}/refund require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Authorization; use PayPal\Api\Capture; use PayPal\Api\Refund; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\CreditCard; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; // ### Capture Payment // Capture Payment by posting to the APIService // using a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the status; try { // create payment to get authorization Id $authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); ### Capture $captur = new Capture(); $captur->setAmount($amt); // get the authorization $authorization = Authorization::get($authId, $apiContext); $capt = $authorization->capture($captur, $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } // ### Refund // Create a refund object indicating // refund amount $refund = new Refund(); $refund->setAmount($amt); try { $capture = Capture::get($capt->getId(), $apiContext); // Create a new apiContext object so we send a new // PayPal-Request-Id (idempotency) header for this resource $apiContext = new ApiContext($apiContext->getCredential()); $captureRefund = $capture->refund($refund, $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?>