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 / CaptureIntentExamples / CaptureOrder.php

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

60 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
4 namespace Sample\CaptureIntentExamples;
5
6 require __DIR__ . '/../../vendor/autoload.php';
7 use Sample\PayPalClient;
8 use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
9
10 class CaptureOrder
11 {
12
13 /**
14 * This function can be used to capture an order payment by passing the approved
15 * order id as argument.
16 *
17 * @param orderId
18 * @param debug
19 * @returns
20 */
21 public static function captureOrder($orderId, $debug=false)
22 {
23 $request = new OrdersCaptureRequest($orderId);
24
25 $client = PayPalClient::client();
26 $response = $client->execute($request);
27 if ($debug)
28 {
29 print "Status Code: {$response->statusCode}\n";
30 print "Status: {$response->result->status}\n";
31 print "Order ID: {$response->result->id}\n";
32 print "Links:\n";
33 foreach($response->result->links as $link)
34 {
35 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
36 }
37 print "Capture Ids:\n";
38 foreach($response->result->purchase_units as $purchase_unit)
39 {
40 foreach($purchase_unit->payments->captures as $capture)
41 {
42 print "\t{$capture->id}";
43 }
44 }
45 // To toggle printing the whole response body comment/uncomment below line
46 echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
47 }
48
49 return $response;
50 }
51 }
52
53 /**
54 * This is the driver function which invokes the captureOrder function with
55 * <b>Approved</b> Order Id to capture the order payment.
56 */
57 if (!count(debug_backtrace()))
58 {
59 CaptureOrder::captureOrder('0F105083N67049335', true);
60 }