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

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

75 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require __DIR__ . '/../../vendor/autoload.php';
4
5 use Sample\CaptureIntentExamples\CreateOrder;
6 use Sample\CaptureIntentExamples\CaptureOrder;
7 use Sample\RefundOrder;
8
9 $order = CreateOrder::createOrder();
10
11 print "Creating Order...\n";
12 $orderId = "";
13 if ($order->statusCode == 201)
14 {
15 $orderId = $order->result->id;
16 print "Links:\n";
17 for ($i = 0; $i < count($order->result->links); ++$i)
18 {
19 $link = $order->result->links[$i];
20 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
21 }
22 print "Created Successfully\n";
23 print "Copy approve link and paste it in browser. Login with buyer account and follow the instructions.\nOnce approved hit enter...\n";
24 }
25 else {
26 exit(1);
27 }
28
29 $handle = fopen ("php://stdin","r");
30 $line = fgets($handle);
31 fclose($handle);
32
33 print "Capturing Order...\n";
34 $response = CaptureOrder::captureOrder($orderId);
35 if ($response->statusCode == 201)
36 {
37 print "Captured Successfully\n";
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 for ($i = 0; $i < count($response->result->links); ++$i){
43 $link = $response->result->links[$i];
44 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
45 }
46 foreach($response->result->purchase_units as $purchase_unit)
47 {
48 foreach($purchase_unit->payments->captures as $capture)
49 {
50 $captureId = $capture->id;
51 }
52 }
53 }
54 else {
55 exit(1);
56 }
57
58 print "\nRefunding Order...\n";
59 $response = RefundOrder::refundOrder($captureId);
60 if ($response->statusCode == 201)
61 {
62 print "Refunded Successfully\n";
63 print "Status Code: {$response->statusCode}\n";
64 print "Status: {$response->result->status}\n";
65 print "Refund ID: {$response->result->id}\n";
66 print "Links:\n";
67 for ($i = 0; $i < count($response->result->links); ++$i){
68 $link = $response->result->links[$i];
69 print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
70 }
71 }
72 else {
73 exit(1);
74 }
75