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 / GetOrder.php

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

54 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
7 use Sample\PayPalClient;
8 use PayPalCheckoutSdk\Orders\OrdersGetRequest;
9 use Sample\CaptureIntentExamples\CreateOrder;
10
11 class GetOrder
12 {
13
14 /**
15 * This function can be used to retrieve an order by passing order Id as argument.
16 */
17 public static function getOrder($orderId)
18 {
19
20 $client = PayPalClient::client();
21 $response = $client->execute(new OrdersGetRequest($orderId));
22 /**
23 * Enable below line to print complete response as JSON.
24 */
25 //print json_encode($response->result);
26 print "Status Code: {$response->statusCode}\n";
27 print "Status: {$response->result->status}\n";
28 print "Order ID: {$response->result->id}\n";
29 print "Intent: {$response->result->intent}\n";
30 print "Links:\n";
31 foreach($response->result->links as $link)
32 {
33 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
34 }
35
36 print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n";
37
38 // To toggle printing the whole response body comment/uncomment below line
39 echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
40 }
41 }
42
43 /**
44 * This is the driver function which invokes the getOrder function to retrieve
45 * an sample order.
46 *
47 * To get the correct Order id, we are using the createOrder to create new order
48 * and then we are using the newly created order id.
49 */
50 if (!count(debug_backtrace()))
51 {
52 $createdOrder = CreateOrder::createOrder()->result;
53 GetOrder::getOrder($createdOrder ->id);
54 }