Payum\Paypal\Rest\Action\CaptureAction::execute PHP Method

execute() public method

{@inheritDoc}
public execute ( $request )
    public function execute($request)
    {
        /** @var $request Capture */
        RequestNotSupportedException::assertSupports($this, $request);
        /** @var PaypalPayment $model */
        $model = $request->getModel();
        if (false == isset($model->state) && isset($model->payer->payment_method) && 'paypal' == $model->payer->payment_method) {
            $model->create($this->api);
            foreach ($model->links as $link) {
                if ($link->rel == 'approval_url') {
                    throw new HttpRedirect($link->href);
                }
            }
        }
        if (false == isset($model->state) && isset($model->payer->payment_method) && 'credit_card' == $model->payer->payment_method) {
            $model->create($this->api);
        }
        if (true == isset($model->state) && isset($model->payer->payment_method) && 'paypal' == $model->payer->payment_method) {
            $execution = new PaymentExecution();
            $execution->payer_id = $_GET['PayerID'];
            //Execute the payment
            $model->execute($execution, $this->api);
        }
    }

Usage Example

Example #1
0
 /**
  * {@inheritDoc}
  *
  * @param Authorize $request
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     $details = ArrayObject::ensureArrayObject($request->getModel());
     if (!empty($details['PayerID'])) {
         return parent::execute($request);
     }
     if (empty($details['approval_url'])) {
         $this->createPayment($details);
     }
     $paypalConfig = ['approvalUrl' => $details['approval_url'], 'preselection' => 'none', 'mode' => $this->api->get('mode'), 'country' => $details['PAYMENTREQUEST_SHIPPING_ADDRESS']['country_code'], 'showPuiOnSandbox' => true, 'useraction' => 'commit'];
     $renderTemplate = new RenderTemplate(self::TEMPLATE, ['config' => $paypalConfig]);
     $this->gateway->execute($renderTemplate);
     throw new HttpResponse($renderTemplate->getResult());
 }
All Usage Examples Of Payum\Paypal\Rest\Action\CaptureAction::execute