PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / vendor / paypal / paypal-checkout-sdk / samples / RefundOrder.php

RefundOrder.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php

61 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sample;
4
5 require __DIR__ . '/../vendor/autoload.php';
6 use Sample\PayPalClient;
7 use PayPalCheckoutSdk\Payments\CapturesRefundRequest;
8
9 class RefundOrder
10 {
11
12 /**
13 * Function to create an refund capture request. Payload can be updated to issue partial refund.
14 */
15 public static function buildRequestBody()
16 {
17 return array(
18 'amount' =>
19 array(
20 'value' => '20.00',
21 'currency_code' => 'USD'
22 )
23 );
24 }
25
26 /**
27 * This function can be used to preform refund on the capture.
28 */
29 public static function refundOrder($captureId, $debug=false)
30 {
31 $request = new CapturesRefundRequest($captureId);
32 $request->body = self::buildRequestBody();
33 $client = PayPalClient::client();
34 $response = $client->execute($request);
35
36 if ($debug)
37 {
38 print "Status Code: {$response->statusCode}\n";
39 print "Status: {$response->result->status}\n";
40 print "Order ID: {$response->result->id}\n";
41 print "Links:\n";
42 foreach($response->result->links as $link)
43 {
44 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
45 }
46 // To toggle printing the whole response body comment/uncomment below line
47 echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
48 }
49 return $response;
50 }
51 }
52
53 /**
54 * This is the driver function which invokes the refund capture function with
55 * Capture Id to perform refund on capture.
56 */
57 if (!count(debug_backtrace()))
58 {
59 RefundOrder::refundOrder('8XL09935J2224701N', true);
60 }
61