checkout / checkout-sdk-php
Checkout.com SDK for PHP
Installs: 2 121 436
Dependents: 5
Suggesters: 0
Security: 0
Stars: 48
Watchers: 13
Forks: 40
Open Issues: 2
Requires
- php: >=5.6.0
- ext-fileinfo: *
- ext-json: *
- guzzlehttp/guzzle: ^6.5 || ^7.4
- monolog/monolog: ^1.27 || ^2.4 || ^3.0.0
Requires (Dev)
- mockery/mockery: ^1.3 || ^1.4
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^5.7 || ^9.0
- smgladkovskiy/phpcs-git-pre-commit: dev-master
- squizlabs/php_codesniffer: ^3.3
- symfony/phpunit-bridge: ^5.2 || ^6.0
- dev-master
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- v2.x-dev
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 2.0.0-beta6
- 2.0.0-beta5
- 2.0.0-beta4
- 2.0.0-beta3
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.6
- 1.0.5
- 1.0.3
- 1.0.2
- 1.0.0
- dev-release/3.2.7
- dev-release/3.0.17
- dev-release/3.0.16
- dev-bugfix/INT-1362-php-fix-property
- dev-release/3.0.15
- dev-feature/INT-1347-php-funds-transfer-type-missing-in-payment-intruction-class
- dev-release/3.0.14
- dev-feature/INT-1335-missing-account-holder-in-destination-id-type-in-request-payout
- dev-feature/update-readme
- dev-release/3.0.13
- dev-feature/INT-1259-issuing-api-updates
- dev-release/3.0.12
- dev-feature/INT-1239
- dev-release/3.0.11
- dev-feature/INT-1012-reports-api-redirect-support
- dev-feature/INT-1182-api-updates
- dev-release/3.0.10
- dev-feature/giropay_updates
- dev-p24
- dev-legacy
This package is auto-updated.
Last update: 2024-11-20 09:34:10 UTC
README
Getting started
Version 3.0.0 is here!
We improved the initialization of SDK making it easier to understand the available options.
NowNAS
accounts are the default instance for the SDK andABC
structure was moved to aprevious
prefixes.
If you have been using this SDK before, you may find the following important changes:
- Marketplace module was moved to Accounts module, same for classes and references.
- In most cases, IDE can help you determine from where to import, but if youβre still having issues don't hesitate to open a ticket.
π Please check in GitHub releases for all the versions available.
π Checkout our official documentation.
π Check out our official API documentation guide, where you can also find more usage examples.
Composer
{ "require": { "php": ">=5.6", "checkout/checkout-sdk-php": "version" } }
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.
Note: sandbox keys have a sbox_
or test_
identifier, for Default and Previous 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:
$checkoutApi = CheckoutSdk::builder()->staticKeys() ->publicKey("public_key") // optional, only required for operations related with tokens ->secretKey("secret_key") ->environment(Environment::sandbox()) // or production() ->environmentSubdomain("subdomain") // optional, Merchant-specific DNS name ->logger($logger) //optional, for a custom Logger ->httpClientBuilder($client) // optional, for a custom HTTP client ->build(); $paymentsClient = $checkoutApi->getPaymentsClient(); $paymentsClient->refundPayment("payment_id");
Default OAuth
The SDK supports client credentials OAuth, when initialized as follows:
$checkoutApi = CheckoutSdk::builder()->oAuth() ->clientCredentials("client_id", "client_secret") ->scopes([OAuthScope::$Gateway, OAuthScope::$Vault]) // array of scopes ->environment(Environment::sandbox()) // or production() ->environmentSubdomain("subdomain") // optional, Merchant-specific DNS name ->logger($logger) //optional, for a custom Logger ->httpClientBuilder($client) // optional, for a custom HTTP client ->build(); $paymentsClient = $checkoutApi->getPaymentsClient(); $paymentsClient->refundPayment("payment_id");
Previous
If your pair of keys matches the Previous type, this is how the SDK should be used:
$checkoutApi = CheckoutSdk::builder() ->previous() ->staticKeys() ->environment(Environment::sandbox()) // or production() ->environmentSubdomain("subdomain") // optional, Merchant-specific DNS name ->publicKey("public_key") // optional, only required for operations related with tokens ->secretKey("secret_key") ->logger($logger) //optional, for a custom Logger ->httpClientBuilder($client) // optional, for a custom HTTP client ->build(); $paymentsClient = $checkoutApi->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, the SDK will throw a CheckoutApiException
.
The exception encapsulates http_metadata
and $error_details
, if available.
Building from source
Once you check out 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 (NAS):
CHECKOUT_DEFAULT_PUBLIC_KEY
&CHECKOUT_DEFAULT_SECRET_KEY
- For default account systems (OAuth):
CHECKOUT_DEFAULT_OAUTH_CLIENT_ID
&CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET
- For Previous account systems (ABC):
CHECKOUT_PREVIOUS_PUBLIC_KEY
&CHECKOUT_PREVIOUS_SECRET_KEY
Code of Conduct
Please refer to Code of Conduct