From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- vendor/paypal/paypal-checkout-sdk/.gitignore | 4 +- vendor/paypal/paypal-checkout-sdk/LICENSE | 287 +++++++++---- vendor/paypal/paypal-checkout-sdk/README.md | 344 +++++++-------- vendor/paypal/paypal-checkout-sdk/composer.json | 70 +-- vendor/paypal/paypal-checkout-sdk/gen.yml | 12 +- .../lib/PayPalCheckoutSdk/Core/AccessToken.php | 48 +-- .../PayPalCheckoutSdk/Core/AccessTokenRequest.php | 54 +-- .../Core/AuthorizationInjector.php | 102 ++--- .../Core/FPTIInstrumentationInjector.php | 32 +- .../lib/PayPalCheckoutSdk/Core/GzipInjector.php | 28 +- .../PayPalCheckoutSdk/Core/PayPalEnvironment.php | 46 +- .../PayPalCheckoutSdk/Core/PayPalHttpClient.php | 54 +-- .../Core/ProductionEnvironment.php | 32 +- .../PayPalCheckoutSdk/Core/RefreshTokenRequest.php | 38 +- .../PayPalCheckoutSdk/Core/SandboxEnvironment.php | 32 +- .../lib/PayPalCheckoutSdk/Core/UserAgent.php | 104 ++--- .../lib/PayPalCheckoutSdk/Core/Version.php | 16 +- .../Orders/OrdersAuthorizeRequest.php | 74 ++-- .../Orders/OrdersCaptureRequest.php | 74 ++-- .../Orders/OrdersCreateRequest.php | 62 +-- .../PayPalCheckoutSdk/Orders/OrdersGetRequest.php | 52 +-- .../Orders/OrdersPatchRequest.php | 52 +-- .../Orders/OrdersValidateRequest.php | 58 +-- .../Payments/AuthorizationsCaptureRequest.php | 66 +-- .../Payments/AuthorizationsGetRequest.php | 50 +-- .../Payments/AuthorizationsReauthorizeRequest.php | 66 +-- .../Payments/AuthorizationsVoidRequest.php | 50 +-- .../Payments/CapturesGetRequest.php | 50 +-- .../Payments/CapturesRefundRequest.php | 66 +-- .../Payments/RefundsGetRequest.php | 50 +-- vendor/paypal/paypal-checkout-sdk/phpunit.xml | 18 +- .../AuthorizeIntentExamples/AuthorizeOrder.php | 120 +++--- .../AuthorizeIntentExamples/CaptureOrder.php | 108 ++--- .../AuthorizeIntentExamples/CreateOrder.php | 472 ++++++++++----------- .../samples/AuthorizeIntentExamples/RunAll.php | 164 +++---- .../samples/CaptureIntentExamples/CaptureOrder.php | 118 +++--- .../samples/CaptureIntentExamples/CreateOrder.php | 356 ++++++++-------- .../samples/CaptureIntentExamples/RunAll.php | 148 +++---- .../paypal-checkout-sdk/samples/ErrorSample.php | 188 ++++---- .../paypal-checkout-sdk/samples/GetOrder.php | 106 ++--- .../paypal-checkout-sdk/samples/PatchOrder.php | 162 +++---- .../paypal-checkout-sdk/samples/PayPalClient.php | 70 +-- .../paypal-checkout-sdk/samples/RefundOrder.php | 120 +++--- .../tests/Orders/OrdersAuthorizeTest.php | 52 +-- .../tests/Orders/OrdersCaptureTest.php | 52 +-- .../tests/Orders/OrdersCreateTest.php | 138 +++--- .../tests/Orders/OrdersGetTest.php | 96 ++--- .../tests/Orders/OrdersPatchTest.php | 146 +++---- .../paypal-checkout-sdk/tests/TestHarness.php | 48 +-- vendor/paypal/paypalhttp/.gitattributes | 14 +- vendor/paypal/paypalhttp/.gitignore | 64 +-- vendor/paypal/paypalhttp/.travis.yml | 32 +- vendor/paypal/paypalhttp/CHANGELOG.md | 7 +- vendor/paypal/paypalhttp/CONTRIBUTING.md | 20 +- vendor/paypal/paypalhttp/LICENSE | 46 +- vendor/paypal/paypalhttp/README.md | 152 +++---- vendor/paypal/paypalhttp/Rakefile | 4 +- vendor/paypal/paypalhttp/composer.json | 46 +- vendor/paypal/paypalhttp/lib/PayPalHttp/Curl.php | 114 ++--- .../paypal/paypalhttp/lib/PayPalHttp/Encoder.php | 229 +++++----- .../paypalhttp/lib/PayPalHttp/Environment.php | 36 +- .../paypalhttp/lib/PayPalHttp/HttpClient.php | 469 ++++++++++---------- .../paypalhttp/lib/PayPalHttp/HttpException.php | 51 ++- .../paypalhttp/lib/PayPalHttp/HttpRequest.php | 84 ++-- .../paypalhttp/lib/PayPalHttp/HttpResponse.php | 68 +-- .../paypalhttp/lib/PayPalHttp/IOException.php | 26 +- .../paypal/paypalhttp/lib/PayPalHttp/Injector.php | 38 +- .../paypalhttp/lib/PayPalHttp/Serializer.php | 58 +-- .../paypalhttp/lib/PayPalHttp/Serializer/Form.php | 92 ++-- .../lib/PayPalHttp/Serializer/FormPart.php | 50 +-- .../paypalhttp/lib/PayPalHttp/Serializer/Json.php | 76 ++-- .../lib/PayPalHttp/Serializer/Multipart.php | 268 ++++++------ .../paypalhttp/lib/PayPalHttp/Serializer/Text.php | 76 ++-- vendor/paypal/paypalhttp/phpunit.xml | 20 +- 74 files changed, 3516 insertions(+), 3379 deletions(-) (limited to 'vendor/paypal') diff --git a/vendor/paypal/paypal-checkout-sdk/.gitignore b/vendor/paypal/paypal-checkout-sdk/.gitignore index 4c36e38..45eff58 100644 --- a/vendor/paypal/paypal-checkout-sdk/.gitignore +++ b/vendor/paypal/paypal-checkout-sdk/.gitignore @@ -1,2 +1,2 @@ -.idea/ -vendor/ +.idea/ +vendor/ diff --git a/vendor/paypal/paypal-checkout-sdk/LICENSE b/vendor/paypal/paypal-checkout-sdk/LICENSE index 67d9ac3..3579f23 100644 --- a/vendor/paypal/paypal-checkout-sdk/LICENSE +++ b/vendor/paypal/paypal-checkout-sdk/LICENSE @@ -1,86 +1,201 @@ -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. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) 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. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 PayPal + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/paypal/paypal-checkout-sdk/README.md b/vendor/paypal/paypal-checkout-sdk/README.md index d8aedc0..e52726e 100644 --- a/vendor/paypal/paypal-checkout-sdk/README.md +++ b/vendor/paypal/paypal-checkout-sdk/README.md @@ -1,169 +1,175 @@ -# 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) +# REST API SDK for PHP V2 + +![Home Image](homepage.jpg) + +### To consolidate support across various channels, we have currently turned off the feature of GitHub issues. Please visit https://www.paypal.com/support to submit your request or ask questions within our community forum. + +__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. +## Latest Updates +Beginning January 2020, PayPal will require an update on the Personal Home Page (PHP) Checkout Software Developer Kit (SDK) to version 1.0.1. Merchants who have not updated their PHP Checkout SDK to version 1.0.1 will not be able to deserialize responses using outdated SDK integrations. +All PHP Checkout SDK integrations are expected to be updated by March 1, 2020. Merchants are encouraged to prepare for the update as soon as possible to avoid possible service disruption. +The Status Page has been updated with this information. The bulletin can be found [here](https://www.paypal-status.com/history/eventdetails/11015) + +## 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 contributing or referring 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 while 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 index 0676fb4..b8682d4 100644 --- a/vendor/paypal/paypal-checkout-sdk/composer.json +++ b/vendor/paypal/paypal-checkout-sdk/composer.json @@ -1,35 +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" - } -} +{ + "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.1" + }, + "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/gen.yml b/vendor/paypal/paypal-checkout-sdk/gen.yml index b6f3f79..ac7bd86 100644 --- a/vendor/paypal/paypal-checkout-sdk/gen.yml +++ b/vendor/paypal/paypal-checkout-sdk/gen.yml @@ -1,6 +1,6 @@ ---- -projectName: PayPalCheckoutSdk -language: php -sourcePath: lib/PayPalCheckoutSdk -testPath: tests -apiVersioning: false +--- +projectName: PayPalCheckoutSdk +language: php +sourcePath: lib/PayPalCheckoutSdk +testPath: tests +apiVersioning: false diff --git a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php index b6f1d2d..521429a 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessToken.php @@ -1,25 +1,25 @@ -token = $token; - $this->tokenType = $tokenType; - $this->expiresIn = $expiresIn; - $this->createDate = time(); - } - - public function isExpired() - { - return time() >= $this->createDate + $this->expiresIn; - } +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 index 5c3e26e..9205aae 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AccessTokenRequest.php @@ -1,27 +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"; - } -} - +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 index 0b38bba..5c966aa 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php @@ -1,51 +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); - } -} +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 index 898a750..bad8a35 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/FPTIInstrumentationInjector.php @@ -1,16 +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"; - } -} +headers["sdk_name"] = "Checkout SDK"; + $request->headers["sdk_version"] = "1.0.2"; + $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 index 202b6b1..f1d4339 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/GzipInjector.php @@ -1,14 +1,14 @@ -headers["Accept-Encoding"] = "gzip"; - } -} +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 index 252864b..f9eff1c 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalEnvironment.php @@ -1,23 +1,23 @@ -clientId = $clientId; - $this->clientSecret = $clientSecret; - } - - public function authorizationString() - { - return base64_encode($this->clientId . ":" . $this->clientSecret); - } -} - +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 index 3b3c205..699cc0e 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/PayPalHttpClient.php @@ -1,27 +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(); - } -} - +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 index 20a47b2..e3635fc 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/ProductionEnvironment.php @@ -1,16 +1,16 @@ -headers["Authorization"] = "Basic " . $environment->authorizationString(); - $this->headers["Content-Type"] = "application/x-www-form-urlencoded"; - $this->body = [ - "grant_type" => "authorization_code", - "code" => $authorizationCode - ]; - } -} +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 index 92c1f7a..11fd346 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/SandboxEnvironment.php @@ -1,16 +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; - } -} +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 index 8af8a60..38b32d2 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCaptureRequest.php @@ -1,37 +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; - } -} +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 index 0d9f5a9..0f75e81 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersCreateRequest.php @@ -1,31 +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; - } -} +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 index 3d1c8f1..cce3864 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersGetRequest.php @@ -1,26 +1,26 @@ -path = str_replace("{order_id}", urlencode($orderId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - - -} +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 index 4313c42..5ca5963 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersPatchRequest.php @@ -1,26 +1,26 @@ -path = str_replace("{order_id}", urlencode($orderId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - - -} +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 index 0a68f90..b9b4cf7 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Orders/OrdersValidateRequest.php @@ -1,29 +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; - } -} +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 index 68d5e81..a6f8b5f 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsCaptureRequest.php @@ -1,33 +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; - } -} +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 index e088224..01632ab 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsGetRequest.php @@ -1,25 +1,25 @@ -path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - -} +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 index 7547ece..309b967 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsReauthorizeRequest.php @@ -1,33 +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; - } -} +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 index f5c0f74..df89f3a 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/AuthorizationsVoidRequest.php @@ -1,25 +1,25 @@ -path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - -} +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 index 5b9b335..c1ee75b 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesGetRequest.php @@ -1,25 +1,25 @@ -path = str_replace("{capture_id}", urlencode($captureId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - -} +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 index 7624c6b..f5f1982 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/CapturesRefundRequest.php @@ -1,33 +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; - } -} +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 index cdf1b8a..b5a2aee 100644 --- a/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php +++ b/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Payments/RefundsGetRequest.php @@ -1,25 +1,25 @@ -path = str_replace("{refund_id}", urlencode($refundId), $this->path); - $this->headers["Content-Type"] = "application/json"; - } - - -} +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 index 4e64bcb..7c5978b 100644 --- a/vendor/paypal/paypal-checkout-sdk/phpunit.xml +++ b/vendor/paypal/paypal-checkout-sdk/phpunit.xml @@ -1,9 +1,9 @@ - - - - - - ./tests/ - - - + + + + + + ./tests/ + + + diff --git a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php index 06cc775..a8b68c5 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php @@ -1,61 +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); +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 index 9dffd38..8917dc4 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CaptureOrder.php @@ -1,55 +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); +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 index e8f96ce..99b20e0 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/CreateOrder.php @@ -1,237 +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); + '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 index 708be9d..002f4e2 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/RunAll.php @@ -1,82 +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); -} +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 index 931d5d9..6a0bacb 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CaptureOrder.php @@ -1,60 +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); +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 index 37a8e63..0bb1764 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/CreateOrder.php @@ -1,178 +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); -} - - - + '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 index e576ff0..3c1390a 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/CaptureIntentExamples/RunAll.php @@ -1,74 +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); -} +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 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 @@ - $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(); + $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 index f89ac9d..7fefdbf 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/GetOrder.php @@ -1,54 +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); +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 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 @@ - - 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); + + 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 index 397b8d2..c0bfebf 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/PayPalClient.php @@ -1,35 +1,35 @@ ->"; - $clientSecret = getenv("CLIENT_SECRET") ?: "<>"; - return new SandboxEnvironment($clientId, $clientSecret); - } -} +>"; + $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 index fc9428f..2968189 100644 --- a/vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php +++ b/vendor/paypal/paypal-checkout-sdk/samples/RefundOrder.php @@ -1,60 +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); -} + + 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 index 981ce26..3814853 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersAuthorizeTest.php @@ -1,26 +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); - } -} +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 index 683f70c..3e6f364 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCaptureTest.php @@ -1,26 +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); - } -} +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 index d2d6dad..a53a10f 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersCreateTest.php @@ -1,69 +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); - } -} + "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 index 12fb9b0..dd20521 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersGetTest.php @@ -1,48 +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); - } -} +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 index 1eaa307..1b3e18c 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/Orders/OrdersPatchTest.php @@ -1,73 +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); - } -} + "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 index 66b4abe..32596e1 100644 --- a/vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php +++ b/vendor/paypal/paypal-checkout-sdk/tests/TestHarness.php @@ -1,24 +1,24 @@ ->"; - $clientSecret = getenv("CLIENT_SECRET") ?: "<>"; - return new SandboxEnvironment($clientId, $clientSecret); - } -} +>"; + $clientSecret = getenv("CLIENT_SECRET") ?: "<>"; + return new SandboxEnvironment($clientId, $clientSecret); + } +} diff --git a/vendor/paypal/paypalhttp/.gitattributes b/vendor/paypal/paypalhttp/.gitattributes index ec6c2f5..3daf525 100644 --- a/vendor/paypal/paypalhttp/.gitattributes +++ b/vendor/paypal/paypalhttp/.gitattributes @@ -1,7 +1,7 @@ -tests/ export-ignore -.idea/ export-ignore -.github/ export-ignore -.releasinator.rb export-ignore -Gemfile export-ignore -Gemfile.lock export-ignore - +tests/ export-ignore +.idea/ export-ignore +.github/ export-ignore +.releasinator.rb export-ignore +Gemfile export-ignore +Gemfile.lock export-ignore + diff --git a/vendor/paypal/paypalhttp/.gitignore b/vendor/paypal/paypalhttp/.gitignore index 2efb91f..9adda60 100644 --- a/vendor/paypal/paypalhttp/.gitignore +++ b/vendor/paypal/paypalhttp/.gitignore @@ -1,32 +1,32 @@ -.DS_Store -/vendor/ -composer.phar -composer.lock - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -.idea/codeStyles/Project.xml -.idea/codeStyles/codeStyleConfig.xml -.idea/* - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -## File-based project format: -*.iws -.idea/*.iml -.idea/vcs.xml -.idea/php.xml -.idea/php-test-framework.xml -.idea/modules.xml -__files/* -mappings/* +.DS_Store +/vendor/ +composer.phar +composer.lock + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +.idea/codeStyles/Project.xml +.idea/codeStyles/codeStyleConfig.xml +.idea/* + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +## File-based project format: +*.iws +.idea/*.iml +.idea/vcs.xml +.idea/php.xml +.idea/php-test-framework.xml +.idea/modules.xml +__files/* +mappings/* diff --git a/vendor/paypal/paypalhttp/.travis.yml b/vendor/paypal/paypalhttp/.travis.yml index 4fddbb9..926af50 100644 --- a/vendor/paypal/paypalhttp/.travis.yml +++ b/vendor/paypal/paypalhttp/.travis.yml @@ -1,16 +1,16 @@ -sudo: false -language: php -php: -- 5.6 -- 7.0 -- 7.1 -- hhvm -matrix: - allow_failures: - - php: hhvm - fast_finish: true -before_script: -- composer self-update -- composer install --dev -script: -- vendor/bin/phpunit +sudo: false +language: php +php: +- 5.6 +- 7.0 +- 7.1 +- hhvm +matrix: + allow_failures: + - php: hhvm + fast_finish: true +before_script: +- composer self-update +- composer install --dev +script: +- vendor/bin/phpunit diff --git a/vendor/paypal/paypalhttp/CHANGELOG.md b/vendor/paypal/paypalhttp/CHANGELOG.md index f55b907..e613b6b 100644 --- a/vendor/paypal/paypalhttp/CHANGELOG.md +++ b/vendor/paypal/paypalhttp/CHANGELOG.md @@ -1,2 +1,5 @@ -## 1.0.0 -- First release +## 1.0.1 +* Fix Case Sensitivity of Content Type for deserialization process + +## 1.0.0 +- First release diff --git a/vendor/paypal/paypalhttp/CONTRIBUTING.md b/vendor/paypal/paypalhttp/CONTRIBUTING.md index 3810a58..f551146 100644 --- a/vendor/paypal/paypalhttp/CONTRIBUTING.md +++ b/vendor/paypal/paypalhttp/CONTRIBUTING.md @@ -1,10 +1,10 @@ -# Contribute to the PayPal PHP HttpClient - -### *Pull requests are welcome!* - -General Guidelines ------------------- - -* **Code style.** Please follow local code style. Ask if you're unsure. -* **No warnings.** All generated code must compile without warnings. - +# Contribute to the PayPal PHP HttpClient + +### *Pull requests are welcome!* + +General Guidelines +------------------ + +* **Code style.** Please follow local code style. Ask if you're unsure. +* **No warnings.** All generated code must compile without warnings. + diff --git a/vendor/paypal/paypalhttp/LICENSE b/vendor/paypal/paypalhttp/LICENSE index c689d74..42062c4 100644 --- a/vendor/paypal/paypalhttp/LICENSE +++ b/vendor/paypal/paypalhttp/LICENSE @@ -1,23 +1,23 @@ -Copyright (c) 2009-2016 PayPal, Inc. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - +Copyright (c) 2009-2021 PayPal, Inc. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/paypal/paypalhttp/README.md b/vendor/paypal/paypalhttp/README.md index c4bc958..ff1773b 100644 --- a/vendor/paypal/paypalhttp/README.md +++ b/vendor/paypal/paypalhttp/README.md @@ -1,76 +1,76 @@ -## PayPal HttpClient - -PayPalHttp is a generic HTTP Client. - -In it's simplest form, an [`HttpClient`](lib/PayPalHttp/HttpClient.php) exposes an `execute` method which takes an [HTTP request](lib/PayPalHttp/HttpRequest.php), executes it against the domain described in an [Environment](lib/PayPalHttp/Environment.php), and returns an [HTTP response](lib/PayPalHttp/HttpResponse.php). - -### Environment - -An [`Environment`](./lib/PayPalHttp/environment.rb) describes a domain that hosts a REST API, against which an `HttpClient` will make requests. `Environment` is a simple interface that wraps one method, `baseUrl`. - -```php -$env = new Environment('https://example.com'); -``` - -### Requests - -HTTP requests contain all the information needed to make an HTTP request against the REST API. Specifically, one request describes a path, a verb, any path/query/form parameters, headers, attached files for upload, and body data. - -### Responses - -HTTP responses contain information returned by a server in response to a request as described above. They are simple objects which contain a status code, headers, and any data returned by the server. - -```php -$request = new HttpRequest("/path", "GET"); -$request->body[] = "some data"; - -$response = $client->execute($req); - -$statusCode = $response->statusCode; -$headers = $response->headers; -$data = $response->result; -``` - -### Injectors - -Injectors are blocks that can be used for executing arbitrary pre-flight logic, such as modifying a request or logging data. Injectors are attached to an `HttpClient` using the `addInjector` method. - -The `HttpClient` executes its injectors in a first-in, first-out order, before each request. - -```php -class LogInjector implements Injector -{ - public function inject($httpRequest) - { - // Do some logging here - } -} - -$logInjector = new LogInjector(); -$client = new HttpClient($environment); -$client->addInjector($logInjector); -... -``` - -### Error Handling - -`HttpClient#execute` may throw an `Exception` if something went wrong during the course of execution. If the server returned a non-200 response, [IOException](lib/PayPalHttp/IOException.php) will be thrown, that will contain a status code and headers you can use for debugging. - -```php -try -{ - $client->execute($req); -} -catch (HttpException $e) -{ - $statusCode = $e->response->statusCode; - $headers = $e->response->headers; - $body = $e->response->result; -} -``` - -## License -PayPalHttp-PHP is open source and available under the MIT license. See the [LICENSE](./LICENSE) file for more information. - -## Contributing -Pull requests and issues are welcome. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more details. +## PayPal HttpClient + +PayPalHttp is a generic HTTP Client. + +In it's simplest form, an [`HttpClient`](lib/PayPalHttp/HttpClient.php) exposes an `execute` method which takes an [HTTP request](lib/PayPalHttp/HttpRequest.php), executes it against the domain described in an [Environment](lib/PayPalHttp/Environment.php), and returns an [HTTP response](lib/PayPalHttp/HttpResponse.php). + +### Environment + +An [`Environment`](./lib/PayPalHttp/environment.rb) describes a domain that hosts a REST API, against which an `HttpClient` will make requests. `Environment` is a simple interface that wraps one method, `baseUrl`. + +```php +$env = new Environment('https://example.com'); +``` + +### Requests + +HTTP requests contain all the information needed to make an HTTP request against the REST API. Specifically, one request describes a path, a verb, any path/query/form parameters, headers, attached files for upload, and body data. + +### Responses + +HTTP responses contain information returned by a server in response to a request as described above. They are simple objects which contain a status code, headers, and any data returned by the server. + +```php +$request = new HttpRequest("/path", "GET"); +$request->body[] = "some data"; + +$response = $client->execute($req); + +$statusCode = $response->statusCode; +$headers = $response->headers; +$data = $response->result; +``` + +### Injectors + +Injectors are blocks that can be used for executing arbitrary pre-flight logic, such as modifying a request or logging data. Injectors are attached to an `HttpClient` using the `addInjector` method. + +The `HttpClient` executes its injectors in a first-in, first-out order, before each request. + +```php +class LogInjector implements Injector +{ + public function inject($httpRequest) + { + // Do some logging here + } +} + +$logInjector = new LogInjector(); +$client = new HttpClient($environment); +$client->addInjector($logInjector); +... +``` + +### Error Handling + +`HttpClient#execute` may throw an `Exception` if something went wrong during the course of execution. If the server returned a non-200 response, [IOException](lib/PayPalHttp/IOException.php) will be thrown, that will contain a status code and headers you can use for debugging. + +```php +try +{ + $client->execute($req); +} +catch (HttpException $e) +{ + $statusCode = $e->response->statusCode; + $headers = $e->response->headers; + $body = $e->response->result; +} +``` + +## License +PayPalHttp-PHP is open source and available under the MIT license. See the [LICENSE](./LICENSE) file for more information. + +## Contributing +Pull requests and issues are welcome. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more details. diff --git a/vendor/paypal/paypalhttp/Rakefile b/vendor/paypal/paypalhttp/Rakefile index 33a443c..30824c7 100644 --- a/vendor/paypal/paypalhttp/Rakefile +++ b/vendor/paypal/paypalhttp/Rakefile @@ -1,2 +1,2 @@ -spec = Gem::Specification.find_by_name 'releasinator' -load "#{spec.gem_dir}/lib/tasks/releasinator.rake" +spec = Gem::Specification.find_by_name 'releasinator' +load "#{spec.gem_dir}/lib/tasks/releasinator.rake" diff --git a/vendor/paypal/paypalhttp/composer.json b/vendor/paypal/paypalhttp/composer.json index 05728a3..dc1d85d 100644 --- a/vendor/paypal/paypalhttp/composer.json +++ b/vendor/paypal/paypalhttp/composer.json @@ -1,23 +1,23 @@ -{ - "name": "paypal/paypalhttp", - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "PayPal", - "homepage": "https://github.com/paypal/paypalhttp_php/contributors" - } - ], - "require": { - "ext-curl": "*" - }, - "require-dev": { - "phpunit/phpunit": "^5.7", - "wiremock-php/wiremock-php": "1.43.2" - }, - "autoload": { - "psr-4": { - "PayPalHttp\\": "lib/PayPalHttp" - } - } -} +{ + "name": "paypal/paypalhttp", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "PayPal", + "homepage": "https://github.com/paypal/paypalhttp_php/contributors" + } + ], + "require": { + "ext-curl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "wiremock-php/wiremock-php": "1.43.2" + }, + "autoload": { + "psr-4": { + "PayPalHttp\\": "lib/PayPalHttp" + } + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Curl.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Curl.php index 08e6eaf..9d5ce8f 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Curl.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Curl.php @@ -1,57 +1,57 @@ -curl = $curl; - } - - public function setOpt($option, $value) - { - curl_setopt($this->curl, $option, $value); - return $this; - } - - public function close() - { - curl_close($this->curl); - return $this; - } - - public function exec() - { - return curl_exec($this->curl); - } - - public function errNo() - { - return curl_errno($this->curl); - } - - public function getInfo($option) - { - return curl_getinfo($this->curl, $option); - } - - public function error() - { - return curl_error($this->curl); - } -} +curl = $curl; + } + + public function setOpt($option, $value) + { + curl_setopt($this->curl, $option, $value); + return $this; + } + + public function close() + { + curl_close($this->curl); + return $this; + } + + public function exec() + { + return curl_exec($this->curl); + } + + public function errNo() + { + return curl_errno($this->curl); + } + + public function getInfo($option) + { + return curl_getinfo($this->curl, $option); + } + + public function error() + { + return curl_error($this->curl); + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Encoder.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Encoder.php index b7158a7..06ce88a 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Encoder.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Encoder.php @@ -1,114 +1,115 @@ -serializers[] = new Json(); - $this->serializers[] = new Text(); - $this->serializers[] = new Multipart(); - $this->serializers[] = new Form(); - } - - - - public function serializeRequest(HttpRequest $request) - { - if (!array_key_exists('content-type', $request->headers)) { - $message = "HttpRequest does not have Content-Type header set"; - echo $message; - throw new \Exception($message); - } - - $contentType = $request->headers['content-type']; - /** @var Serializer $serializer */ - $serializer = $this->serializer($contentType); - - if (is_null($serializer)) { - $message = sprintf("Unable to serialize request with Content-Type: %s. Supported encodings are: %s", $contentType, implode(", ", $this->supportedEncodings())); - echo $message; - throw new \Exception($message); - } - - if (!(is_string($request->body) || is_array($request->body))) { - $message = "Body must be either string or array"; - echo $message; - throw new \Exception($message); - } - - $serialized = $serializer->encode($request); - - if (array_key_exists("content-encoding", $request->headers) && $request->headers["content-encoding"] === "gzip") { - $serialized = gzencode($serialized); - } - return $serialized; - } - - - public function deserializeResponse($responseBody, $headers) - { - - if (!array_key_exists('content-type', $headers)) { - $message = "HTTP response does not have Content-Type header set"; - echo $message; - throw new \Exception($message); - } - - $contentType = $headers['content-type']; - /** @var Serializer $serializer */ - $serializer = $this->serializer($contentType); - - if (is_null($serializer)) { - throw new \Exception(sprintf("Unable to deserialize response with Content-Type: %s. Supported encodings are: %s", $contentType, implode(", ", $this->supportedEncodings()))); - } - - if (array_key_exists("content-encoding", $headers) && $headers["content-encoding"] === "gzip") { - $responseBody = gzdecode($responseBody); - } - - return $serializer->decode($responseBody); - } - - private function serializer($contentType) - { - /** @var Serializer $serializer */ - foreach ($this->serializers as $serializer) { - try { - if (preg_match($serializer->contentType(), $contentType) == 1) { - return $serializer; - } - } catch (\Exception $ex) { - $message = sprintf("Error while checking content type of %s: %s", get_class($serializer), $ex->getMessage()); - echo $message; - throw new \Exception($message, $ex->getCode(), $ex); - } - } - - return NULL; - } - - private function supportedEncodings() - { - $values = []; - /** @var Serializer $serializer */ - foreach ($this->serializers as $serializer) { - $values[] = $serializer->contentType(); - } - return $values; - } -} +serializers[] = new Json(); + $this->serializers[] = new Text(); + $this->serializers[] = new Multipart(); + $this->serializers[] = new Form(); + } + + + + public function serializeRequest(HttpRequest $request) + { + if (!array_key_exists('content-type', $request->headers)) { + $message = "HttpRequest does not have Content-Type header set"; + echo $message; + throw new \Exception($message); + } + + $contentType = $request->headers['content-type']; + /** @var Serializer $serializer */ + $serializer = $this->serializer($contentType); + + if (is_null($serializer)) { + $message = sprintf("Unable to serialize request with Content-Type: %s. Supported encodings are: %s", $contentType, implode(", ", $this->supportedEncodings())); + echo $message; + throw new \Exception($message); + } + + if (!(is_string($request->body) || is_array($request->body))) { + $message = "Body must be either string or array"; + echo $message; + throw new \Exception($message); + } + + $serialized = $serializer->encode($request); + + if (array_key_exists("content-encoding", $request->headers) && $request->headers["content-encoding"] === "gzip") { + $serialized = gzencode($serialized); + } + return $serialized; + } + + + public function deserializeResponse($responseBody, $headers) + { + + if (!array_key_exists('content-type', $headers)) { + $message = "HTTP response does not have Content-Type header set"; + echo $message; + throw new \Exception($message); + } + + $contentType = $headers['content-type']; + $contentType = strtolower($contentType); + /** @var Serializer $serializer */ + $serializer = $this->serializer($contentType); + + if (is_null($serializer)) { + throw new \Exception(sprintf("Unable to deserialize response with Content-Type: %s. Supported encodings are: %s", $contentType, implode(", ", $this->supportedEncodings()))); + } + + if (array_key_exists("content-encoding", $headers) && $headers["content-encoding"] === "gzip") { + $responseBody = gzdecode($responseBody); + } + + return $serializer->decode($responseBody); + } + + private function serializer($contentType) + { + /** @var Serializer $serializer */ + foreach ($this->serializers as $serializer) { + try { + if (preg_match($serializer->contentType(), $contentType) == 1) { + return $serializer; + } + } catch (\Exception $ex) { + $message = sprintf("Error while checking content type of %s: %s", get_class($serializer), $ex->getMessage()); + echo $message; + throw new \Exception($message, $ex->getCode(), $ex); + } + } + + return NULL; + } + + private function supportedEncodings() + { + $values = []; + /** @var Serializer $serializer */ + foreach ($this->serializers as $serializer) { + $values[] = $serializer->contentType(); + } + return $values; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Environment.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Environment.php index 4eb0ce0..0910a44 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Environment.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Environment.php @@ -1,18 +1,18 @@ -environment = $environment; - $this->encoder = new Encoder(); - $this->curlCls = Curl::class; - } - - /** - * Injectors are blocks that can be used for executing arbitrary pre-flight logic, such as modifying a request or logging data. - * Executed in first-in first-out order. - * - * @param Injector $inj - */ - public function addInjector(Injector $inj) - { - $this->injectors[] = $inj; - } - - /** - * The method that takes an HTTP request, serializes the request, makes a call to given environment, and deserialize response - * - * @param $httpRequest HttpRequest - * @return HttpResponse - */ - public function execute(HttpRequest $httpRequest) - { - $requestCpy = clone $httpRequest; - $curl = new Curl(); - - foreach ($this->injectors as $inj) { - $inj->inject($requestCpy); - } - - $url = $this->environment->baseUrl() . $requestCpy->path; - $formattedHeaders = $this->prepareHeaders($requestCpy->headers); - if (!array_key_exists("user-agent", $formattedHeaders)) { - $requestCpy->headers["user-agent"] = $this->userAgent(); - } - - $body = ""; - if (!is_null($requestCpy->body)) { - $rawHeaders = $requestCpy->headers; - $requestCpy->headers = $formattedHeaders; - $body = $this->encoder->serializeRequest($requestCpy); - $requestCpy->headers = $this->mapHeaders($rawHeaders,$requestCpy->headers); - } - - $curl->setOpt(CURLOPT_URL, $url); - $curl->setOpt(CURLOPT_CUSTOMREQUEST, $requestCpy->verb); - $curl->setOpt(CURLOPT_HTTPHEADER, $this->serializeHeaders($requestCpy->headers)); - $curl->setOpt(CURLOPT_RETURNTRANSFER, 1); - $curl->setOpt(CURLOPT_HEADER, 0); - - if (!is_null($requestCpy->body)) { - $curl->setOpt(CURLOPT_POSTFIELDS, $body); - } - - if (strpos($this->environment->baseUrl(), "https://") === 0) { - $curl->setOpt(CURLOPT_SSL_VERIFYPEER, true); - $curl->setOpt(CURLOPT_SSL_VERIFYHOST, 2); - } - - if ($caCertPath = $this->getCACertFilePath()) { - $curl->setOpt(CURLOPT_CAINFO, $caCertPath); - } - - $response = $this->parseResponse($curl); - $curl->close(); - - return $response; - } - - /** - * Returns an array representing headers with their keys - * to be lower case - * @param $headers - * @return array - */ - public function prepareHeaders($headers){ - return array_change_key_case($headers); - } - - /** - * Returns an array representing headers with their key in - * original cases and updated values - * @param $rawHeaders - * @param $formattedHeaders - * @return array - */ - public function mapHeaders($rawHeaders, $formattedHeaders){ - $rawHeadersKey = array_keys($rawHeaders); - foreach ($rawHeadersKey as $array_key) { - if(array_key_exists(strtolower($array_key), $formattedHeaders)){ - $rawHeaders[$array_key] = $formattedHeaders[strtolower($array_key)]; - } - } - return $rawHeaders; - } - - /** - * Returns default user-agent - * - * @return string - */ - public function userAgent() - { - return "PayPalHttp-PHP HTTP/1.1"; - } - - /** - * Return the filepath to your custom CA Cert if needed. - * @return string - */ - protected function getCACertFilePath() - { - return null; - } - - protected function setCurl(Curl $curl) - { - $this->curl = $curl; - } - - protected function setEncoder(Encoder $encoder) - { - $this->encoder = $encoder; - } - - private function serializeHeaders($headers) - { - $headerArray = []; - if ($headers) { - foreach ($headers as $key => $val) { - $headerArray[] = $key . ": " . $val; - } - } - - return $headerArray; - } - - private function parseResponse($curl) - { - $headers = []; - $curl->setOpt(CURLOPT_HEADERFUNCTION, - function($curl, $header) use (&$headers) - { - $len = strlen($header); - - $k = ""; - $v = ""; - - $this->deserializeHeader($header, $k, $v); - $headers[$k] = $v; - - return $len; - }); - - $responseData = $curl->exec(); - $statusCode = $curl->getInfo(CURLINFO_HTTP_CODE); - $errorCode = $curl->errNo(); - $error = $curl->error(); - - if ($errorCode > 0) { - throw new IOException($error, $errorCode); - } - - $body = $responseData; - - if ($statusCode >= 200 && $statusCode < 300) { - $responseBody = NULL; - - if (!empty($body)) { - $responseBody = $this->encoder->deserializeResponse($body, $this->prepareHeaders($headers)); - } - - return new HttpResponse( - $errorCode === 0 ? $statusCode : $errorCode, - $responseBody, - $headers - ); - } else { - throw new HttpException($body, $statusCode, $headers); - } - } - - private function deserializeHeader($header, &$key, &$value) - { - if (strlen($header) > 0) { - if (empty($header) || strpos($header, ':') === false) { - return NULL; - } - - list($k, $v) = explode(":", $header); - $key = trim($k); - $value = trim($v); - } - } -} +environment = $environment; + $this->encoder = new Encoder(); + $this->curlCls = Curl::class; + } + + /** + * Injectors are blocks that can be used for executing arbitrary pre-flight logic, such as modifying a request or logging data. + * Executed in first-in first-out order. + * + * @param Injector $inj + */ + public function addInjector(Injector $inj) + { + $this->injectors[] = $inj; + } + + /** + * The method that takes an HTTP request, serializes the request, makes a call to given environment, and deserialize response + * + * @param HttpRequest $httpRequest + * @return HttpResponse + * + * @throws HttpException + * @throws IOException + */ + public function execute(HttpRequest $httpRequest) + { + $requestCpy = clone $httpRequest; + $curl = new Curl(); + + foreach ($this->injectors as $inj) { + $inj->inject($requestCpy); + } + + $url = $this->environment->baseUrl() . $requestCpy->path; + $formattedHeaders = $this->prepareHeaders($requestCpy->headers); + if (!array_key_exists("user-agent", $formattedHeaders)) { + $requestCpy->headers["user-agent"] = $this->userAgent(); + } + + $body = ""; + if (!is_null($requestCpy->body)) { + $rawHeaders = $requestCpy->headers; + $requestCpy->headers = $formattedHeaders; + $body = $this->encoder->serializeRequest($requestCpy); + $requestCpy->headers = $this->mapHeaders($rawHeaders,$requestCpy->headers); + } + + $curl->setOpt(CURLOPT_URL, $url); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, $requestCpy->verb); + $curl->setOpt(CURLOPT_HTTPHEADER, $this->serializeHeaders($requestCpy->headers)); + $curl->setOpt(CURLOPT_RETURNTRANSFER, 1); + $curl->setOpt(CURLOPT_HEADER, 0); + + if (!is_null($requestCpy->body)) { + $curl->setOpt(CURLOPT_POSTFIELDS, $body); + } + + if (strpos($this->environment->baseUrl(), "https://") === 0) { + $curl->setOpt(CURLOPT_SSL_VERIFYPEER, true); + $curl->setOpt(CURLOPT_SSL_VERIFYHOST, 2); + } + + if ($caCertPath = $this->getCACertFilePath()) { + $curl->setOpt(CURLOPT_CAINFO, $caCertPath); + } + + $response = $this->parseResponse($curl); + $curl->close(); + + return $response; + } + + /** + * Returns an array representing headers with their keys + * to be lower case + * @param $headers + * @return array + */ + public function prepareHeaders($headers){ + $preparedHeaders = array_change_key_case($headers); + if (array_key_exists("content-type", $preparedHeaders)) { + $preparedHeaders["content-type"] = strtolower($preparedHeaders["content-type"]); + } + return $preparedHeaders; + } + + /** + * Returns an array representing headers with their key in + * original cases and updated values + * @param $rawHeaders + * @param $formattedHeaders + * @return array + */ + public function mapHeaders($rawHeaders, $formattedHeaders){ + $rawHeadersKey = array_keys($rawHeaders); + foreach ($rawHeadersKey as $array_key) { + if(array_key_exists(strtolower($array_key), $formattedHeaders)){ + $rawHeaders[$array_key] = $formattedHeaders[strtolower($array_key)]; + } + } + return $rawHeaders; + } + + /** + * Returns default user-agent + * + * @return string + */ + public function userAgent() + { + return "PayPalHttp-PHP HTTP/1.1"; + } + + /** + * Return the filepath to your custom CA Cert if needed. + * @return string + */ + protected function getCACertFilePath() + { + return null; + } + + protected function setCurl(Curl $curl) + { + $this->curl = $curl; + } + + protected function setEncoder(Encoder $encoder) + { + $this->encoder = $encoder; + } + + private function serializeHeaders($headers) + { + $headerArray = []; + if ($headers) { + foreach ($headers as $key => $val) { + $headerArray[] = $key . ": " . $val; + } + } + + return $headerArray; + } + + private function parseResponse($curl) + { + $headers = []; + $curl->setOpt(CURLOPT_HEADERFUNCTION, + function($curl, $header) use (&$headers) + { + $len = strlen($header); + + $k = ""; + $v = ""; + + $this->deserializeHeader($header, $k, $v); + $headers[$k] = $v; + + return $len; + }); + + $responseData = $curl->exec(); + $statusCode = $curl->getInfo(CURLINFO_HTTP_CODE); + $errorCode = $curl->errNo(); + $error = $curl->error(); + + if ($errorCode > 0) { + throw new IOException($error, $errorCode); + } + + $body = $responseData; + + if ($statusCode >= 200 && $statusCode < 300) { + $responseBody = NULL; + + if (!empty($body)) { + $responseBody = $this->encoder->deserializeResponse($body, $this->prepareHeaders($headers)); + } + + return new HttpResponse( + $errorCode === 0 ? $statusCode : $errorCode, + $responseBody, + $headers + ); + } else { + throw new HttpException($body, $statusCode, $headers); + } + } + + private function deserializeHeader($header, &$key, &$value) + { + if (strlen($header) > 0) { + if (empty($header) || strpos($header, ':') === false) { + return NULL; + } + + list($k, $v) = explode(":", $header); + $key = trim($k); + $value = trim($v); + } + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpException.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpException.php index 5f4d2db..3551786 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpException.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpException.php @@ -1,23 +1,28 @@ -statusCode = $statusCode; - $this->headers = $headers; - } -} +statusCode = $statusCode; + $this->headers = $headers; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpRequest.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpRequest.php index 89b7480..656994a 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpRequest.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpRequest.php @@ -1,42 +1,42 @@ -path = $path; - $this->verb = $verb; - $this->body = NULL; - $this->headers = []; - } -} +path = $path; + $this->verb = $verb; + $this->body = NULL; + $this->headers = []; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpResponse.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpResponse.php index ef8fb35..7d46dd2 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpResponse.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpResponse.php @@ -1,34 +1,34 @@ -statusCode = $statusCode; - $this->headers = $headers; - $this->result = $body; - } -} +statusCode = $statusCode; + $this->headers = $headers; + $this->result = $body; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/IOException.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/IOException.php index 7bfc91c..401b438 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/IOException.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/IOException.php @@ -1,13 +1,13 @@ -body) || !$this->isAssociative($request->body)) - { - throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["Content-Type"]); - } - - return http_build_query($request->body); - } - - /** - * @param $body - * @return mixed - * @throws \Exception as multipart does not support deserialization. - */ - public function decode($body) - { - throw new \Exception("CurlSupported does not support deserialization"); - } - - private function isAssociative(array $array) - { - return array_values($array) !== $array; - } -} +body) || !$this->isAssociative($request->body)) + { + throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["Content-Type"]); + } + + return http_build_query($request->body); + } + + /** + * @param $body + * @return mixed + * @throws \Exception as multipart does not support deserialization. + */ + public function decode($body) + { + throw new \Exception("CurlSupported does not support deserialization"); + } + + private function isAssociative(array $array) + { + return array_values($array) !== $array; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php index 3779a9b..5c40026 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/FormPart.php @@ -1,25 +1,25 @@ -value = $value; - $this->headers = array_merge([], $headers); - } - - public function getValue() - { - return $this->value; - } - - public function getHeaders() - { - return $this->headers; - } -} +value = $value; + $this->headers = array_merge([], $headers); + } + + public function getValue() + { + return $this->value; + } + + public function getHeaders() + { + return $this->headers; + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php index 3f66314..a73897c 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Json.php @@ -1,38 +1,38 @@ -body; - if (is_string($body)) { - return $body; - } - if (is_array($body)) { - return json_encode($body); - } - throw new \Exception("Cannot serialize data. Unknown type"); - } - - public function decode($data) - { - return json_decode($data); - } -} +body; + if (is_string($body)) { + return $body; + } + if (is_array($body)) { + return json_encode($body); + } + throw new \Exception("Cannot serialize data. Unknown type"); + } + + public function decode($data) + { + return json_decode($data); + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php index a420205..b9142de 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Multipart.php @@ -1,134 +1,134 @@ -body) || !$this->isAssociative($request->body)) - { - throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["content-type"]); - } - $boundary = "---------------------" . md5(mt_rand() . microtime()); - $contentTypeHeader = $request->headers["content-type"]; - $request->headers["content-type"] = "{$contentTypeHeader}; boundary={$boundary}"; - - $value_params = []; - $file_params = []; - - $disallow = ["\0", "\"", "\r", "\n"]; - - $body = []; - - foreach ($request->body as $k => $v) { - $k = str_replace($disallow, "_", $k); - if (is_resource($v)) { - $file_params[] = $this->prepareFilePart($k, $v, $boundary); - } else if ($v instanceof FormPart) { - $value_params[] = $this->prepareFormPart($k, $v, $boundary); - } else { - $value_params[] = $this->prepareFormField($k, $v, $boundary); - } - } - - $body = array_merge($value_params, $file_params); - - // add boundary for each parameters - array_walk($body, function (&$part) use ($boundary) { - $part = "--{$boundary}" . self::LINEFEED . "{$part}"; - }); - - // add final boundary - $body[] = "--{$boundary}--"; - $body[] = ""; - - return implode(self::LINEFEED, $body); - } - - public function decode($data) - { - throw new \Exception("Multipart does not support deserialization"); - } - - private function isAssociative(array $array) - { - return array_values($array) !== $array; - } - - private function prepareFormField($partName, $value, $boundary) - { - return implode(self::LINEFEED, [ - "Content-Disposition: form-data; name=\"{$partName}\"", - "", - filter_var($value), - ]); - } - - private function prepareFilePart($partName, $file, $boundary) - { - $fileInfo = new finfo(FILEINFO_MIME_TYPE); - $filePath = stream_get_meta_data($file)['uri']; - $data = file_get_contents($filePath); - $mimeType = $fileInfo->buffer($data); - - $splitFilePath = explode(DIRECTORY_SEPARATOR, $filePath); - $filePath = end($splitFilePath); - $disallow = ["\0", "\"", "\r", "\n"]; - $filePath = str_replace($disallow, "_", $filePath); - return implode(self::LINEFEED, [ - "Content-Disposition: form-data; name=\"{$partName}\"; filename=\"{$filePath}\"", - "Content-Type: {$mimeType}", - "", - $data, - ]); - } - - private function prepareFormPart($partName, $formPart, $boundary) - { - $contentDisposition = "Content-Disposition: form-data; name=\"{$partName}\""; - - $partHeaders = $formPart->getHeaders(); - $formattedheaders = array_change_key_case($partHeaders); - if (array_key_exists("content-type", $formattedheaders)) { - if ($formattedheaders["content-type"] === "application/json") { - $contentDisposition .= "; filename=\"{$partName}.json\""; - } - $tempRequest = new HttpRequest('/', 'POST'); - $tempRequest->headers = $formattedheaders; - $tempRequest->body = $formPart->getValue(); - $encoder = new Encoder(); - $partValue = $encoder->serializeRequest($tempRequest); - } else { - $partValue = $formPart->getValue(); - } - - $finalPartHeaders = []; - foreach ($partHeaders as $k => $v) { - $finalPartHeaders[] = "{$k}: {$v}"; - } - - $body = array_merge([$contentDisposition], $finalPartHeaders, [""], [$partValue]); - - return implode(self::LINEFEED, $body); - } -} +body) || !$this->isAssociative($request->body)) + { + throw new \Exception("HttpRequest body must be an associative array when Content-Type is: " . $request->headers["content-type"]); + } + $boundary = "---------------------" . md5(mt_rand() . microtime()); + $contentTypeHeader = $request->headers["content-type"]; + $request->headers["content-type"] = "{$contentTypeHeader}; boundary={$boundary}"; + + $value_params = []; + $file_params = []; + + $disallow = ["\0", "\"", "\r", "\n"]; + + $body = []; + + foreach ($request->body as $k => $v) { + $k = str_replace($disallow, "_", $k); + if (is_resource($v)) { + $file_params[] = $this->prepareFilePart($k, $v, $boundary); + } else if ($v instanceof FormPart) { + $value_params[] = $this->prepareFormPart($k, $v, $boundary); + } else { + $value_params[] = $this->prepareFormField($k, $v, $boundary); + } + } + + $body = array_merge($value_params, $file_params); + + // add boundary for each parameters + array_walk($body, function (&$part) use ($boundary) { + $part = "--{$boundary}" . self::LINEFEED . "{$part}"; + }); + + // add final boundary + $body[] = "--{$boundary}--"; + $body[] = ""; + + return implode(self::LINEFEED, $body); + } + + public function decode($data) + { + throw new \Exception("Multipart does not support deserialization"); + } + + private function isAssociative(array $array) + { + return array_values($array) !== $array; + } + + private function prepareFormField($partName, $value, $boundary) + { + return implode(self::LINEFEED, [ + "Content-Disposition: form-data; name=\"{$partName}\"", + "", + filter_var($value), + ]); + } + + private function prepareFilePart($partName, $file, $boundary) + { + $fileInfo = new finfo(FILEINFO_MIME_TYPE); + $filePath = stream_get_meta_data($file)['uri']; + $data = file_get_contents($filePath); + $mimeType = $fileInfo->buffer($data); + + $splitFilePath = explode(DIRECTORY_SEPARATOR, $filePath); + $filePath = end($splitFilePath); + $disallow = ["\0", "\"", "\r", "\n"]; + $filePath = str_replace($disallow, "_", $filePath); + return implode(self::LINEFEED, [ + "Content-Disposition: form-data; name=\"{$partName}\"; filename=\"{$filePath}\"", + "Content-Type: {$mimeType}", + "", + $data, + ]); + } + + private function prepareFormPart($partName, $formPart, $boundary) + { + $contentDisposition = "Content-Disposition: form-data; name=\"{$partName}\""; + + $partHeaders = $formPart->getHeaders(); + $formattedheaders = array_change_key_case($partHeaders); + if (array_key_exists("content-type", $formattedheaders)) { + if ($formattedheaders["content-type"] === "application/json") { + $contentDisposition .= "; filename=\"{$partName}.json\""; + } + $tempRequest = new HttpRequest('/', 'POST'); + $tempRequest->headers = $formattedheaders; + $tempRequest->body = $formPart->getValue(); + $encoder = new Encoder(); + $partValue = $encoder->serializeRequest($tempRequest); + } else { + $partValue = $formPart->getValue(); + } + + $finalPartHeaders = []; + foreach ($partHeaders as $k => $v) { + $finalPartHeaders[] = "{$k}: {$v}"; + } + + $body = array_merge([$contentDisposition], $finalPartHeaders, [""], [$partValue]); + + return implode(self::LINEFEED, $body); + } +} diff --git a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php index e2ce0ca..d6fa3cd 100644 --- a/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php +++ b/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Text.php @@ -1,38 +1,38 @@ -body; - if (is_string($body)) { - return $body; - } - if (is_array($body)) { - return json_encode($body); - } - return implode(" ", $body); - } - - public function decode($data) - { - return $data; - } -} +body; + if (is_string($body)) { + return $body; + } + if (is_array($body)) { + return json_encode($body); + } + return implode(" ", $body); + } + + public function decode($data) + { + return $data; + } +} diff --git a/vendor/paypal/paypalhttp/phpunit.xml b/vendor/paypal/paypalhttp/phpunit.xml index ea84278..649fcd9 100644 --- a/vendor/paypal/paypalhttp/phpunit.xml +++ b/vendor/paypal/paypalhttp/phpunit.xml @@ -1,10 +1,10 @@ - - - - - - ./tests/unit - - - - + + + + + + ./tests/unit + + + + -- cgit v1.2.3