/execute'. require __DIR__ . '/../bootstrap.php'; use PayPal\Api\ExecutePayment; use PayPal\Api\Payment; use PayPal\Api\PaymentExecution; session_start(); if(isset($_GET['success']) && $_GET['success'] == 'true') { // Get the payment Object by passing paymentId // payment id was previously stored in session in // CreatePaymentUsingPayPal.php $paymentId = $_SESSION['paymentId']; $payment = Payment::get($paymentId, $apiContext); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayer_id($_GET['PayerID']); //Execute the payment // (See bootstrap.php for more on `ApiContext`) $payment->execute($execution, $apiContext); echo "
"; var_dump($payment->toArray()); echo "Back"; } else { echo "User cancelled payment."; }