PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.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 2.3.2 All 256 releases
give / vendor / paypal / paypal-checkout-sdk / samples / AuthorizeIntentExamples / CaptureOrder.php

CaptureOrder.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php

55 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sample\AuthorizeIntentExamples;
4
5 require __DIR__ . '/../../vendor/autoload.php';
6 use PayPalCheckoutSdk\Payments\AuthorizationsCaptureRequest;
7 use Sample\PayPalClient;
8
9 class CaptureOrder
10 {
11 /**
12 * Below method can be used to build the capture request body.
13 * This request can be updated with required fields as per need.
14 * Please refer API specs for more info.
15 */
16 public static function buildRequestBody()
17 {
18 return "{}";
19 }
20
21 /**
22 * Below function can be used to capture order.
23 * Valid Authorization id should be passed as an argument.
24 */
25 public static function captureOrder($authorizationId, $debug=false)
26 {
27 $request = new AuthorizationsCaptureRequest($authorizationId);
28 $request->body = self::buildRequestBody();
29 $client = PayPalClient::client();
30 $response = $client->execute($request);
31
32 if ($debug)
33 {
34 print "Status Code: {$response->statusCode}\n";
35 print "Status: {$response->result->status}\n";
36 print "Capture ID: {$response->result->id}\n";
37 print "Links:\n";
38 foreach($response->result->links as $link)
39 {
40 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
41 }
42 // To toggle printing the whole response body comment/uncomment below line
43 echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
44 }
45 return $response;
46 }
47 }
48
49 /**
50 * Driver function for invoking the capture flow.
51 */
52 if (!count(debug_backtrace()))
53 {
54 CaptureOrder::captureOrder('18A38324BV5456924', true);
55 }