diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
-rw-r--r-- | vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php index cba8152..e8f45b1 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php @@ -1,82 +1,82 @@ -<?php - -namespace Sample; - -require __DIR__ . '/../vendor/autoload.php'; - -use PayPalCheckoutSdk\Orders\OrdersPatchRequest; -use PayPalCheckoutSdk\Orders\OrdersGetRequest; -use Sample\AuthorizeIntentExamples\CreateOrder; - -class PatchOrder -{ - private static function buildRequestBody() - { - return array ( - 0 => - array ( - 'op' => 'replace', - 'path' => '/intent', - 'value' => 'CAPTURE', - ), - 1 => - array ( - 'op' => 'replace', - 'path' => '/purchase_units/@reference_id==\'PUHF\'/amount', - 'value' => - array ( - 'currency_code' => 'USD', - 'value' => '200.00', - 'breakdown' => - array ( - 'item_total' => - array ( - 'currency_code' => 'USD', - 'value' => '180.00', - ), - 'tax_total' => - array ( - 'currency_code' => 'USD', - 'value' => '20.00', - ), - ), - ), - ), - ); - } - - public static function patchOrder($orderId) - { - - $client = PayPalClient::client(); - - $request = new OrdersPatchRequest($orderId); - $request->body = PatchOrder::buildRequestBody(); - $client->execute($request); - - $response = $client->execute(new OrdersGetRequest($orderId)); - - print "Status Code: {$response->statusCode}\n"; - print "Status: {$response->result->status}\n"; - print "Order ID: {$response->result->id}\n"; - print "Intent: {$response->result->intent}\n"; - print "Links:\n"; - foreach($response->result->links as $link) - { - print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; - } - - print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n"; - - // To toggle printing the whole response body comment/uncomment below line - echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; - } -} - -if (!count(debug_backtrace())) -{ - print "Before PATCH:\n"; - $createdOrder = CreateOrder::createOrder(true)->result; - print "\nAfter PATCH (Changed Intent and Amount):\n"; - PatchOrder::patchOrder($createdOrder->id); +<?php
+
+namespace Sample;
+
+require __DIR__ . '/../vendor/autoload.php';
+
+use PayPalCheckoutSdk\Orders\OrdersPatchRequest;
+use PayPalCheckoutSdk\Orders\OrdersGetRequest;
+use Sample\AuthorizeIntentExamples\CreateOrder;
+
+class PatchOrder
+{
+ private static function buildRequestBody()
+ {
+ return array (
+ 0 =>
+ array (
+ 'op' => 'replace',
+ 'path' => '/intent',
+ 'value' => 'CAPTURE',
+ ),
+ 1 =>
+ array (
+ 'op' => 'replace',
+ 'path' => '/purchase_units/@reference_id==\'PUHF\'/amount',
+ 'value' =>
+ array (
+ 'currency_code' => 'USD',
+ 'value' => '200.00',
+ 'breakdown' =>
+ array (
+ 'item_total' =>
+ array (
+ 'currency_code' => 'USD',
+ 'value' => '180.00',
+ ),
+ 'tax_total' =>
+ array (
+ 'currency_code' => 'USD',
+ 'value' => '20.00',
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ public static function patchOrder($orderId)
+ {
+
+ $client = PayPalClient::client();
+
+ $request = new OrdersPatchRequest($orderId);
+ $request->body = PatchOrder::buildRequestBody();
+ $client->execute($request);
+
+ $response = $client->execute(new OrdersGetRequest($orderId));
+
+ print "Status Code: {$response->statusCode}\n";
+ print "Status: {$response->result->status}\n";
+ print "Order ID: {$response->result->id}\n";
+ print "Intent: {$response->result->intent}\n";
+ print "Links:\n";
+ foreach($response->result->links as $link)
+ {
+ print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
+ }
+
+ print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n";
+
+ // To toggle printing the whole response body comment/uncomment below line
+ echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
+ }
+}
+
+if (!count(debug_backtrace()))
+{
+ print "Before PATCH:\n";
+ $createdOrder = CreateOrder::createOrder(true)->result;
+ print "\nAfter PATCH (Changed Intent and Amount):\n";
+ PatchOrder::patchOrder($createdOrder->id);
}
\ No newline at end of file |