}/refund require __DIR__ . '/../bootstrap.php'; 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; // create payment to get authorization Id $authId = createAuthorization(); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); ### Capture $captur = new Capture(); $captur->setId($authId); $captur->setAmount($amt); // get the authorization $authorization = Authorization::get($authId, $apiContext); // ### 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 { $capt = $authorization->capture($captur, $apiContext); } catch (\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->setId($capt->getId()); $refund->setAmount($amt); $capture = Capture::get($capt->getId(), $apiContext); try { // (See bootstrap.php for more on `ApiContext`) $captureRefund = $capture->refund($refund, $apiContext); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?>