Subiendo proyecto completo sin restricciones de git ignore

This commit is contained in:
Jose Sanchez
2023-08-17 11:44:02 -04:00
parent a0d4f5ba3b
commit 20f1c60600
19921 changed files with 2509159 additions and 45 deletions

View File

@@ -0,0 +1,2 @@
.idea/
vendor/

View File

@@ -0,0 +1,201 @@
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.

View File

@@ -0,0 +1,175 @@
# 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 <b>Client ID</b> and <b>Secret</b> from there.
```php
require __DIR__ . '/vendor/autoload.php';
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
// Creating an environment
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";
$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)

View File

@@ -0,0 +1,35 @@
{
"name": "paypal/paypal-checkout-sdk",
"description": "PayPal's PHP SDK for Checkout REST APIs",
"keywords": ["paypal", "payments", "rest", "sdk", "orders", "checkout"],
"type": "library",
"license": "Apache-2.0",
"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"
}
}

View File

@@ -0,0 +1,6 @@
---
projectName: PayPalCheckoutSdk
language: php
sourcePath: lib/PayPalCheckoutSdk
testPath: tests
apiVersioning: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

View File

@@ -0,0 +1,25 @@
<?php
namespace PayPalCheckoutSdk\Core;
class AccessToken
{
public $token;
public $tokenType;
public $expiresIn;
private $createDate;
public function __construct($token, $tokenType, $expiresIn)
{
$this->token = $token;
$this->tokenType = $tokenType;
$this->expiresIn = $expiresIn;
$this->createDate = time();
}
public function isExpired()
{
return time() >= $this->createDate + $this->expiresIn;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\HttpRequest;
class AccessTokenRequest extends HttpRequest
{
public function __construct(PayPalEnvironment $environment, $refreshToken = NULL)
{
parent::__construct("/v1/oauth2/token", "POST");
$this->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";
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\HttpRequest;
use PayPalHttp\Injector;
use PayPalHttp\HttpClient;
class AuthorizationInjector implements Injector
{
private $client;
private $environment;
private $refreshToken;
public $accessToken;
public function __construct(HttpClient $client, PayPalEnvironment $environment, $refreshToken)
{
$this->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);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\Injector;
class FPTIInstrumentationInjector implements Injector
{
public function inject($request)
{
$request->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";
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\Injector;
class GzipInjector implements Injector
{
public function inject($httpRequest)
{
$httpRequest->headers["Accept-Encoding"] = "gzip";
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\Environment;
abstract class PayPalEnvironment implements Environment
{
private $clientId;
private $clientSecret;
public function __construct($clientId, $clientSecret)
{
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
}
public function authorizationString()
{
return base64_encode($this->clientId . ":" . $this->clientSecret);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\HttpClient;
class PayPalHttpClient extends HttpClient
{
private $refreshToken;
public $authInjector;
public function __construct(PayPalEnvironment $environment, $refreshToken = NULL)
{
parent::__construct($environment);
$this->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();
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace PayPalCheckoutSdk\Core;
class ProductionEnvironment extends PayPalEnvironment
{
public function __construct($clientId, $clientSecret)
{
parent::__construct($clientId, $clientSecret);
}
public function baseUrl()
{
return "https://api.paypal.com";
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace PayPalCheckoutSdk\Core;
use PayPalHttp\HttpRequest;
class RefreshTokenRequest extends HttpRequest
{
public function __construct(PayPalEnvironment $environment, $authorizationCode)
{
parent::__construct("/v1/identity/openidconnect/tokenservice", "POST");
$this->headers["Authorization"] = "Basic " . $environment->authorizationString();
$this->headers["Content-Type"] = "application/x-www-form-urlencoded";
$this->body = [
"grant_type" => "authorization_code",
"code" => $authorizationCode
];
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace PayPalCheckoutSdk\Core;
class SandboxEnvironment extends PayPalEnvironment
{
public function __construct($clientId, $clientSecret)
{
parent::__construct($clientId, $clientSecret);
}
public function baseUrl()
{
return "https://api.sandbox.paypal.com";
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace PayPalCheckoutSdk\Core;
/**
* Class PayPalUserAgent
* PayPalUserAgent generates User Agent for curl requests
*
* @package PayPal\Core
*/
class UserAgent
{
/**
* Returns the value of the User-Agent header
* Add environment values and php version numbers
*
* @return string
*/
public static function getValue()
{
$featureList = array(
'platform-ver=' . PHP_VERSION,
'bit=' . self::_getPHPBit(),
'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
'machine=' . php_uname('m')
);
if (defined('OPENSSL_VERSION_TEXT')) {
$opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
$featureList[] = 'crypto-lib-ver=' . $opensslVersion[1];
}
if (function_exists('curl_version')) {
$curlVersion = curl_version();
$featureList[] = 'curl=' . $curlVersion['version'];
}
return sprintf("PayPalSDK/%s %s (%s)", "Checkout-PHP-SDK", Version::VERSION, implode('; ', $featureList));
}
/**
* Gets PHP Bit version
*
* @return int|string
*/
private static function _getPHPBit()
{
switch (PHP_INT_SIZE) {
case 4:
return '32';
case 8:
return '64';
default:
return PHP_INT_SIZE;
}
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace PayPalCheckoutSdk\Core;
class Version
{
const VERSION = "1.0.2";
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:39 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// OrdersPatchRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+RXTW8jNwy991cIOg/sYFv0MDcjSZF+7MZN3AWKbWAzEp3R7sxQpaikRuD/Xmg0/ho33W67TVHkZOuJ1LwnUiL1qN9Ag7rUxBY5jDyIqXShzzAYdl4ctbrUP3kLgkFBqzq7kfqZojLQqtjNbCfUg5NKLU6vziez87OFIlaLyXR6dfk2jYKAxLB1bkme8r98Pf3hfLbvM6tQLamu6cG1dwpE2N3GzMkqun2PRoICRtUpgNsay1/iycmXJtbdL+ZR7fZHhmz+h64VbCWj4x08UtfRe2JBq8gjQ9oQ5YIa+jP6GgweL9Ajh999ioWPbCoIOI+tk/DX2GTVw5XA2iP3bqueg/i7m5GJQaiZO/ufinjCuKH7zy7Y7g7MS5HsYYU4wgZc/X9O1VA57117NwdrGUN4KeELtJT5Jm2JX4psaCg+300/3pQfXegfI/JqCgwNCnLQ5bubQl8gWOQh+g1xM8SmINUB9qhnK59qdxB27Z0u9Ftgl0rffk2fO6sL/T2uevCouKfK+u2ZoqWSCvsyLNRX5pEu9IQZVvlTJ4W+QrCXbb3S5RLqgAn4NTpGq0vhiIWecto/cRh02ca6Xt9kGwySF9nynvbNxoB2V8HnnF0OuA9nDoVMWgWJapLy3fXlm9wKbJsDIQXe1yvlgcVB3SvsJhgDRTYYBnq//lO9PbAv+ONBWTI1B6J64DgoWQOl1qSLSAqPAN+hKEsmNtiKqsnkTE2rqIfKmSqZpoPT2d9DHXGkNpzVkrjDF8liscv0T4rzH+juAl18PCP9gfRueCx8d/6ElKHG1/iJmfj3GXqQaphz1T8PD8guOBtF+bz9SxHIWX+sr0uIA4Eb5FhhN7M9N7kHX+RbeS91lCUMKjXznPkp6NPucyi6WSer4KkNmNdJcKFPqevYe7WJoMtbPX4fqNWFvhDxr1EqsummmcxOL3S+Q3Wpx/evxqZC84GijPPLZ/y4uS3XutDXH5zfcjr/zaMRtNfdU+SULOry1clX6y9+BwAA//8=
// DO NOT EDIT
namespace PayPalCheckoutSdk\Orders;
use PayPalHttp\HttpRequest;
class OrdersPatchRequest extends HttpRequest
{
function __construct($orderId)
{
parent::__construct("/v2/checkout/orders/{order_id}?", "PATCH");
$this->path = str_replace("{order_id}", urlencode($orderId), $this->path);
$this->headers["Content-Type"] = "application/json";
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// AuthorizationsCaptureRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+xde28jN5L//z5FQXvAxYAsTTzj2V0DB5wzdm58tx77bGcPizlDorqr1VyzyQ7JlqwN8t0PRbKlfsmeh+RskkYQjEWy1VWsql89+NBPgw8sw8HJgBU2VZr/g1mupBlFLLeFxsFwcIYm0jyn5sHJ4J1vN8AklI9gDDlbZSjtEGYruDgbDYaD/ylQr66ZZhla1GZw8vF+OHiPLEZda/1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s97T9n9z8PBO78jOsia5bkIv9I0/rtX0PfW5pf+zoyTwfXV7d3A/9LP4GQwXhyNy8ugxvXfDxv/1Pxtn5/Hm7u/bh94vibr/DHHyGLssYCwdHBy9Orbn//l/wEAAP//
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class AuthorizationsCaptureRequest extends HttpRequest
{
function __construct($authorizationId)
{
parent::__construct("/v2/payments/authorizations/{authorization_id}/capture?", "POST");
$this->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;
}
}

View File

@@ -0,0 +1,25 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// AuthorizationsGetRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+xbbW/juPF///8UA90f6AawrXSf7s7v0t1sN+1lk8beAkUaJLQ4tnihSB05sqMu9rsXJCXbkuxLrmdnW8AvFgsNR9b8Zn6cB4n5En1iGUbDiBWUaiP+xUhoZQczpKgXvUebGJE7UTSMRqleWOBITEgLU22AKajvQw45KzNU1INJCWfvB1Ev+luBprxkhmVIaGw0vL7pRR+RcTRt6QdtsrbsklHakH2JxmXurLVkhJpFvejvzAg2kbgJxa3gUS/6K5bVYgfQOEU4ew96CpTiBiQe4yIVSQqkwaZ6UaN34E6MYWWw57gXXSHjF0qW0XDKpEUn+KUQBnk0JFNgL7o0OkdDAm00VIWUX2+CDloKP+KETmRzrSwG2RLwyTqwLu7HcW5AR4YpyxKn9JvwVIJ1QKvInGuF5YbAZLpQ1DBzKeoamxTGoEpKYIpD0At8g6lQTCWCyXXre2CLJAVmgcGESaYSBG2WOHmBu8O3jXm1ybeJ5tjA2V7pwr2m1CD2k5QZlh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Oxs2/G4m/tP8C42vUi0b3Il9ac/qQY0LIR57O7zTHaPjy+Pjr//0bAAD//w==
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class AuthorizationsGetRequest extends HttpRequest
{
function __construct($authorizationId)
{
parent::__construct("/v2/payments/authorizations/{authorization_id}?", "GET");
$this->path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path);
$this->headers["Content-Type"] = "application/json";
}
}

View File

@@ -0,0 +1,33 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// AuthorizationsReauthorizeRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+xcW2/jNvZ//3+KA7V/7ASwrcwl0zbAPmRnppjsNk02zhQossGEpo4tNhSpkpQdbTHffXFIydbFHs9sncy28EMA65CUzuV3bhSV36IfWYbRccQKl2oj/s2c0MqODNYEjAbRa7TciJyGouPocjVmgSlYXiVwwcoLJoFxrgvlIGdlhsoNYFLC6esRXGlAZQuD4FLmYFqoxAIzCNYJKYHNmZBsInEAjed3HlHdE9jUoQHhLAglnGASXGoQhwkrIdVKG8jRCJ0A3ufCoB39qzg8fM4nJvY/sHN54m/nUtxymwGUugDO1CewqJUsQSuOMDU6g4SVFqa6MOA0PPtuBKdTeH4YyCmbI+TMWkzAClpCrCTMIeip/92/f2AlK6wDbpCmrmdDKOuQJdsU0BSosdhZlFNImQUGChcb1DOCnz9DLaQRbaDISRNPnx79fy2kNmImFCFotYxlHktMJaC0oxV4z5EGFAhFkluvpK+/OYJ349dbxBwXea6Ns/5xYYzrJMzC8KhAjVdkMPhrgZbwbFiGBBQy7SgaRP8s0JQXNdlGx9c3g+gtsgRNi/pbdFXm5GfWGaFm0SD6iRlBWK/8L3jO8DI8aXiaRIPoH1h+ZLTtlFcpgkUzRwPWaYMW7tDDzcCLI48xYvfEGFYGTg4H5MjJuZJldDxl0iIRfi2E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+cxKuHzJ6nSvcnH61wk76rSm7S7+r+TuOMZvwljOXjh0zbU03qR3kaWB57s8QCBv8k4Hf6Ud/boIpjvYv8O7y1A7A0i38EF03+nD/zmP0OJknpxbfqMbKjqS90S+RH/MN7D0sXzef2qeEJmPc71Y6A/ueZd+z7HuWfc+y71n2Pcu+Z9n3LPueZd+z7HuWfc/yQD3LxogknOyEpIrSj0mhIaHhnQeJMfpPni6MduGV2JoXQH7K+7w5pfEuaM3oGglwjpI8dzUP9HSKBpPu69bq25EeY/6N3Fl1sKPzIi1nZc7kiOssLmy8wAnLcxtneR5b5IURrowDn8PV8w8ePm0nwuaFw/ecOZxp06tz1w1vDnpcq9AO2tVpRq7nXof14ZbNB4cfKtKF79jakKhJbVlOVSJIVAuLFF2KPY5BWEApZmIiw/GcYLMGZkaP5Z2fLpX/kM4PffnDUkWerD232abvz/L9757lu/kwiF6Fcr2yNZUF1feq8S/Wh9e3zuVn4UDHcXRxPr6KwjeP0XEUz5/FFeZs3P6HAfFv3a8cP8Tt/yEwvhP5krU39zlyh8nYY/uVTjA6fnb49MP//QcAAP//
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class AuthorizationsReauthorizeRequest extends HttpRequest
{
function __construct($authorizationId)
{
parent::__construct("/v2/payments/authorizations/{authorization_id}/reauthorize?", "POST");
$this->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;
}
}

View File

@@ -0,0 +1,25 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// AuthorizationsVoidRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/2yS0YpTMRCG732KYa5jz7J4lTvZKruI7tGWBZFFpifTPdE0iZPJYix9dzltFVt7++XPMP/HbPEDbRgtUtUxif9F6lMss+fkHRqccxnE54mhxYfkXTGQBAaKA4digCL8+ckOMrUNRzWwanA3n8HnVKdoTArTwMtp0JEURiqwYo6wriE0GChrFXYzNPixsrSehDasLAXtl0eDt0yO5Zy+TbI5Zz3peMK2uGx56lxUfHxCgw8knlaBL7n4uhfxjtvx8T8ry5Ghp9ZTePnEkYWUHdzNYZ0EdOSLjdPex1TutQi1wz5XBj8xufsYGto1hcIT+FG9sEOrUtlgLymzqOeCNtYQdo+HDBc9DJnghEpOsfC/7CZF5XiMIeUc/LBv2H0rKaLBW9X8nnVMDi3294slHuShxe75ujsuX7rTU+m257p23fF6Ft99/tvkzc/Mg7JbKGktN8kx2uurV7sXvwEAAP//
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class AuthorizationsVoidRequest extends HttpRequest
{
function __construct($authorizationId)
{
parent::__construct("/v2/payments/authorizations/{authorization_id}/void?", "POST");
$this->path = str_replace("{authorization_id}", urlencode($authorizationId), $this->path);
$this->headers["Content-Type"] = "application/json";
}
}

View File

@@ -0,0 +1,25 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// CapturesGetRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+xcbVMjN/J///8UXZN/1S1VxibsQhJeHVnYLHdh4YDNVYqj7PZM26OgkSaSxsaX2u9+JWnGnicDydrkLpkXFDXdkqdb3fp1tx7ml+ADJhQcBSGmJlOk+1MyQS84IR0qlhomRXAUXMdyriEig4xrmEgFCHmHCFJcJCRMD8YLODvpB73gHxmpxSUqTMiQ0sHR7V0veE8YkapT30mV1GmXaOIK7ZfgZpFaIbVRTEyDXvADKoZjTlXhhywKesHfaZGTG3rcxASXuLhEvjslQQoNRXB24jQyMTV0cox5zMIYjAQdy3kxCFbNY6Vw4SXb6wV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T5tvBMCNVYCK6bxdkwg1S9Fwp868E/L7fsSh8uH5LvUpfd9/eObmCs5MCdO1MgAT1PUV2gLTfG3VWyHtgGLpgnIOSdUER5bt+mablCQAVuUSFUT7s9X4aFLk3jPkCSIRq4Qzrwj2kSqaKkUG1gJlVWLi1YQsfr/dt30z7i6HuGFFxNVRnfFOrxc+o+0obai2pTRu3y3K6LKfLcv5gWc7dRs8lWP/wrG1tutcc+tq/7MSnVetEH0ZLfl2FEmt9trZGl1zV7YOWItS1s0JLUtsdDMuCebx4TGobhkaXpx9Ozj58N7IwPDo5/XB2ejLqv9SxrSyNWr9TVqV33yn77/1O2d2nXvDWn4jObY1pylnowesn76DvjUnP/TczjoLvTm8C/83R4CgYzPYHxbegBsUnUQe/rL4v+inoBdf3LF1KcPqQUmgo8tPewmZwtL+39+n//gMAAP//
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class CapturesGetRequest extends HttpRequest
{
function __construct($captureId)
{
parent::__construct("/v2/payments/captures/{capture_id}?", "GET");
$this->path = str_replace("{capture_id}", urlencode($captureId), $this->path);
$this->headers["Content-Type"] = "application/json";
}
}

View File

@@ -0,0 +1,33 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// CapturesRefundRequest.php
// @version 0.1.0-dev+0ee05a-dirty
// @type request
// @data H4sIAAAAAAAC/+xde2/ctrL//36KwfYCNwbWu6lju62BC1w3dm7cUz+O7RQ48DG8XHF2xZoiFZLyWi3y3Q/40K6esZOsnZ4c/REgO0NJ8+JvZiiK/nNwQhIc7A0ikppMoR4pnGWCDoaDA9SRYqlhUgz2BueOrIFAGEkhJXmCwgxhmsPRwQjeSAUEZhnn4G8yBCYinlEEIgCT1OT2Gi4JBSbAxAi/XJyegML3GWoDU0nz4i4pUYaR1hv9M3v58lUUSYruf0gSmQnjqeMVGeT0d4xM95MGw8HfM1T5GVEkQYNKD/auroeD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KYh2MPBYVZxmeMc0+WiqLyW5yW1zINhGsJt0IuhAURO9DJ8PSogQlh/IZQqlBXU0Cd0zQGc3vniA9i9gdScNdAuObLT2Z5l9qGe3e7dJqBC27CuVwghSnOpPI7Obd2drpGkZlFtLZzVv+veRikZnMxgrdygXeohu4qf0yKnbIkijA1SCEh9yzJEuAo5ib2E0FUtbde3drZbhzEEDZSwR2qAhPtlBWQCWck+lgpAe+ZNl/5vJkihusnuFTpXSfQuCBXcHRQgC5z5+8SfYvUGkiXTgKuvRcKoGRDUFiQsy7INC73zinqjwbFYPb6dRoUuidMeQ4oIpU7x7p0D6mSqWJoiMrhzios3GKPhY9XW/baTPsjFdwG3OJQBZ3xdS3/PKK5M9IQfuOLp/YXU10j+mqnr3b6aucbXg7qfEPjTgyvvpgpSC0nzTtWAb/h9OY1vxW48M848FVVl8Q3dMmvS15idRdr1W0I/sKnRyi/abZ26k0gdW6xXcR5WdY4FIOTs8OTg6OT/59YnJ282T/69fBgsiZNHr2DOEtp6/mBVXp/fuBf9/zA6w/DwWv/7VDwNUlTHv6Ywfh3H5tvjUmP/elSe4Oz04vLgT8Qf7A3GN9tjUOW1+Pib4GM/1wdfv9hvPzDIBe3LF1KcnifYmSQ+vluYXKwt/Xy+w//9S8AAAD//w==
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class CapturesRefundRequest extends HttpRequest
{
function __construct($captureId)
{
parent::__construct("/v2/payments/captures/{capture_id}/refund?", "POST");
$this->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;
}
}

View File

@@ -0,0 +1,25 @@
<?php
// This class was generated on Wed, 01 Aug 2018 16:35:04 PDT by version 0.1.0-dev+0ee05a-dirty of Braintree SDK Generator
// RefundsGetRequest.php
// @version 0.1.0-dev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IA/1sMuqKAFVPVh/d6jjM0Pd8rXJPitiyLY8wIOaTsQaR5ChLVlJKwEVRVe7eq+wdvGhcxFIVUMENTYqLbsgpy5SeJP1VKwAdh6U++b6a04foNLlV62w003sgNnJ2UoOt2AqTM3iN3E+Tv4dn8XagAJWeCyoGcW4Lc4rJ2znAfjQgspr3ez4JBP8JYLgBVbBZ+Yb27h8zozAgkZhYwcworf9jj4OP1vuub23Clgi/ALS9VsLnc1vHPE5I70sTkMARPmz9MtbXoop0u2umina/4OKj1Cw0xyqtOfklq2kdglfAbs4xys+1a5OswxkmIqtokHvIlvy75Gqs9WKuWIYSOz49QoWi2dutNQWotsZ0ni3VZkyIYHF2efjg5+/DTyOHs6N3x2c+nJ6MtafLkCuI84xvvD6zSu/sD/3XvD7z71Iveht8OFWvNskyKOIDUL8E23xNl5+F2qaPop9ObKNwBHB1Fg9n+oHDydlDcSzz4bXnd76eoF13fi2w5/ulDhjEhD7vcgWN0tL+39+m//gkAAP//
// DO NOT EDIT
namespace PayPalCheckoutSdk\Payments;
use PayPalHttp\HttpRequest;
class RefundsGetRequest extends HttpRequest
{
function __construct($refundId)
{
parent::__construct("/v2/payments/refunds/{refund_id}?", "GET");
$this->path = str_replace("{refund_id}", urlencode($refundId), $this->path);
$this->headers["Content-Type"] = "application/json";
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="integration">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@@ -0,0 +1,61 @@
<?php
namespace Sample\AuthorizeIntentExamples;
require __DIR__ . '/../../vendor/autoload.php';
use PayPalCheckoutSdk\Orders\OrdersAuthorizeRequest;
use Sample\PayPalClient;
class AuthorizeOrder
{
/**
* Setting up request body for Authorize. This can be populated with fields as per need. Refer API docs for more details.
*
*/
public static function buildRequestBody()
{
return "{}";
}
/**
* This function can be used to perform authorization on the approved order.
* Valid Approved order id should be passed as an argument.
*/
public static function authorizeOrder($orderId, $debug=false)
{
$request = new OrdersAuthorizeRequest($orderId);
$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 "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);
}

View File

@@ -0,0 +1,55 @@
<?php
namespace Sample\AuthorizeIntentExamples;
require __DIR__ . '/../../vendor/autoload.php';
use PayPalCheckoutSdk\Payments\AuthorizationsCaptureRequest;
use Sample\PayPalClient;
class CaptureOrder
{
/**
* Below method can be used to build the capture request body.
* This request can be updated with required fields as per need.
* Please refer API specs for more info.
*/
public static function buildRequestBody()
{
return "{}";
}
/**
* Below function can be used to capture order.
* Valid Authorization id should be passed as an argument.
*/
public static function captureOrder($authorizationId, $debug=false)
{
$request = new AuthorizationsCaptureRequest($authorizationId);
$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 "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);
}

View File

@@ -0,0 +1,237 @@
<?php
namespace Sample\AuthorizeIntentExamples;
require __DIR__ . '/../../vendor/autoload.php';
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
use Sample\PayPalClient;
class CreateOrder
{
/**
* Setting up the JSON request body for creating the Order with complete request body. The Intent in the
* request body should be set as "AUTHORIZE" for authorize intent flow.
*
*/
private static function buildRequestBody()
{
return array(
'intent' => '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);
}

View File

@@ -0,0 +1,82 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';
use Sample\AuthorizeIntentExamples\CreateOrder;
use Sample\AuthorizeIntentExamples\AuthorizeOrder;
use Sample\AuthorizeIntentExamples\CaptureOrder;
use Sample\RefundOrder;
$order = CreateOrder::createOrder();
print "Creating Order...\n";
$orderId = "";
if ($order->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);
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Sample\CaptureIntentExamples;
require __DIR__ . '/../../vendor/autoload.php';
use Sample\PayPalClient;
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
class CaptureOrder
{
/**
* This function can be used to capture an order payment by passing the approved
* order id as argument.
*
* @param orderId
* @param debug
* @returns
*/
public static function captureOrder($orderId, $debug=false)
{
$request = new OrdersCaptureRequest($orderId);
$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";
}
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
* <b>Approved</b> Order Id to capture the order payment.
*/
if (!count(debug_backtrace()))
{
CaptureOrder::captureOrder('0F105083N67049335', true);
}

View File

@@ -0,0 +1,178 @@
<?php
namespace Sample\CaptureIntentExamples;
require __DIR__ . '/../../vendor/autoload.php';
use Sample\PayPalClient;
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
class CreateOrder
{
/**
* Setting up the JSON request body for creating the Order. The Intent in the
* request body should be set as "CAPTURE" for capture intent flow.
*
*/
private static function buildRequestBody()
{
return array(
'intent' => '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);
}

View File

@@ -0,0 +1,74 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';
use Sample\CaptureIntentExamples\CreateOrder;
use Sample\CaptureIntentExamples\CaptureOrder;
use Sample\RefundOrder;
$order = CreateOrder::createOrder();
print "Creating Order...\n";
$orderId = "";
if ($order->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);
}

View File

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

View File

@@ -0,0 +1,54 @@
<?php
namespace Sample;
require __DIR__ . '/../vendor/autoload.php';
use Sample\PayPalClient;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use Sample\CaptureIntentExamples\CreateOrder;
class GetOrder
{
/**
* This function can be used to retrieve an order by passing order Id as argument.
*/
public static function getOrder($orderId)
{
$client = PayPalClient::client();
$response = $client->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);
}

View File

@@ -0,0 +1,82 @@
<?php
namespace Sample;
require __DIR__ . '/../vendor/autoload.php';
use PayPalCheckoutSdk\Orders\OrdersPatchRequest;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use Sample\AuthorizeIntentExamples\CreateOrder;
class PatchOrder
{
private static function buildRequestBody()
{
return array (
0 =>
array (
'op' => 'replace',
'path' => '/intent',
'value' => 'CAPTURE',
),
1 =>
array (
'op' => 'replace',
'path' => '/purchase_units/@reference_id==\'PUHF\'/amount',
'value' =>
array (
'currency_code' => 'USD',
'value' => '200.00',
'breakdown' =>
array (
'item_total' =>
array (
'currency_code' => 'USD',
'value' => '180.00',
),
'tax_total' =>
array (
'currency_code' => 'USD',
'value' => '20.00',
),
),
),
),
);
}
public static function patchOrder($orderId)
{
$client = PayPalClient::client();
$request = new OrdersPatchRequest($orderId);
$request->body = PatchOrder::buildRequestBody();
$client->execute($request);
$response = $client->execute(new OrdersGetRequest($orderId));
print "Status Code: {$response->statusCode}\n";
print "Status: {$response->result->status}\n";
print "Order ID: {$response->result->id}\n";
print "Intent: {$response->result->intent}\n";
print "Links:\n";
foreach($response->result->links as $link)
{
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
}
print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n";
// To toggle printing the whole response body comment/uncomment below line
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n";
}
}
if (!count(debug_backtrace()))
{
print "Before PATCH:\n";
$createdOrder = CreateOrder::createOrder(true)->result;
print "\nAfter PATCH (Changed Intent and Amount):\n";
PatchOrder::patchOrder($createdOrder->id);
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Sample;
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
class PayPalClient
{
/**
* Returns PayPal HTTP client instance with environment which has access
* credentials context. This can be used invoke PayPal API's provided the
* credentials have the access to do so.
*/
public static function client()
{
return new PayPalHttpClient(self::environment());
}
/**
* Setting up and Returns PayPal SDK environment with PayPal Access credentials.
* For demo purpose, we are using SandboxEnvironment. In production this will be
* ProductionEnvironment.
*/
public static function environment()
{
$clientId = getenv("CLIENT_ID") ?: "<<PAYPAL-CLIENT-ID>>";
$clientSecret = getenv("CLIENT_SECRET") ?: "<<PAYPAL-CLIENT-SECRET>>";
return new SandboxEnvironment($clientId, $clientSecret);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Sample;
require __DIR__ . '/../vendor/autoload.php';
use Sample\PayPalClient;
use PayPalCheckoutSdk\Payments\CapturesRefundRequest;
class RefundOrder
{
/**
* Function to create an refund capture request. Payload can be updated to issue partial refund.
*/
public static function buildRequestBody()
{
return array(
'amount' =>
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);
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Test\Orders;
use PHPUnit\Framework\TestCase;
use PayPalCheckoutSdk\Orders\OrdersAuthorizeRequest;
use Test\TestHarness;
class OrdersAuthorizeTest extends TestCase
{
public function testOrdersAuthorizeRequest()
{
$this->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);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Test\Orders;
use PHPUnit\Framework\TestCase;
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
use Test\TestHarness;
class OrdersCaptureTest extends TestCase
{
public function testOrdersCaptureRequest()
{
$this->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);
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Test\Orders;
use PHPUnit\Framework\TestCase;
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
use Test\TestHarness;
class OrdersCreateTest extends TestCase
{
private static function buildRequestBody()
{
return [
"intent" => "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);
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Test\Orders;
use PHPUnit\Framework\TestCase;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use Test\TestHarness;
class OrdersGetTest extends TestCase
{
public function testOrdersGetRequest()
{
$client = TestHarness::client();
$createdOrder = OrdersCreateTest::create($client);
$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("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);
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Test\Orders;
use PHPUnit\Framework\TestCase;
use PayPalCheckoutSdk\Orders\OrdersPatchRequest;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use Test\TestHarness;
class OrdersPatchTest extends TestCase
{
private function buildRequestBody()
{
return [
[
"op" => "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);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Test;
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
class TestHarness
{
public static function client()
{
return new PayPalHttpClient(self::environment());
}
public static function environment()
{
$clientId = getenv("CLIENT_ID") ?: "<<PAYPAL-CLIENT-ID>>";
$clientSecret = getenv("CLIENT_SECRET") ?: "<<PAYPAL-CLIENT-SECRET>>";
return new SandboxEnvironment($clientId, $clientSecret);
}
}

View File

@@ -0,0 +1,7 @@
tests/ export-ignore
.idea/ export-ignore
.github/ export-ignore
.releasinator.rb export-ignore
Gemfile export-ignore
Gemfile.lock export-ignore

32
vendor/paypal/paypalhttp/.gitignore vendored Normal file
View File

@@ -0,0 +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/*

16
vendor/paypal/paypalhttp/.travis.yml vendored Normal file
View File

@@ -0,0 +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

5
vendor/paypal/paypalhttp/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,5 @@
## 1.0.1
* Fix Case Sensitivity of Content Type for deserialization process
## 1.0.0
- First release

View File

@@ -0,0 +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.

23
vendor/paypal/paypalhttp/LICENSE vendored Normal file
View File

@@ -0,0 +1,23 @@
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.

76
vendor/paypal/paypalhttp/README.md vendored Normal file
View File

@@ -0,0 +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.

2
vendor/paypal/paypalhttp/Rakefile vendored Normal file
View File

@@ -0,0 +1,2 @@
spec = Gem::Specification.find_by_name 'releasinator'
load "#{spec.gem_dir}/lib/tasks/releasinator.rake"

23
vendor/paypal/paypalhttp/composer.json vendored Normal file
View File

@@ -0,0 +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"
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace PayPalHttp;
/**
* Class Curl
* @package PayPalHttp
*
* Curl wrapper used by HttpClient to make curl requests.
* @see HttpClient
*/
class Curl
{
protected $curl;
public function __construct($curl = NULL)
{
if (is_null($curl))
{
$curl = curl_init();
}
$this->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);
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace PayPalHttp;
use PayPalHttp\Serializer\Form;
use PayPalHttp\Serializer\Json;
use PayPalHttp\Serializer\Multipart;
use PayPalHttp\Serializer\Text;
/**
* Class Encoder
* @package PayPalHttp
*
* Encoding class for serializing and deserializing request/response.
*/
class Encoder
{
private $serializers = [];
function __construct()
{
$this->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;
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace PayPalHttp;
/**
* Interface Environment
* @package PayPalHttp
*
* Describes a domain that hosts a REST API, against which an HttpClient will make requests.
* @see HttpClient
*/
interface Environment
{
/**
* @return string
*/
public function baseUrl();
}

View File

@@ -0,0 +1,238 @@
<?php
namespace PayPalHttp;
/**
* Class HttpClient
* @package PayPalHttp
*
* Client used to make HTTP requests.
*/
class HttpClient
{
/**
* @var Environment
*/
public $environment;
/**
* @var Injector[]
*/
public $injectors = [];
/**
* @var Encoder
*/
public $encoder;
/**
* HttpClient constructor. Pass the environment you wish to make calls to.
*
* @param Environment $environment
* @see Environment
*/
function __construct(Environment $environment)
{
$this->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);
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace PayPalHttp;
class HttpException extends IOException
{
/**
* @var int
*/
public $statusCode;
/**
* @var array
*/
public $headers;
/**
* @param string $message
* @param int $statusCode
* @param array $headers
*/
public function __construct($message, $statusCode, $headers)
{
parent::__construct($message);
$this->statusCode = $statusCode;
$this->headers = $headers;
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace PayPalHttp;
/**
* Class HttpRequest
* @package PayPalHttp
*
* Request object that holds all the necessary information required by HTTPClient
*
* @see HttpClient
*/
class HttpRequest
{
/**
* @var string
*/
public $path;
/**
* @var array | string
*/
public $body;
/**
* @var string
*/
public $verb;
/**
* @var array
*/
public $headers;
function __construct($path, $verb)
{
$this->path = $path;
$this->verb = $verb;
$this->body = NULL;
$this->headers = [];
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace PayPalHttp;
/**
* Class HttpResponse
* @package PayPalHttp
*
* Object that holds your response details
*/
class HttpResponse
{
/**
* @var int
*/
public $statusCode;
/**
* @var array | string | object
*/
public $result;
/**
* @var array
*/
public $headers;
public function __construct($statusCode, $body, $headers)
{
$this->statusCode = $statusCode;
$this->headers = $headers;
$this->result = $body;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace PayPalHttp;
use Throwable;
class IOException extends \Exception
{
public function __construct($message = "", $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace PayPalHttp;
/**
* Interface Injector
* @package PayPalHttp
*
* Interface that can be implemented to apply injectors to Http client.
*
* @see HttpClient
*/
interface Injector
{
/**
* @param HttpRequest $httpRequest
*/
public function inject($httpRequest);
}

View File

@@ -0,0 +1,29 @@
<?php
namespace PayPalHttp;
/**
* Interface Serializer
* @package PayPalHttp
*
* Used to implement different serializers for different content types
*/
interface Serializer
{
/**
* @return string Regex that matches the content type it supports.
*/
public function contentType();
/**
* @param HttpRequest $request
* @return string representation of your data after being serialized.
*/
public function encode(HttpRequest $request);
/**
* @param $body
* @return mixed object/string representing the de-serialized response body.
*/
public function decode($body);
}

View File

@@ -0,0 +1,46 @@
<?php
namespace PayPalHttp\Serializer;
use PayPalHttp\HttpRequest;
use PayPalHttp\Serializer;
class Form implements Serializer
{
/**
* @return string Regex that matches the content type it supports.
*/
public function contentType()
{
return "/^application\/x-www-form-urlencoded$/";
}
/**
* @param HttpRequest $request
* @return string representation of your data after being serialized.
*/
public function encode(HttpRequest $request)
{
if (!is_array($request->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;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace PayPalHttp\Serializer;
class FormPart
{
private $value;
private $headers;
public function __construct($value, $headers)
{
$this->value = $value;
$this->headers = array_merge([], $headers);
}
public function getValue()
{
return $this->value;
}
public function getHeaders()
{
return $this->headers;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace PayPalHttp\Serializer;
use PayPalHttp\HttpRequest;
use PayPalHttp\Serializer;
/**
* Class Json
* @package PayPalHttp\Serializer
*
* Serializer for JSON content types.
*/
class Json implements Serializer
{
public function contentType()
{
return "/^application\\/json/";
}
public function encode(HttpRequest $request)
{
$body = $request->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);
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace PayPalHttp\Serializer;
use finfo;
use PayPalHttp\HttpRequest;
use PayPalHttp\Serializer;
use PayPalHttp\Encoder;
use PayPalHttp\Serializer\FormPart;
/**
* Class Multipart
* @package PayPalHttp\Serializer
*
* Serializer for multipart.
*/
class Multipart implements Serializer
{
const LINEFEED = "\r\n";
public function contentType()
{
return "/^multipart\/.*$/";
}
public function encode(HttpRequest $request)
{
if (!is_array($request->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);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace PayPalHttp\Serializer;
use PayPalHttp\HttpRequest;
use PayPalHttp\Serializer;
/**
* Class Text
* @package PayPalHttp\Serializer
*
* Serializer for Text content types.
*/
class Text implements Serializer
{
public function contentType()
{
return "/^text\\/.*/";
}
public function encode(HttpRequest $request)
{
$body = $request->body;
if (is_string($body)) {
return $body;
}
if (is_array($body)) {
return json_encode($body);
}
return implode(" ", $body);
}
public function decode($data)
{
return $data;
}
}

10
vendor/paypal/paypalhttp/phpunit.xml vendored Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
</testsuites>
</phpunit>