checkout/checkout-sdk-php
Composer 安装命令:
composer require checkout/checkout-sdk-php
包简介
Checkout.com SDK for PHP
关键字:
README 文档
README
Getting started
Version 4.0.0 is here!
We improved the initialization of SDK making it easier to understand the available options.
NowNASaccounts are the default instance for the SDK andABCstructure was moved to apreviousprefixes.
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.
⚠️ PHP version support
As of v5.0.0, this SDK requires PHP 8.1 or newer. Support for PHP 7.1 and 7.4 has been dropped.
This change is required because the SDK now depends on guzzlehttp/guzzle:^7.4 (and guzzlehttp/promises:^2.0), which require PHP 8.0+. Older Guzzle and PHPUnit releases that supported PHP 7.x are affected by security advisories that make them unsuitable for a payment SDK.
If you are still on PHP 7.x, remain on the latest 4.x release until you can upgrade your runtime to PHP 8.1+.
Composer
{
"require": {
"php": ">=8.1",
"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.
| Account System | Public Key (example) | Secret Key (example) |
|---|---|---|
| Default | pk_zyxwabcde123pqrstu876vwxyt | sk_abcdef98765mnopqr4321ghijk |
| Previous | pk_f3456789-ab12-cd34-ef56-7890ghijklmn | sk_hijklmn0-1234-5678-abcd-efgh98765432 |
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. File paths passed to the SDK must be controlled by your application (e.g. from validated uploads); do not use paths taken directly from untrusted user input.
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
Licensing
checkout/checkout-sdk-php 适用场景与选型建议
checkout/checkout-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.57M 次下载、GitHub Stars 达 56, 最近一次更新时间为 2019 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「library」 「payment」 「checkout」 「sdk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 checkout/checkout-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 checkout/checkout-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 checkout/checkout-sdk-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 3.57M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 56
- 点击次数: 28
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-31