AuthorizeIntentExamples
5 years ago
CaptureIntentExamples
5 years ago
ErrorSample.php
5 years ago
GetOrder.php
5 years ago
PatchOrder.php
5 years ago
PayPalClient.php
5 years ago
RefundOrder.php
5 years ago
PayPalClient.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Sample; |
| 4 | |
| 5 | use PayPalCheckoutSdk\Core\PayPalHttpClient; |
| 6 | use PayPalCheckoutSdk\Core\SandboxEnvironment; |
| 7 | |
| 8 | ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL); |
| 9 | ini_set('display_errors', '1'); |
| 10 | ini_set('display_startup_errors', '1'); |
| 11 | |
| 12 | class PayPalClient |
| 13 | { |
| 14 | /** |
| 15 | * Returns PayPal HTTP client instance with environment which has access |
| 16 | * credentials context. This can be used invoke PayPal API's provided the |
| 17 | * credentials have the access to do so. |
| 18 | */ |
| 19 | public static function client() |
| 20 | { |
| 21 | return new PayPalHttpClient(self::environment()); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Setting up and Returns PayPal SDK environment with PayPal Access credentials. |
| 26 | * For demo purpose, we are using SandboxEnvironment. In production this will be |
| 27 | * ProductionEnvironment. |
| 28 | */ |
| 29 | public static function environment() |
| 30 | { |
| 31 | $clientId = getenv("CLIENT_ID") ?: "<<PAYPAL-CLIENT-ID>>"; |
| 32 | $clientSecret = getenv("CLIENT_SECRET") ?: "<<PAYPAL-CLIENT-SECRET>>"; |
| 33 | return new SandboxEnvironment($clientId, $clientSecret); |
| 34 | } |
| 35 | } |
| 36 |