/** * {@inheritDoc} * * @param Authorize $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['reservation']) { return; } $model['activate'] = false; $backupConfig = clone $this->config; $token = $model['recurring_token']; try { unset($model['recurring_token']); $baseUri = Constants::BASE_URI_LIVE == $backupConfig->baseUri ? Constants::BASE_URI_RECURRING_LIVE : Constants::BASE_URI_RECURRING_SANDBOX; $this->config->contentType = Constants::CONTENT_TYPE_RECURRING_ORDER_V1; $this->config->acceptHeader = Constants::ACCEPT_HEADER_RECURRING_ORDER_ACCEPTED_V1; $this->config->baseUri = str_replace('{recurring_token}', $token, $baseUri); $this->gateway->execute($createOrderRequest = new CreateOrder($model)); $model->replace($createOrderRequest->getOrder()->marshal()); } catch (\Exception $e) { $this->config->contentType = $backupConfig->contentType; $this->config->acceptHeader = $backupConfig->acceptHeader; $this->config->baseUri = $backupConfig->baseUri; $model['recurring_token'] = $token; throw $e; } $model['recurring_token'] = $token; $this->config->contentType = $backupConfig->contentType; $this->config->acceptHeader = $backupConfig->acceptHeader; $this->config->baseUri = $backupConfig->baseUri; }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request \Payum\Core\Request\Capture */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model['location']) { $this->payment->execute($createOrder = new CreateOrder($model)); $model->replace($createOrder->getOrder()->marshal()); $model['location'] = $createOrder->getOrder()->getLocation(); } $this->payment->execute(new Sync($model)); if (Constants::STATUS_CHECKOUT_INCOMPLETE == $model['status']) { $renderTemplate = new RenderTemplate($this->templateName, array('snippet' => $model['gui']['snippet'])); $this->payment->execute($renderTemplate); throw new HttpResponse($renderTemplate->getResult()); } }