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 / AuthorizeIntentExamples / AuthorizeOrder.php

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

61 lines 2.0 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\Orders\OrdersAuthorizeRequest;
7 use Sample\PayPalClient;
8
9
10 class AuthorizeOrder
11 {
12 /**
13 * Setting up request body for Authorize. This can be populated with fields as per need. Refer API docs for more details.
14 *
15 */
16 public static function buildRequestBody()
17 {
18 return "{}";
19 }
20
21 /**
22 * This function can be used to perform authorization on the approved order.
23 * Valid Approved order id should be passed as an argument.
24 */
25 public static function authorizeOrder($orderId, $debug=false)
26 {
27 $request = new OrdersAuthorizeRequest($orderId);
28 $request->body = self::buildRequestBody();
29
30 $client = PayPalClient::client();
31 $response = $client->execute($request);
32 if ($debug)
33 {
34 print "Status Code: {$response->statusCode}\n";
35 print "Status: {$response->result->status}\n";
36 print "Order ID: {$response->result->id}\n";
37 print "Authorization ID: {$response->result->purchase_units[0]->payments->authorizations[0]->id}\n";
38 print "Links:\n";
39 foreach($response->result->links as $link)
40 {
41 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
42 }
43 print "Authorization Links:\n";
44 foreach($response->result->purchase_units[0]->payments->authorizations[0]->links as $link)
45 {
46 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
47 }
48 // To toggle printing the whole response body comment/uncomment below line
49 echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
50 }
51 return $response;
52 }
53 }
54
55 /**
56 * This is an driver function which invokes authorize order.
57 */
58 if (!count(debug_backtrace()))
59 {
60 AuthorizeOrder::authorizeOrder('1U242387CB956380X', true);
61 }