This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/RefundCapture.php

33 lines
1.1 KiB
PHP
Raw Normal View History

2015-06-21 03:30:38 +00:00
<?php
// # Refund Capture Sample
// This sample code demonstrates how you can
// process a refund on a Captured transaction.
// API used: /v1/payments/capture/{<captureID>}/refund
/** @var Capture $capture */
$capture = require 'AuthorizationCapture.php';
use PayPal\Api\Capture;
use PayPal\Api\Refund;
// ### Refund
// Create a refund object indicating
// refund amount and call the refund method
$refund = new Refund();
$refund->setAmount($amt);
try {
// Create a new apiContext object so we send a new
// PayPal-Request-Id (idempotency) header for this resource
$apiContext = getApiContext($clientId, $clientSecret);
$captureRefund = $capture->refund($refund, $apiContext);
} catch (Exception $ex) {
2015-07-01 00:16:22 +00:00
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Refund Capture", "Capture", null, $refund, $ex);
2015-06-21 03:30:38 +00:00
exit(1);
}
2015-07-01 00:16:22 +00:00
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Refund Capture", "Capture", $captureRefund->getId(), $refund, $captureRefund);