PayPal\Api\PaymentExecution::setPayerId PHP Method

setPayerId() public method

The ID of the Payer, passed in the return_url by PayPal.
public setPayerId ( string $payer_id )
$payer_id string
    public function setPayerId($payer_id)
    {
        $this->payer_id = $payer_id;
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 public function success()
 {
     $paymentId = request('paymentId');
     $payment = Payment::get($paymentId, $this->paypal);
     $execution = new PaymentExecution();
     $execution->setPayerId(request('PayerID'));
     $transaction = new Transaction();
     $amount = new Amount();
     $details = new Details();
     $productsSum = 0.0;
     foreach ($this->order->getProducts() as $product) {
         $productsSum += $product->getTotal();
     }
     $details->setSubtotal($productsSum);
     $total = $productsSum;
     if ($delivery = $this->order->getDelivery()) {
         $details->setShipping($delivery);
         $total += $delivery;
     }
     if ($vat = $this->order->getVat()) {
         $details->setTax($vat);
         $total += $vat;
     }
     $amount->setCurrency($this->order->getCurrency())->setTotal($total)->setDetails($details);
     $transaction->setAmount($amount);
     $execution->addTransaction($transaction);
     try {
         $payment->execute($execution, $this->paypal);
     } catch (\Exception $e) {
         $this->log($e);
         throw $e;
     } finally {
         Payment::get($paymentId, $this->paypal);
     }
 }
All Usage Examples Of PayPal\Api\PaymentExecution::setPayerId