Skip to content

Commit 6b43a42

Browse files
Beta Release 0.5.0 (paypal#3)
* Automated commit message * Automated commit message * Automated commit message * Automated commit message --------- Co-authored-by: PayPalServerSDKs <server-sdks@paypal.com>
1 parent c9cb1ad commit 6b43a42

File tree

732 files changed

+73569
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

732 files changed

+73569
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.php -lf

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
composer.phar
2+
vendor/
3+
.phpunit.result.cache
4+
coverage/

.phan/config.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
$vendor_dir = getenv('COMPOSER_VENDOR_DIR') ?: 'vendor';
4+
5+
/**
6+
* This configuration will be read and overlaid on top of the
7+
* default configuration. Command line arguments will be applied
8+
* after this file is read.
9+
*/
10+
return [
11+
// Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `null`.
12+
// If this is set to `null`,
13+
// then Phan assumes the PHP version which is closest to the minor version
14+
// of the php executable used to execute Phan.
15+
//
16+
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
17+
// (See `backward_compatibility_checks` for additional options)
18+
'target_php_version' => '7.2',
19+
20+
// A list of directories that should be parsed for class and
21+
// method information. After excluding the directories
22+
// defined in exclude_analysis_directory_list, the remaining
23+
// files will be statically analyzed for errors.
24+
//
25+
// Thus, both first-party and third-party code being used by
26+
// your application should be included in this list.
27+
'directory_list' => [
28+
'src',
29+
$vendor_dir . '/psr/log',
30+
$vendor_dir . '/apimatic/unirest-php',
31+
$vendor_dir . '/apimatic/core',
32+
$vendor_dir . '/apimatic/core-interfaces'
33+
],
34+
35+
// A directory list that defines files that will be excluded
36+
// from static analysis, but whose class and method
37+
// information should be included.
38+
//
39+
// Generally, you'll want to include the directories for
40+
// third-party code (such as "vendor/") in this list.
41+
//
42+
// n.b.: If you'd like to parse but not analyze 3rd
43+
// party code, directories containing that code
44+
// should be added to both the `directory_list`
45+
// and `exclude_analysis_directory_list` arrays.
46+
'exclude_analysis_directory_list' => [
47+
$vendor_dir
48+
],
49+
50+
'plugin_config' => [
51+
'infer_pure_methods' => true
52+
],
53+
54+
'plugins' => [
55+
'AlwaysReturnPlugin',
56+
'DuplicateArrayKeyPlugin',
57+
'PregRegexCheckerPlugin',
58+
'PrintfCheckerPlugin',
59+
'UnreachableCodePlugin',
60+
'InvokePHPNativeSyntaxCheckPlugin',
61+
'UseReturnValuePlugin',
62+
'EmptyStatementListPlugin',
63+
'LoopVariableReusePlugin',
64+
'RedundantAssignmentPlugin',
65+
'NonBoolBranchPlugin',
66+
'NonBoolInLogicalArithPlugin',
67+
'InvalidVariableIssetPlugin',
68+
'NoAssertPlugin',
69+
'DuplicateExpressionPlugin',
70+
'WhitespacePlugin',
71+
'PHPDocToRealTypesPlugin',
72+
'PHPDocRedundantPlugin',
73+
'PreferNamespaceUsePlugin',
74+
'StrictComparisonPlugin',
75+
'EmptyMethodAndFunctionPlugin',
76+
'DollarDollarPlugin',
77+
'AvoidableGetterPlugin'
78+
]
79+
];

LICENSE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
The PayPal Server SDK is released under the following license:
2+
3+
Copyright (c) 2024 PAYPAL, INC.
4+
5+
SDK LICENSE
6+
7+
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.
8+
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.
9+
10+
1. LICENSE GRANT
11+
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, other than perpetration of any fraud or violation of any law, statute, ordinance, or regulation (for example, those governing financial services, consumer protections, unfair competition, anti-discrimination or false advertising), 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.
12+
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, other than perpetration of any fraud or violation of any law, statute, ordinance, or regulation (for example, those governing financial services, consumer protections, unfair competition, anti-discrimination or false advertising). You may not modify the Documentation.
13+
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.
14+
Nothing in this Agreement provides you with any right, title, or license to use PayPal’s or any third party’s copyright, patent, trademark, trade secret, or other intellectual property rights, or rights of publicity or privacy, beyond the rights specifically granted herein. You may not infringe PayPal’s or any third party’s copyright, patent, trademark, trade secret, or other intellectual property rights, or rights of publicity or privacy.
15+
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:
16+
(a) complies with the terms and conditions of this license agreement;
17+
(b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
18+
(c) effectively excludes all liability for damages on behalf of PayPal;
19+
(d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
20+
(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.
21+
22+
2. DISCLAIMER OF WARRANTY
23+
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.
24+
25+
3. LIMITATION OF LIABILITY
26+
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.
27+
28+
4. TRADEMARK USAGE
29+
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.
30+
31+
5. TERM
32+
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.
33+
34+
6. GOVERNING LAW AND JURISDICTION.
35+
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.

README.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,109 @@
1-
# PayPal-PHP-Server-SDK
1+
2+
# Getting Started with Paypal Server SDK
3+
4+
## Introduction
5+
6+
An order represents a payment between two or more parties. Use the Orders API to create, update, retrieve, authorize, and capture orders., Call the Payments API to authorize payments, capture authorized payments, refund payments that have already been captured, and show payment information. Use the Payments API in conjunction with the <a href="/docs/api/orders/v2/">Orders API</a>. For more information, see the <a href="/docs/checkout/">PayPal Checkout Overview</a>., The Payment Method Tokens API saves payment methods so payers don't have to enter details for future transactions. Payers can check out faster or pay without being present after they agree to save a payment method.<br><br>The API associates a payment method with a temporary setup token. Pass the setup token to the API to exchange the setup token for a permanent token.<br><br>The permanent token represents a payment method that's saved to the vault. This token can be used repeatedly for checkout or recurring transactions such as subscriptions.<br><br>The Payment Method Tokens API is available in the US only.
7+
8+
Find out more here: [https://developer.paypal.com/docs/api/orders/v2/](https://developer.paypal.com/docs/api/orders/v2/)
9+
10+
## Install the Package
11+
12+
Run the following command to install the package and automatically add the dependency to your composer.json file:
13+
14+
```php
15+
composer require "paypal/paypal-server-sdk:0.5.1"
16+
```
17+
18+
Or add it to the composer.json file manually as given below:
19+
20+
```php
21+
"require": {
22+
"paypal/paypal-server-sdk": "0.5.1"
23+
}
24+
```
25+
26+
You can also view the package at:
27+
https://packagist.org/packages/paypal/paypal-server-sdk#0.5.1
28+
29+
## Initialize the API Client
30+
31+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/client.md)
32+
33+
The following parameters are configurable for the API Client:
34+
35+
| Parameter | Type | Description |
36+
| --- | --- | --- |
37+
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.SANDBOX`** |
38+
| `timeout` | `int` | Timeout for API calls in seconds.<br>*Default*: `0` |
39+
| `enableRetries` | `bool` | Whether to enable retries and backoff feature.<br>*Default*: `false` |
40+
| `numberOfRetries` | `int` | The number of retries to make.<br>*Default*: `0` |
41+
| `retryInterval` | `float` | The retry time interval between the endpoint calls.<br>*Default*: `1` |
42+
| `backOffFactor` | `float` | Exponential backoff factor to increase interval between retries.<br>*Default*: `2` |
43+
| `maximumRetryWaitTime` | `int` | The maximum wait time in seconds for overall retrying requests.<br>*Default*: `0` |
44+
| `retryOnTimeout` | `bool` | Whether to retry on request timeout.<br>*Default*: `true` |
45+
| `httpStatusCodesToRetry` | `array` | Http status codes to retry against.<br>*Default*: `408, 413, 429, 500, 502, 503, 504, 521, 522, 524` |
46+
| `httpMethodsToRetry` | `array` | Http methods to retry against.<br>*Default*: `'GET', 'PUT'` |
47+
| `loggingConfiguration` | [`LoggingConfigurationBuilder`](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/logging-configuration-builder.md) | Represents the logging configurations for API calls |
48+
| `clientCredentialsAuth` | [`ClientCredentialsAuth`](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/auth/oauth-2-client-credentials-grant.md) | The Credentials Setter for OAuth 2 Client Credentials Grant |
49+
50+
The API client can be initialized as follows:
51+
52+
```php
53+
$client = PaypalServerSDKClientBuilder::init()
54+
->clientCredentialsAuthCredentials(
55+
ClientCredentialsAuthCredentialsBuilder::init(
56+
'OAuthClientId',
57+
'OAuthClientSecret'
58+
)
59+
)
60+
->environment(Environment::SANDBOX)
61+
->loggingConfiguration(
62+
LoggingConfigurationBuilder::init()
63+
->level(LogLevel::INFO)
64+
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
65+
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
66+
)
67+
->build();
68+
```
69+
70+
API calls return an `ApiResponse` object that includes the following fields:
71+
72+
| Field | Description |
73+
| --- | --- |
74+
| `getStatusCode` | Status code of the HTTP response |
75+
| `getHeaders` | Headers of the HTTP response as a Hash |
76+
| `getResult` | The deserialized body of the HTTP response as a String |
77+
78+
## Environments
79+
80+
The SDK can be configured to use a different environment for making API calls. Available environments are:
81+
82+
### Fields
83+
84+
| Name | Description |
85+
| --- | --- |
86+
| Production | PayPal Live Environment |
87+
| Sandbox | **Default** PayPal Sandbox Environment |
88+
89+
## Authorization
90+
91+
This API uses the following authentication schemes.
92+
93+
* [`Oauth2 (OAuth 2 Client Credentials Grant)`](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/auth/oauth-2-client-credentials-grant.md)
94+
95+
## List of APIs
96+
97+
* [Orders](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/controllers/orders.md)
98+
* [Payments](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/controllers/payments.md)
99+
* [Vault](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/controllers/vault.md)
100+
101+
## Classes Documentation
102+
103+
* [ApiException](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/api-exception.md)
104+
* [HttpRequest](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/http-request.md)
105+
* [HttpResponse](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/http-response.md)
106+
* [LoggingConfigurationBuilder](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/logging-configuration-builder.md)
107+
* [RequestLoggingConfigurationBuilder](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/request-logging-configuration-builder.md)
108+
* [ResponseLoggingConfigurationBuilder](https://www.github.com/paypal/PayPal-PHP-Server-SDK/tree/0.5.1/doc/response-logging-configuration-builder.md)
109+

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "paypal/paypal-server-sdk",
3+
"description": "PayPal's SDK for interacting with the REST APIs",
4+
"type": "library",
5+
"keywords": [],
6+
"homepage": "https://github.com/paypal/PayPal-PHP-Server-SDK",
7+
"license": [
8+
"MIT"
9+
],
10+
"authors": [],
11+
"support": {},
12+
"require": {
13+
"php": "^7.2 || ^8.0",
14+
"ext-json": "*",
15+
"apimatic/unirest-php": "^4.0.0",
16+
"apimatic/core-interfaces": "~0.1.5",
17+
"apimatic/core": "~0.3.11"
18+
},
19+
"require-dev": {
20+
"squizlabs/php_codesniffer": "^3.5",
21+
"phan/phan": "5.4.2"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"PaypalServerSDKLib\\": "src/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"PaypalServerSDKLib\\Tests\\": "tests/"
31+
}
32+
},
33+
"scripts": {
34+
"lint-src": "phpcs --standard=phpcs-ruleset.xml src/",
35+
"lint-src-fix": "phpcbf --standard=phpcs-ruleset.xml src/",
36+
"analyze": "phan --allow-polyfill-parser -p",
37+
"lint": [
38+
"@lint-src"
39+
]
40+
}
41+
}

doc/api-exception.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# ApiException
3+
4+
Thrown when there is a network error or HTTP response status code is not okay.
5+
6+
## Methods
7+
8+
| Name | Type | Description |
9+
| --- | --- | --- |
10+
| getHttpRequest() | [`HttpRequest`](http-request.md) | Returns the HTTP request. |
11+
| getHttpResponse() | ?[`HttpResponse`](http-response.md) | Returns the HTTP response. |
12+
| hasResponse() | bool | Is the response available? |
13+

0 commit comments

Comments
 (0)