From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- vendor/paypal/paypal-checkout-sdk/.gitignore | 2 + vendor/paypal/paypal-checkout-sdk/LICENSE | 86 ++++++++ vendor/paypal/paypal-checkout-sdk/README.md | 169 +++++++++++++++ vendor/paypal/paypal-checkout-sdk/composer.json | 35 +++ vendor/paypal/paypal-checkout-sdk/composer.phar | Bin 0 -> 1874955 bytes vendor/paypal/paypal-checkout-sdk/gen.yml | 6 + vendor/paypal/paypal-checkout-sdk/homepage.jpg | Bin 0 -> 165333 bytes vendor/paypal/paypal-checkout-sdk/init | 0 .../lib/PayPalCheckoutSdk/Core/AccessToken.php | 25 +++ .../PayPalCheckoutSdk/Core/AccessTokenRequest.php | 27 +++ .../Core/AuthorizationInjector.php | 51 +++++ .../Core/FPTIInstrumentationInjector.php | 16 ++ .../lib/PayPalCheckoutSdk/Core/GzipInjector.php | 14 ++ .../PayPalCheckoutSdk/Core/PayPalEnvironment.php | 23 ++ .../PayPalCheckoutSdk/Core/PayPalHttpClient.php | 27 +++ .../Core/ProductionEnvironment.php | 16 ++ .../PayPalCheckoutSdk/Core/RefreshTokenRequest.php | 19 ++ .../PayPalCheckoutSdk/Core/SandboxEnvironment.php | 16 ++ .../lib/PayPalCheckoutSdk/Core/UserAgent.php | 52 +++++ .../lib/PayPalCheckoutSdk/Core/Version.php | 8 + .../Orders/OrdersAuthorizeRequest.php | 37 ++++ .../Orders/OrdersCaptureRequest.php | 37 ++++ .../Orders/OrdersCreateRequest.php | 31 +++ .../PayPalCheckoutSdk/Orders/OrdersGetRequest.php | 26 +++ .../Orders/OrdersPatchRequest.php | 26 +++ .../Orders/OrdersValidateRequest.php | 29 +++ .../Payments/AuthorizationsCaptureRequest.php | 33 +++ .../Payments/AuthorizationsGetRequest.php | 25 +++ .../Payments/AuthorizationsReauthorizeRequest.php | 33 +++ .../Payments/AuthorizationsVoidRequest.php | 25 +++ .../Payments/CapturesGetRequest.php | 25 +++ .../Payments/CapturesRefundRequest.php | 33 +++ .../Payments/RefundsGetRequest.php | 25 +++ vendor/paypal/paypal-checkout-sdk/phpunit.xml | 9 + .../AuthorizeIntentExamples/AuthorizeOrder.php | 61 ++++++ .../AuthorizeIntentExamples/CaptureOrder.php | 55 +++++ .../AuthorizeIntentExamples/CreateOrder.php | 237 +++++++++++++++++++++ .../samples/AuthorizeIntentExamples/RunAll.php | 82 +++++++ .../samples/CaptureIntentExamples/CaptureOrder.php | 60 ++++++ .../samples/CaptureIntentExamples/CreateOrder.php | 178 ++++++++++++++++ .../samples/CaptureIntentExamples/RunAll.php | 74 +++++++ .../paypal-checkout-sdk/samples/ErrorSample.php | 94 ++++++++ .../paypal-checkout-sdk/samples/GetOrder.php | 54 +++++ .../paypal-checkout-sdk/samples/PatchOrder.php | 82 +++++++ .../paypal-checkout-sdk/samples/PayPalClient.php | 35 +++ .../paypal-checkout-sdk/samples/RefundOrder.php | 60 ++++++ .../tests/Orders/OrdersAuthorizeTest.php | 26 +++ .../tests/Orders/OrdersCaptureTest.php | 26 +++ .../tests/Orders/OrdersCreateTest.php | 69 ++++++ .../tests/Orders/OrdersGetTest.php | 48 +++++ .../tests/Orders/OrdersPatchTest.php | 73 +++++++ .../paypal-checkout-sdk/tests/TestHarness.php | 24 +++ 52 files changed, 2324 insertions(+) create mode 100644 vendor/paypal/paypal-checkout-sdk/.gitignore create mode 100644 vendor/paypal/paypal-checkout-sdk/LICENSE create mode 100644 vendor/paypal/paypal-checkout-sdk/README.md create mode 100644 vendor/paypal/paypal-checkout-sdk/composer.json create mode 100644 vendor/paypal/paypal-checkout-sdk/composer.phar create mode 100644 vendor/paypal/paypal-checkout-sdk/gen.yml create mode 100644 vendor/paypal/paypal-checkout-sdk/homepage.jpg create mode 100644 vendor/paypal/paypal-checkout-sdk/init create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/RefreshTokenRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/UserAgent.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/Version.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersAuthorizeRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/phpunit.xml create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php create mode 100644 vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php create mode 100644 vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php (limited to 'vendor/paypal/paypal-checkout-sdk') diff --git a/vendor/paypal/paypal-checkout-sdk/.gitignore b/vendor/paypal/paypal-checkout-sdk/.gitignore new file mode 100644 index 0000000..4c36e38 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/.gitignore @@ -0,0 +1,2 @@ +.idea/ +vendor/ diff --git a/vendor/paypal/paypal-checkout-sdk/LICENSE b/vendor/paypal/paypal-checkout-sdk/LICENSE new file mode 100644 index 0000000..67d9ac3 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/LICENSE @@ -0,0 +1,86 @@ +The PayPal Node SDK is released under the following license: + + Copyright (c) 2013-2019 PAYPAL, INC. + + SDK LICENSE + + NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of + this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, + or any derivatives or portions hereof, constitutes your acceptance of this Agreement. + + As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying + this agreement. "Documentation" means the documents, specifications and all other items accompanying + this Agreement other than the Software. + + 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, + worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, + publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice + below appears in a conspicuous location within the source code of the distributed Software and this + license is distributed in the supporting documentation of the Software you distribute. Furthermore, + you must comply with all third party licenses in order to use the third party software contained in the + Software. + + Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free + license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation + for any purpose. You may not modify the Documentation. + + No title to the intellectual property in the Software or Documentation is transferred to you under the + terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as + expressly set forth in this Agreement. + + If you choose to distribute the Software in a commercial product, you do so with the understanding that + you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and + costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may + distribute the Software in object code form under your own license, provided that your license agreement: + + (a) complies with the terms and conditions of this license agreement; + + (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal; + + (c) effectively excludes all liability for damages on behalf of PayPal; + + (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and + + (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a + reasonable manner on or through a medium customarily used for software exchange. + + 2. DISCLAIMER OF WARRANTY + PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, + NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE + SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible + for determining the appropriateness of using and distributing the Software and Documentation and assumes all + risks associated with its exercise of rights under this Agreement, including but not limited to the risks and + costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, + and unavailability or interruption of operations. Use of the Software and Documentation is made with the + understanding that PayPal will not provide you with any technical or customer support or maintenance. Some + states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied + warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied + warranties are limited to ninety (90) days. + + + 3. LIMITATION OF LIABILITY + PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE + OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY + FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, + COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY + TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE + LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. + + 4. TRADEMARK USAGE + PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used + to endorse or promote any product unless expressly permitted under separate agreement with PayPal. + + 5. TERM + Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or + conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming + aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use + and distribution of the Software and Documentation as soon as reasonably practicable. + + 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of + California, without regard to the conflicts of law principles thereof. If any part of this Agreement is + found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall + remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement + shall be brought in the courts of Santa Clara County, California, USA. diff --git a/vendor/paypal/paypal-checkout-sdk/README.md b/vendor/paypal/paypal-checkout-sdk/README.md new file mode 100644 index 0000000..d8aedc0 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/README.md @@ -0,0 +1,169 @@ +# REST API SDK for PHP V2 + +![Home Image](homepage.jpg) + +__Welcome to PayPal PHP SDK__. This repository contains PayPal's PHP SDK and samples for [v2/checkout/orders](https://developer.paypal.com/docs/api/orders/v2/) and [v2/payments](https://developer.paypal.com/docs/api/payments/v2/) APIs. + +This is a part of the next major PayPal SDK. It includes a simplified interface to only provide simple model objects and blueprints for HTTP calls. This repo currently contains functionality for PayPal Checkout APIs which includes [Orders V2](https://developer.paypal.com/docs/api/orders/v2/) and [Payments V2](https://developer.paypal.com/docs/api/payments/v2/). + +Please refer to the [PayPal Checkout Integration Guide](https://developer.paypal.com/docs/checkout/) for more information. Also refer to [Setup your SDK](https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/) for additional information about setting up the SDK's. + +## Prerequisites + +PHP 5.6 and above + +An environment which supports TLS 1.2 (see the TLS-update site for more information) + +## Usage + +### Binaries + +It is not mandatory to fork this repository for using the PayPal SDK. You can refer [PayPal Checkout Server SDK](https://developer.paypal.com/docs/checkout/reference/server-integration) for configuring and working with SDK without forking this code. + +For contirbuting or referrring the samples, You can fork/refer this repository. + +### Setting up credentials +Get client ID and client secret by going to https://developer.paypal.com/developer/applications and generating a REST API app. Get Client ID and Secret from there. + +```php +require __DIR__ . '/vendor/autoload.php'; +use PayPalCheckoutSdk\Core\PayPalHttpClient; +use PayPalCheckoutSdk\Core\SandboxEnvironment; +// Creating an environment +$clientId = "<>"; +$clientSecret = "<>"; + +$environment = new SandboxEnvironment($clientId, $clientSecret); +$client = new PayPalHttpClient($environment); +``` + +## Examples +### Creating an Order +#### Code: +```php +// Construct a request object and set desired parameters +// Here, OrdersCreateRequest() creates a POST request to /v2/checkout/orders +use PayPalCheckoutSdk\Orders\OrdersCreateRequest; +$request = new OrdersCreateRequest(); +$request->prefer('return=representation'); +$request->body = [ + "intent" => "CAPTURE", + "purchase_units" => [[ + "reference_id" => "test_ref_id1", + "amount" => [ + "value" => "100.00", + "currency_code" => "USD" + ] + ]], + "application_context" => [ + "cancel_url" => "https://example.com/cancel", + "return_url" => "https://example.com/return" + ] + ]; + +try { + // Call API with your client and get a response for your call + $response = $client->execute($request); + + // If call returns body in response, you can get the deserialized version from the result attribute of the response + print_r($response); +}catch (HttpException $ex) { + echo $ex->statusCode; + print_r($ex->getMessage()); +} +``` +#### Example Output: +``` +Status Code: 201 +Id: 8GB67279RC051624C +Intent: CAPTURE +Gross_amount: + Currency_code: USD + Value: 100.00 +Purchase_units: + 1: + Amount: + Currency_code: USD + Value: 100.00 +Create_time: 2018-08-06T23:34:31Z +Links: + 1: + Href: https://api.sandbox.paypal.com/v2/checkout/orders/8GB67279RC051624C + Rel: self + Method: GET + 2: + Href: https://www.sandbox.paypal.com/checkoutnow?token=8GB67279RC051624C + Rel: approve + Method: GET + 3: + Href: https://api.sandbox.paypal.com/v2/checkout/orders/8GB67279RC051624C/capture + Rel: capture + Method: POST +Status: CREATED +``` + +## Capturing an Order +Before capture, Order should be approved by the buyer using the approval URL returned in the create order response. +### Code to Execute: +```php +use PayPalCheckoutSdk\Orders\OrdersCaptureRequest; +// Here, OrdersCaptureRequest() creates a POST request to /v2/checkout/orders +// $response->result->id gives the orderId of the order created above +$request = new OrdersCaptureRequest("APPROVED-ORDER-ID"); +$request->prefer('return=representation'); +try { + // Call API with your client and get a response for your call + $response = $client->execute($request); + + // If call returns body in response, you can get the deserialized version from the result attribute of the response + print_r($response); +}catch (HttpException $ex) { + echo $ex->statusCode; + print_r($ex->getMessage()); +} +``` + +#### Example Output: +``` +Status Code: 201 +Id: 8GB67279RC051624C +Create_time: 2018-08-06T23:39:11Z +Update_time: 2018-08-06T23:39:11Z +Payer: + Name: + Given_name: test + Surname: buyer + Email_address: test-buyer@paypal.com + Payer_id: KWADC7LXRRWCE + Phone: + Phone_number: + National_number: 408-411-2134 + Address: + Country_code: US +Links: + 1: + Href: https://api.sandbox.paypal.com/v2/checkout/orders/3L848818A2897925Y + Rel: self + Method: GET +Status: COMPLETED +``` + +## Running tests + +To run integration tests using your client id and secret, clone this repository and run the following command: +```sh +$ composer install +$ CLIENT_ID=YOUR_SANDBOX_CLIENT_ID CLIENT_SECRET=OUR_SANDBOX_CLIENT_SECRET composer integration +``` + +## Samples + +You can start off by trying out [creating and capturing an order](/samples/CaptureIntentExamples/RunAll.php) + +To try out different samples for both create and authorize intent check [this link](/samples) + +Note: Update the `PayPalClient.php` with your sandbox client credentials or pass your client credentials as environment variable whie executing the samples. + + +## License +Code released under [SDK LICENSE](LICENSE) diff --git a/vendor/paypal/paypal-checkout-sdk/composer.json b/vendor/paypal/paypal-checkout-sdk/composer.json new file mode 100644 index 0000000..0676fb4 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/composer.json @@ -0,0 +1,35 @@ +{ + "name": "paypal/paypal-checkout-sdk", + "description": "PayPal's PHP SDK for Checkout REST APIs", + "keywords": ["paypal", "payments", "rest", "sdk", "orders", "checkout"], + "type": "library", + "license": "https://github.com/paypal/Checkout-PHP-SDK/blob/master/LICENSE", + "homepage": "http://github.com/paypal/Checkout-PHP-SDK/", + "require": { + "paypal/paypalhttp": "1.0.0" + }, + "authors": [ + { + "name": "PayPal", + "homepage": "https://github.com/paypal/Checkout-PHP-SDK/contributors" + } + ], + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "autoload": { + "psr-4": { + "PayPalCheckoutSdk\\": "lib/PayPalCheckoutSdk", + "Sample\\":"samples/" + } + }, + "autoload-dev": { + "psr-4": { + "Test\\":"tests/" + } + }, + "scripts": { + "unit": "phpunit --testsuite unit", + "integration": "phpunit --testsuite integration" + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/composer.phar b/vendor/paypal/paypal-checkout-sdk/composer.phar new file mode 100644 index 0000000..801b9a9 Binary files /dev/null and b/vendor/paypal/paypal-checkout-sdk/composer.phar differ diff --git a/vendor/paypal/paypal-checkout-sdk/gen.yml b/vendor/paypal/paypal-checkout-sdk/gen.yml new file mode 100644 index 0000000..b6f3f79 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/gen.yml @@ -0,0 +1,6 @@ +--- +projectName: PayPalCheckoutSdk +language: php +sourcePath: lib/PayPalCheckoutSdk +testPath: tests +apiVersioning: false diff --git a/vendor/paypal/paypal-checkout-sdk/homepage.jpg b/vendor/paypal/paypal-checkout-sdk/homepage.jpg new file mode 100644 index 0000000..9b7aa61 Binary files /dev/null and b/vendor/paypal/paypal-checkout-sdk/homepage.jpg differ diff --git a/vendor/paypal/paypal-checkout-sdk/init b/vendor/paypal/paypal-checkout-sdk/init new file mode 100644 index 0000000..e69de29 diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php new file mode 100644 index 0000000..b6f1d2d --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php @@ -0,0 +1,25 @@ +token = $token; + $this->tokenType = $tokenType; + $this->expiresIn = $expiresIn; + $this->createDate = time(); + } + + public function isExpired() + { + return time() >= $this->createDate + $this->expiresIn; + } +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php new file mode 100644 index 0000000..5c3e26e --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php @@ -0,0 +1,27 @@ +headers["Authorization"] = "Basic " . $environment->authorizationString(); + $body = [ + "grant_type" => "client_credentials" + ]; + + if (!is_null($refreshToken)) + { + $body["grant_type"] = "refresh_token"; + $body["refresh_token"] = $refreshToken; + } + + $this->body = $body; + $this->headers["Content-Type"] = "application/x-www-form-urlencoded"; + } +} + diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php new file mode 100644 index 0000000..0b38bba --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php @@ -0,0 +1,51 @@ +client = $client; + $this->environment = $environment; + $this->refreshToken = $refreshToken; + } + + public function inject($request) + { + if (!$this->hasAuthHeader($request) && !$this->isAuthRequest($request)) + { + if (is_null($this->accessToken) || $this->accessToken->isExpired()) + { + $this->accessToken = $this->fetchAccessToken(); + } + $request->headers['Authorization'] = 'Bearer ' . $this->accessToken->token; + } + } + + private function fetchAccessToken() + { + $accessTokenResponse = $this->client->execute(new AccessTokenRequest($this->environment, $this->refreshToken)); + $accessToken = $accessTokenResponse->result; + return new AccessToken($accessToken->access_token, $accessToken->token_type, $accessToken->expires_in); + } + + private function isAuthRequest($request) + { + return $request instanceof AccessTokenRequest || $request instanceof RefreshTokenRequest; + } + + private function hasAuthHeader(HttpRequest $request) + { + return array_key_exists("Authorization", $request->headers); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php new file mode 100644 index 0000000..898a750 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php @@ -0,0 +1,16 @@ +headers["sdk_name"] = "Checkout SDK"; + $request->headers["sdk_version"] = "1.0.1"; + $request->headers["sdk_tech_stack"] = "PHP " . PHP_VERSION; + $request->headers["api_integration_type"] = "PAYPALSDK"; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php new file mode 100644 index 0000000..202b6b1 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php @@ -0,0 +1,14 @@ +headers["Accept-Encoding"] = "gzip"; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php new file mode 100644 index 0000000..252864b --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php @@ -0,0 +1,23 @@ +clientId = $clientId; + $this->clientSecret = $clientSecret; + } + + public function authorizationString() + { + return base64_encode($this->clientId . ":" . $this->clientSecret); + } +} + diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php new file mode 100644 index 0000000..3b3c205 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php @@ -0,0 +1,27 @@ +refreshToken = $refreshToken; + $this->authInjector = new AuthorizationInjector($this, $environment, $refreshToken); + $this->addInjector($this->authInjector); + $this->addInjector(new GzipInjector()); + $this->addInjector(new FPTIInstrumentationInjector()); + } + + public function userAgent() + { + return UserAgent::getValue(); + } +} + diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php new file mode 100644 index 0000000..20a47b2 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php @@ -0,0 +1,16 @@ +headers["Authorization"] = "Basic " . $environment->authorizationString(); + $this->headers["Content-Type"] = "application/x-www-form-urlencoded"; + $this->body = [ + "grant_type" => "authorization_code", + "code" => $authorizationCode + ]; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php new file mode 100644 index 0000000..92c1f7a --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php @@ -0,0 +1,16 @@ +path = str_replace("{order_id}", urlencode($orderId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalClientMetadataId($payPalClientMetadataId) + { + $this->headers["PayPal-Client-Metadata-Id"] = $payPalClientMetadataId; + } + public function payPalRequestId($payPalRequestId) + { + $this->headers["PayPal-Request-Id"] = $payPalRequestId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php new file mode 100644 index 0000000..8af8a60 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php @@ -0,0 +1,37 @@ +path = str_replace("{order_id}", urlencode($orderId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalClientMetadataId($payPalClientMetadataId) + { + $this->headers["PayPal-Client-Metadata-Id"] = $payPalClientMetadataId; + } + public function payPalRequestId($payPalRequestId) + { + $this->headers["PayPal-Request-Id"] = $payPalRequestId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php new file mode 100644 index 0000000..0d9f5a9 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php @@ -0,0 +1,31 @@ +headers["Content-Type"] = "application/json"; + } + + + public function payPalPartnerAttributionId($payPalPartnerAttributionId) + { + $this->headers["PayPal-Partner-Attribution-Id"] = $payPalPartnerAttributionId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php new file mode 100644 index 0000000..3d1c8f1 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php @@ -0,0 +1,26 @@ +path = str_replace("{order_id}", urlencode($orderId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php new file mode 100644 index 0000000..4313c42 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php @@ -0,0 +1,26 @@ +path = str_replace("{order_id}", urlencode($orderId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php new file mode 100644 index 0000000..0a68f90 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php @@ -0,0 +1,29 @@ +path = str_replace("{order_id}", urlencode($orderId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalClientMetadataId($payPalClientMetadataId) + { + $this->headers["PayPal-Client-Metadata-Id"] = $payPalClientMetadataId; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php new file mode 100644 index 0000000..68d5e81 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php @@ -0,0 +1,33 @@ +path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalRequestId($payPalRequestId) + { + $this->headers["PayPal-Request-Id"] = $payPalRequestId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php new file mode 100644 index 0000000..e088224 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php @@ -0,0 +1,25 @@ +path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php new file mode 100644 index 0000000..7547ece --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php @@ -0,0 +1,33 @@ +path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalRequestId($payPalRequestId) + { + $this->headers["PayPal-Request-Id"] = $payPalRequestId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php new file mode 100644 index 0000000..f5c0f74 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php @@ -0,0 +1,25 @@ +path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php new file mode 100644 index 0000000..5b9b335 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php @@ -0,0 +1,25 @@ +path = str_replace("{capture_id}", urlencode($captureId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php new file mode 100644 index 0000000..7624c6b --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php @@ -0,0 +1,33 @@ +path = str_replace("{capture_id}", urlencode($captureId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + + public function payPalRequestId($payPalRequestId) + { + $this->headers["PayPal-Request-Id"] = $payPalRequestId; + } + public function prefer($prefer) + { + $this->headers["Prefer"] = $prefer; + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php new file mode 100644 index 0000000..cdf1b8a --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php @@ -0,0 +1,25 @@ +path = str_replace("{refund_id}", urlencode($refundId), $this->path); + $this->headers["Content-Type"] = "application/json"; + } + + +} diff --git a/vendor/paypal/paypal-checkout-sdk/phpunit.xml b/vendor/paypal/paypal-checkout-sdk/phpunit.xml new file mode 100644 index 0000000..4e64bcb --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/phpunit.xml @@ -0,0 +1,9 @@ + + + + + + ./tests/ + + + diff --git a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php new file mode 100644 index 0000000..06cc775 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php @@ -0,0 +1,61 @@ +body = self::buildRequestBody(); + + $client = PayPalClient::client(); + $response = $client->execute($request); + if ($debug) + { + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Order ID: {$response->result->id}\n"; + print "Authorization ID: {$response->result->purchase_units[0]->payments->authorizations[0]->id}\n"; + print "Links:\n"; + foreach($response->result->links as $link) + { + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + print "Authorization Links:\n"; + foreach($response->result->purchase_units[0]->payments->authorizations[0]->links as $link) + { + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + // To toggle printing the whole response body comment/uncomment below line + echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; + } + return $response; + } +} + +/** + * This is an driver function which invokes authorize order. + */ +if (!count(debug_backtrace())) +{ + AuthorizeOrder::authorizeOrder('1U242387CB956380X', true); +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php new file mode 100644 index 0000000..9dffd38 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php @@ -0,0 +1,55 @@ +body = self::buildRequestBody(); + $client = PayPalClient::client(); + $response = $client->execute($request); + + if ($debug) + { + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Capture ID: {$response->result->id}\n"; + print "Links:\n"; + foreach($response->result->links as $link) + { + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + // To toggle printing the whole response body comment/uncomment below line + echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; + } + return $response; + } +} + +/** + * Driver function for invoking the capture flow. + */ +if (!count(debug_backtrace())) +{ + CaptureOrder::captureOrder('18A38324BV5456924', true); +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php new file mode 100644 index 0000000..e8f96ce --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php @@ -0,0 +1,237 @@ + 'AUTHORIZE', + 'application_context' => + array( + 'return_url' => 'https://example.com/return', + 'cancel_url' => 'https://example.com/cancel', + 'brand_name' => 'EXAMPLE INC', + 'locale' => 'en-US', + 'landing_page' => 'BILLING', + 'shipping_preference' => 'SET_PROVIDED_ADDRESS', + 'user_action' => 'PAY_NOW', + ), + 'purchase_units' => + array( + 0 => + array( + 'reference_id' => 'PUHF', + 'description' => 'Sporting Goods', + 'custom_id' => 'CUST-HighFashions', + 'soft_descriptor' => 'HighFashions', + 'amount' => + array( + 'currency_code' => 'USD', + 'value' => '220.00', + 'breakdown' => + array( + 'item_total' => + array( + 'currency_code' => 'USD', + 'value' => '180.00', + ), + 'shipping' => + array( + 'currency_code' => 'USD', + 'value' => '20.00', + ), + 'handling' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + 'tax_total' => + array( + 'currency_code' => 'USD', + 'value' => '20.00', + ), + 'shipping_discount' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + ), + ), + 'items' => + array( + 0 => + array( + 'name' => 'T-Shirt', + 'description' => 'Green XL', + 'sku' => 'sku01', + 'unit_amount' => + array( + 'currency_code' => 'USD', + 'value' => '90.00', + ), + 'tax' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + 'quantity' => '1', + 'category' => 'PHYSICAL_GOODS', + ), + 1 => + array( + 'name' => 'Shoes', + 'description' => 'Running, Size 10.5', + 'sku' => 'sku02', + 'unit_amount' => + array( + 'currency_code' => 'USD', + 'value' => '45.00', + ), + 'tax' => + array( + 'currency_code' => 'USD', + 'value' => '5.00', + ), + 'quantity' => '2', + 'category' => 'PHYSICAL_GOODS', + ), + ), + 'shipping' => + array( + 'method' => 'United States Postal Service', + 'name' => + array( + 'full_name' => 'John Doe', + ), + 'address' => + array( + 'address_line_1' => '123 Townsend St', + 'address_line_2' => 'Floor 6', + 'admin_area_2' => 'San Francisco', + 'admin_area_1' => 'CA', + 'postal_code' => '94107', + 'country_code' => 'US', + ), + ), + ), + ), + ); + } + + /** + * Setting up the JSON request body for creating the Order with minimum request body. The Intent in the + * request body should be set as "AUTHORIZE" for authorize intent flow. + * + */ + private static function buildMinimumRequestBody() + { + return array( + 'intent' => 'AUTHORIZE', + 'application_context' => + array( + 'return_url' => 'https://example.com/return', + 'cancel_url' => 'https://example.com/cancel' + ), + 'purchase_units' => + array( + 0 => + array( + 'amount' => + array( + 'currency_code' => 'USD', + 'value' => '220.00' + ) + ) + ) + ); + } + + /** + * This is the sample function which can be used to create an order. It uses the + * JSON body returned by buildRequestBody() to create an new Order. + */ + public static function createOrder($debug=false) + { + $request = new OrdersCreateRequest(); + $request->headers["prefer"] = "return=representation"; + $request->body = CreateOrder::buildRequestBody(); + + $client = PayPalClient::client(); + $response = $client->execute($request); + if ($debug) + { + 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"; + } + + + return $response; + } + + /** + * This is the sample function which can be used to create an order. It uses the + * JSON body returned by buildMinimumRequestBody() to create an new Order. + */ + public static function createOrderWithMinimumBody($debug=false) + { + $request = new OrdersCreateRequest(); + $request->headers["prefer"] = "return=representation"; + $request->body = CreateOrder::buildMinimumRequestBody(); + + $client = PayPalClient::client(); + $response = $client->execute($request); + if ($debug) + { + print "Order With Minimum Body\n"; + 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"; + } + + + return $response; + } +} + + + +if (!count(debug_backtrace())) +{ + CreateOrder::createOrder(true); + CreateOrder::createOrderWithMinimumBody(true); +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php new file mode 100644 index 0000000..708be9d --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php @@ -0,0 +1,82 @@ +statusCode == 201) +{ + $orderId = $order->result->id; + print "Links:\n"; + for ($i = 0; $i < count($order->result->links); ++$i) + { + $link = $order->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + print "Created Successfully\n"; + print "Copy approve link and paste it in browser. Login with buyer account and follow the instructions.\nOnce approved hit enter...\n"; +} +else { + exit(1); +} + +$handle = fopen ("php://stdin","r"); +$line = fgets($handle); +fclose($handle); + +print "Authorizing Order...\n"; +$response = AuthorizeOrder::authorizeOrder($orderId); +$authId = ""; + +if ($response->statusCode == 201) +{ + print "Authorized Successfully\n"; + $authId = $response->result->purchase_units[0]->payments->authorizations[0]->id; +} +else { + exit(1); +} + +print "\nCapturing Order...\n"; +$response = CaptureOrder::captureOrder($authId); +if ($response->statusCode == 201) +{ + print "Captured Successfully\n"; + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + $captureId = $response->result->id; + print "Capture ID: {$captureId}\n"; + print "Links:\n"; + for ($i = 0; $i < count($response->result->links); ++$i){ + $link = $response->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } +} +else { + exit(1); +} + +print "\nRefunding Order...\n"; +$response = RefundOrder::refundOrder($captureId); +if ($response->statusCode == 201) +{ + print "Refunded Successfully\n"; + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Refund ID: {$response->result->id}\n"; + print "Links:\n"; + for ($i = 0; $i < count($response->result->links); ++$i){ + $link = $response->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } +} +else { + exit(1); +} diff --git a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php new file mode 100644 index 0000000..931d5d9 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php @@ -0,0 +1,60 @@ +execute($request); + if ($debug) + { + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Order ID: {$response->result->id}\n"; + print "Links:\n"; + foreach($response->result->links as $link) + { + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + print "Capture Ids:\n"; + foreach($response->result->purchase_units as $purchase_unit) + { + foreach($purchase_unit->payments->captures as $capture) + { + print "\t{$capture->id}"; + } + } + // To toggle printing the whole response body comment/uncomment below line + echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; + } + + return $response; + } +} + +/** + * This is the driver function which invokes the captureOrder function with + * Approved Order Id to capture the order payment. + */ +if (!count(debug_backtrace())) +{ + CaptureOrder::captureOrder('0F105083N67049335', true); +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php new file mode 100644 index 0000000..37a8e63 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php @@ -0,0 +1,178 @@ + 'CAPTURE', + 'application_context' => + array( + 'return_url' => 'https://example.com/return', + 'cancel_url' => 'https://example.com/cancel', + 'brand_name' => 'EXAMPLE INC', + 'locale' => 'en-US', + 'landing_page' => 'BILLING', + 'shipping_preference' => 'SET_PROVIDED_ADDRESS', + 'user_action' => 'PAY_NOW', + ), + 'purchase_units' => + array( + 0 => + array( + 'reference_id' => 'PUHF', + 'description' => 'Sporting Goods', + 'custom_id' => 'CUST-HighFashions', + 'soft_descriptor' => 'HighFashions', + 'amount' => + array( + 'currency_code' => 'USD', + 'value' => '220.00', + 'breakdown' => + array( + 'item_total' => + array( + 'currency_code' => 'USD', + 'value' => '180.00', + ), + 'shipping' => + array( + 'currency_code' => 'USD', + 'value' => '20.00', + ), + 'handling' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + 'tax_total' => + array( + 'currency_code' => 'USD', + 'value' => '20.00', + ), + 'shipping_discount' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + ), + ), + 'items' => + array( + 0 => + array( + 'name' => 'T-Shirt', + 'description' => 'Green XL', + 'sku' => 'sku01', + 'unit_amount' => + array( + 'currency_code' => 'USD', + 'value' => '90.00', + ), + 'tax' => + array( + 'currency_code' => 'USD', + 'value' => '10.00', + ), + 'quantity' => '1', + 'category' => 'PHYSICAL_GOODS', + ), + 1 => + array( + 'name' => 'Shoes', + 'description' => 'Running, Size 10.5', + 'sku' => 'sku02', + 'unit_amount' => + array( + 'currency_code' => 'USD', + 'value' => '45.00', + ), + 'tax' => + array( + 'currency_code' => 'USD', + 'value' => '5.00', + ), + 'quantity' => '2', + 'category' => 'PHYSICAL_GOODS', + ), + ), + 'shipping' => + array( + 'method' => 'United States Postal Service', + 'name' => + array( + 'full_name' => 'John Doe', + ), + 'address' => + array( + 'address_line_1' => '123 Townsend St', + 'address_line_2' => 'Floor 6', + 'admin_area_2' => 'San Francisco', + 'admin_area_1' => 'CA', + 'postal_code' => '94107', + 'country_code' => 'US', + ), + ), + ), + ), + ); + } + + /** + * This is the sample function which can be sued to create an order. It uses the + * JSON body returned by buildRequestBody() to create an new Order. + */ + public static function createOrder($debug=false) + { + $request = new OrdersCreateRequest(); + $request->headers["prefer"] = "return=representation"; + $request->body = self::buildRequestBody(); + + $client = PayPalClient::client(); + $response = $client->execute($request); + if ($debug) + { + 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"; + } + // To toggle printing the whole response body comment/uncomment below line + echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; + } + + + return $response; + } +} + + +/** + * This is the driver function which invokes the createOrder function to create + * an sample order. + */ +if (!count(debug_backtrace())) +{ + CreateOrder::createOrder(true); +} + + + diff --git a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php new file mode 100644 index 0000000..e576ff0 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php @@ -0,0 +1,74 @@ +statusCode == 201) +{ + $orderId = $order->result->id; + print "Links:\n"; + for ($i = 0; $i < count($order->result->links); ++$i) + { + $link = $order->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + print "Created Successfully\n"; + print "Copy approve link and paste it in browser. Login with buyer account and follow the instructions.\nOnce approved hit enter...\n"; +} +else { + exit(1); +} + +$handle = fopen ("php://stdin","r"); +$line = fgets($handle); +fclose($handle); + +print "Capturing Order...\n"; +$response = CaptureOrder::captureOrder($orderId); +if ($response->statusCode == 201) +{ + print "Captured Successfully\n"; + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Order ID: {$response->result->id}\n"; + print "Links:\n"; + for ($i = 0; $i < count($response->result->links); ++$i){ + $link = $response->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + foreach($response->result->purchase_units as $purchase_unit) + { + foreach($purchase_unit->payments->captures as $capture) + { + $captureId = $capture->id; + } + } +} +else { + exit(1); +} + +print "\nRefunding Order...\n"; +$response = RefundOrder::refundOrder($captureId); +if ($response->statusCode == 201) +{ + print "Refunded Successfully\n"; + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Refund ID: {$response->result->id}\n"; + print "Links:\n"; + for ($i = 0; $i < count($response->result->links); ++$i){ + $link = $response->result->links[$i]; + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } +} +else { + exit(1); +} diff --git a/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php b/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php new file mode 100644 index 0000000..8daf96b --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/ErrorSample.php @@ -0,0 +1,94 @@ + $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(); diff --git a/vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php new file mode 100644 index 0000000..f89ac9d --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php @@ -0,0 +1,54 @@ +execute(new OrdersGetRequest($orderId)); + /** + * Enable below line to print complete response as JSON. + */ + //print json_encode($response->result); + 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"; + } +} + +/** + * This is the driver function which invokes the getOrder function to retrieve + * an sample order. + * + * To get the correct Order id, we are using the createOrder to create new order + * and then we are using the newly created order id. + */ +if (!count(debug_backtrace())) +{ + $createdOrder = CreateOrder::createOrder()->result; + GetOrder::getOrder($createdOrder ->id); +} \ No newline at end of file diff --git a/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php new file mode 100644 index 0000000..cba8152 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/PatchOrder.php @@ -0,0 +1,82 @@ + + 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 diff --git a/vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php b/vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php new file mode 100644 index 0000000..397b8d2 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php @@ -0,0 +1,35 @@ +>"; + $clientSecret = getenv("CLIENT_SECRET") ?: "<>"; + return new SandboxEnvironment($clientId, $clientSecret); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php new file mode 100644 index 0000000..fc9428f --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php @@ -0,0 +1,60 @@ + + array( + 'value' => '20.00', + 'currency_code' => 'USD' + ) + ); + } + + /** + * This function can be used to preform refund on the capture. + */ + public static function refundOrder($captureId, $debug=false) + { + $request = new CapturesRefundRequest($captureId); + $request->body = self::buildRequestBody(); + $client = PayPalClient::client(); + $response = $client->execute($request); + + if ($debug) + { + print "Status Code: {$response->statusCode}\n"; + print "Status: {$response->result->status}\n"; + print "Order ID: {$response->result->id}\n"; + print "Links:\n"; + foreach($response->result->links as $link) + { + print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; + } + // To toggle printing the whole response body comment/uncomment below line + echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; + } + return $response; + } +} + +/** + * This is the driver function which invokes the refund capture function with + * Capture Id to perform refund on capture. + */ +if (!count(debug_backtrace())) +{ + RefundOrder::refundOrder('8XL09935J2224701N', true); +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php new file mode 100644 index 0000000..981ce26 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php @@ -0,0 +1,26 @@ +markTestSkipped("Need an approved Order ID to execute this test."); + $request = new OrdersAuthorizeRequest('ORDER-ID'); + $request->body = $this->buildRequestBody(); + + $client = TestHarness::client(); + $response = $client->execute($request); + $this->assertEquals(201, $response->statusCode); + $this->assertNotNull($response->result); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php new file mode 100644 index 0000000..683f70c --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php @@ -0,0 +1,26 @@ +markTestSkipped("Need an approved Order ID to execute this test."); + $request = new OrdersCaptureRequest('ORDER-ID'); + + $client = TestHarness::client(); + $response = $client->execute($request); + $this->assertEquals(201, $response->statusCode); + $this->assertNotNull($response->result); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php new file mode 100644 index 0000000..d2d6dad --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php @@ -0,0 +1,69 @@ + "CAPTURE", + "purchase_units" => [[ + "reference_id" => "test_ref_id1", + "amount" => [ + "value" => "100.00", + "currency_code" => "USD" + ] + ]], + "redirect_urls" => [ + "cancel_url" => "https://example.com/cancel", + "return_url" => "https://example.com/return" + ] + ]; + } + + public static function create($client) { + $request = new OrdersCreateRequest(); + $request->prefer("return=representation"); + $request->body = self::buildRequestBody(); + return $client->execute($request); + } + + public function testOrdersCreateRequest() + { + $client = TestHarness::client(); + $response = self::create($client); + $this->assertEquals(201, $response->statusCode); + $this->assertNotNull($response->result); + + $createdOrder = $response->result; + $this->assertNotNull($createdOrder->id); + $this->assertNotNull($createdOrder->purchase_units); + $this->assertEquals(1, count($createdOrder->purchase_units)); + $firstPurchaseUnit = $createdOrder->purchase_units[0]; + $this->assertEquals("test_ref_id1", $firstPurchaseUnit->reference_id); + $this->assertEquals("USD", $firstPurchaseUnit->amount->currency_code); + $this->assertEquals("100.00", $firstPurchaseUnit->amount->value); + + $this->assertNotNull($createdOrder->create_time); + $this->assertNotNull($createdOrder->links); + $foundApproveUrl = false; + foreach ($createdOrder->links as $link) { + if ("approve" === $link->rel) { + $foundApproveUrl = true; + $this->assertNotNull($link->href); + $this->assertEquals("GET", $link->method); + } + } + $this->assertTrue($foundApproveUrl); + $this->assertEquals("CREATED", $createdOrder->status); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php new file mode 100644 index 0000000..12fb9b0 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php @@ -0,0 +1,48 @@ +result->id); + $response = $client->execute($request); + $this->assertEquals(200, $response->statusCode); + $this->assertNotNull($response->result); + + $createdOrder = $response->result; + $this->assertNotNull($createdOrder->id); + $this->assertNotNull($createdOrder->purchase_units); + $this->assertEquals(1, count($createdOrder->purchase_units)); + $firstPurchaseUnit = $createdOrder->purchase_units[0]; + $this->assertEquals("test_ref_id1", $firstPurchaseUnit->reference_id); + $this->assertEquals("USD", $firstPurchaseUnit->amount->currency_code); + $this->assertEquals("100.00", $firstPurchaseUnit->amount->value); + + $this->assertNotNull($createdOrder->create_time); + $this->assertNotNull($createdOrder->links); + $foundApproveUrl = false; + foreach ($createdOrder->links as $link) { + if ("approve" === $link->rel) { + $foundApproveUrl = true; + $this->assertNotNull($link->href); + $this->assertEquals("GET", $link->method); + } + } + $this->assertTrue($foundApproveUrl); + $this->assertEquals("CREATED", $createdOrder->status); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php new file mode 100644 index 0000000..1eaa307 --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php @@ -0,0 +1,73 @@ + "add", + "path" => "/purchase_units/@reference_id=='test_ref_id1'/description", + "value" => "added_description" + ], + [ + "op" => "replace", + "path" => "/purchase_units/@reference_id=='test_ref_id1'/amount", + "value" => [ + "currency_code" => "USD", + "value" => "200.00" + ] + ] + ]; + } + + public function testOrdersPatchRequest() + { + $client = TestHarness::client(); + $createdOrder = OrdersCreateTest::create($client); + + $request = new OrdersPatchRequest($createdOrder->result->id); + $request->body = $this->buildRequestBody(); + $response = $client->execute($request); + $this->assertEquals(204, $response->statusCode); + + $request = new OrdersGetRequest($createdOrder->result->id); + $response = $client->execute($request); + $this->assertEquals(200, $response->statusCode); + $this->assertNotNull($response->result); + + $createdOrder = $response->result; + $this->assertNotNull($createdOrder->id); + $this->assertNotNull($createdOrder->purchase_units); + $this->assertEquals(1, count($createdOrder->purchase_units)); + $firstPurchaseUnit = $createdOrder->purchase_units[0]; + $this->assertEquals("test_ref_id1", $firstPurchaseUnit->reference_id); + $this->assertEquals("USD", $firstPurchaseUnit->amount->currency_code); + $this->assertEquals("200.00", $firstPurchaseUnit->amount->value); + $this->assertEquals("added_description", $firstPurchaseUnit->description); + + $this->assertNotNull($createdOrder->create_time); + $this->assertNotNull($createdOrder->links); + $foundApproveUrl = false; + foreach ($createdOrder->links as $link) { + if ("approve" === $link->rel) { + $foundApproveUrl = true; + $this->assertNotNull($link->href); + $this->assertEquals("GET", $link->method); + } + } + $this->assertTrue($foundApproveUrl); + $this->assertEquals("CREATED", $createdOrder->status); + } +} diff --git a/vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php b/vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php new file mode 100644 index 0000000..66b4abe --- /dev/null +++ b/vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php @@ -0,0 +1,24 @@ +>"; + $clientSecret = getenv("CLIENT_SECRET") ?: "<>"; + return new SandboxEnvironment($clientId, $clientSecret); + } +} -- cgit v1.2.3