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/ErrorSample.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/ErrorSample.php | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php b/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php index 8daf96b..ee6401b 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php @@ -1,94 +1,94 @@ -<?php - -require __DIR__ . '/../vendor/autoload.php'; - -use PayPalCheckoutSdk\Orders\OrdersCreateRequest; -use Sample\PayPalClient; -use PayPalHttp\HttpException; - -class ErrorSample -{ - public static function prettyPrint($jsonData, $pre="") - { - $pretty = ""; - foreach ($jsonData as $key => $val) - { - $pretty .= $pre . ucfirst($key) .": "; - if (strcmp(gettype($val), "array") == 0){ - $pretty .= "\n"; - $sno = 1; - foreach ($val as $value) - { - $pretty .= $pre . "\t" . $sno++ . ":\n"; - $pretty .= self::prettyPrint($value, $pre . "\t\t"); - } - } - else { - $pretty .= $val . "\n"; - } - } - return $pretty; - } - - /** - * Body has no required parameters (intent, purchase_units) - */ - public static function createError1() - { - $request = new OrdersCreateRequest(); - $request->body = "{}"; - print "Request Body: {}\n\n"; - - print "Response:\n"; - try{ - $client = PayPalClient::client(); - $response = $client->execute($request); - } - catch(HttpException $exception){ - $message = json_decode($exception->getMessage(), true); - print "Status Code: {$exception->statusCode}\n"; - print(self::prettyPrint($message)); - } - } - - /** - * Body has invalid parameter value for intent - */ - public static function createError2() - { - $request = new OrdersCreateRequest(); - $request->body = array ( - 'intent' => 'INVALID', - 'purchase_units' => - array ( - 0 => - array ( - 'amount' => - array ( - 'currency_code' => 'USD', - 'value' => '100.00', - ), - ), - ), - ); - print "Request Body:\n" . json_encode($request->body, JSON_PRETTY_PRINT) . "\n\n"; - - try{ - $client = PayPalClient::client(); - $response = $client->execute($request); - } - catch(HttpException $exception){ - print "Response:\n"; - $message = json_decode($exception->getMessage(), true); - print "Status Code: {$exception->statusCode}\n"; - print(self::prettyPrint($message)); - } - - } -} - -print "Calling createError1 (Body has no required parameters (intent, purchase_units))\n"; -ErrorSample::createError1(); - -print "\n\nCalling createError2 (Body has invalid parameter value for intent)\n"; -ErrorSample::createError2(); +<?php
+
+require __DIR__ . '/../vendor/autoload.php';
+
+use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
+use Sample\PayPalClient;
+use PayPalHttp\HttpException;
+
+class ErrorSample
+{
+ public static function prettyPrint($jsonData, $pre="")
+ {
+ $pretty = "";
+ foreach ($jsonData as $key => $val)
+ {
+ $pretty .= $pre . ucfirst($key) .": ";
+ if (strcmp(gettype($val), "array") == 0){
+ $pretty .= "\n";
+ $sno = 1;
+ foreach ($val as $value)
+ {
+ $pretty .= $pre . "\t" . $sno++ . ":\n";
+ $pretty .= self::prettyPrint($value, $pre . "\t\t");
+ }
+ }
+ else {
+ $pretty .= $val . "\n";
+ }
+ }
+ return $pretty;
+ }
+
+ /**
+ * Body has no required parameters (intent, purchase_units)
+ */
+ public static function createError1()
+ {
+ $request = new OrdersCreateRequest();
+ $request->body = "{}";
+ print "Request Body: {}\n\n";
+
+ print "Response:\n";
+ try{
+ $client = PayPalClient::client();
+ $response = $client->execute($request);
+ }
+ catch(HttpException $exception){
+ $message = json_decode($exception->getMessage(), true);
+ print "Status Code: {$exception->statusCode}\n";
+ print(self::prettyPrint($message));
+ }
+ }
+
+ /**
+ * Body has invalid parameter value for intent
+ */
+ public static function createError2()
+ {
+ $request = new OrdersCreateRequest();
+ $request->body = array (
+ 'intent' => 'INVALID',
+ 'purchase_units' =>
+ array (
+ 0 =>
+ array (
+ 'amount' =>
+ array (
+ 'currency_code' => 'USD',
+ 'value' => '100.00',
+ ),
+ ),
+ ),
+ );
+ print "Request Body:\n" . json_encode($request->body, JSON_PRETTY_PRINT) . "\n\n";
+
+ try{
+ $client = PayPalClient::client();
+ $response = $client->execute($request);
+ }
+ catch(HttpException $exception){
+ print "Response:\n";
+ $message = json_decode($exception->getMessage(), true);
+ print "Status Code: {$exception->statusCode}\n";
+ print(self::prettyPrint($message));
+ }
+
+ }
+}
+
+print "Calling createError1 (Body has no required parameters (intent, purchase_units))\n";
+ErrorSample::createError1();
+
+print "\n\nCalling createError2 (Body has invalid parameter value for intent)\n";
+ErrorSample::createError2();
|