checkout / checkout-sdk-php-beta
Checkout.com SDK for PHP
Requires
- php: >=7.4
- ext-fileinfo: *
- ext-json: *
- guzzlehttp/guzzle: ^7.4.1
- monolog/monolog: ^2.3
- symfony/deprecation-contracts: ^2.5
- symfony/polyfill-php80: ^1.23.1
Requires (Dev)
- mockery/mockery: ^1.4
- phpstan/extension-installer: ^1.1.0
- phpstan/phpstan: ^1.2.0
- phpstan/phpstan-deprecation-rules: ^1.0.0
- phpunit/phpunit: ^9.5.10
- symfony/phpunit-bridge: ^6.0.0
This package is auto-updated.
Last update: 2022-03-09 16:59:10 UTC
README
This is a temporary development Checkout PHP SDK project that was archived and transferred to the official repository.
Getting started
Packages and sources are available from Packagist.
Composer
"require": { "php": ">=7.4", "checkout/checkout-sdk-php-beta": "version" }
Please check in GitHub releases for all the versions available.
How to use the SDK
This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features. Please find in the table below the types of keys that can be used within this SDK.
Account System | Public Key (example) | Secret Key (example) |
---|---|---|
default | pk_g650ff27-7c42-4ce1-ae90-5691a188ee7b | sk_gk3517a8-3z01-45fq-b4bd-4282384b0a64 |
Four | pk_pkhpdtvabcf7hdgpwnbhw7r2uic | sk_m73dzypy7cf3gf5d2xr4k7sxo4e |
Note: sandbox keys have a test_
or sbox_
identifier, for Default and Four accounts respectively.
PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.
If you don't have your own API keys, you can sign up for a test account here.
Default
Default keys client instantiation can be done as follows:
$builder = CheckoutDefaultSdk::staticKeys(); $builder->setPublicKey("public_key"); $builder->setSecretKey("secret_key"); $builder->setEnvironment(Environment::sandbox()); // or production() $builder->setHttpClientBuilder(); // optional, for a custom HTTP client $defaultApi = $builder->build(); $paymentsClient = $defaultApi->getPaymentsClient(); $paymentsClient->refundPayment("payment_id");
Four
If your pair of keys matches the Four type, this is how the SDK should be used:
$builder = CheckoutFourSdk::staticKeys(); $builder->setPublicKey("public_key"); $builder->setSecretKey("secret_key"); $builder->setEnvironment(Environment::sandbox()); // or production() $builder->setHttpClientBuilder(); // optional, for a custom HTTP client $fourApi = $builder->build(); $paymentsClient = $fourApi->getPaymentsClient(); $paymentsClient->refundPayment("payment_id");
The SDK supports client credentials OAuth, when initialized as follows:
$builder = CheckoutFourSdk::oAuth(); $builder->clientCredentials("client_id", "client_secret"); $builder->scopes([FourOAuthScope::$Files, FourOAuthScope::$Flow]); // array of scopes $builder->setEnvironment(Environment::sandbox()); // or production() $builder->setHttpClientBuilder(); // optional, for a custom HTTP client $fourApi = $builder->build(); $paymentsClient = $fourApi->getPaymentsClient(); $paymentsClient->refundPayment("payment_id");
PHP Settings
For operations that require file upload (Disputes or Marketplace) the configuration extension=fileinfo
must be enabled in the php.ini
.
Exception handling
All the API responses that do not fall in the 2** status codes will cause a CheckoutApiException
. The exception encapsulates
the requestId
, httpStatusCode
and a map of errorDetails
, if available.
More documentation related to Checkout API and the SDK is available at:
Building from source
Once you checkout the code from GitHub, the project can be built using composer:
composer update
The execution of integration tests require the following environment variables set in your system:
- For Default account systems:
CHECKOUT_PUBLIC_KEY
&CHECKOUT_SECRET_KEY
- For Four account systems:
CHECKOUT_FOUR_PUBLIC_KEY
&CHECKOUT_FOUR_SECRET_KEY
- For Four account systems (OAuth):
CHECKOUT_FOUR_OAUTH_CLIENT_ID
&CHECKOUT_FOUR_OAUTH_CLIENT_SECRET
Code of Conduct
Please refer to Code of Conduct