corvuspay/corvuspay_wallet_php_sdk
Composer 安装命令:
composer require corvuspay/corvuspay_wallet_php_sdk
包简介
CorvusPay Wallet PHP SDK
README 文档
README
After downloading the project, add it as a dependancy to your application.
require_once('/path/to/init.php');
or use composer
Composer is a package manager for PHP. In the composer.json file in your project add:
{
"require": {
"corvuspay/corvuspay_wallet_php_sdk": "*"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/corvuspay/corvuspay_wallet_php_sdk.git"
}
]
}
And then in the file where you want to use the library write:
require_once('/path/to/init.php');
Dependencies
The bindings require the following extensions in order to work properly:
- ext-mbstring
- ext-json
- ext-openssl
- ext-posix
- ext-curl
- psr/log
- ext-simplexml
- monolog/monolog
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Getting Started
Simple usage for basic checkout looks like:
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $params = [ 'order_number' => "order_number", 'language' => "language", 'currency' => "currency", 'amount' => "amount", 'cart' => "cart", 'require_complete' => "require_complete" ]; $client->checkout->create($params, 'auto');
Optional parameters are:
- cardholder_name
- cardholder_surname
- cardholder_address
- cardholder_city
- cardholder_zip_code
- cardholder_country
- cardholder_phone
- cardholder_email
- subscription
- number_of_installments
- payment_all
- payment_all_dynamic
- payment_amex
- payment_diners
- payment_dina
- payment_visa
- payment_master
- payment_maestro
- payment_discover
- payment_jcb
- installments_map
- cc_type
- cardholder_country_code
- hide_tabs
- creditor_reference
- debtor_iban
- best_before
- discount_amount
Example for cancelling a preauthorized transaction
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number" ]; $client->transaction->cancel($params);
Example for completing a preauthorized transaction
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number" ]; // or if you are completing a transaction with subscription $params = [ 'order_number' => "order_number", 'subscription' => "true", 'account_id' => "account_id" ]; $client->transaction->complete($params);
Example for partially completing a preauthorized transaction
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number", 'new_amount' => "new_amount", 'currency' => "currency" ]; $client->transaction->partiallyComplete($params);
Example for refunding a transaction
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number" ]; $client->transaction->refund($params);
Example for partially refunding a transaction
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number", 'new_amount' => "new_amount", 'currency' => "currency" ]; $client->transaction->partiallyRefund($params);
Example for charging the next subscription payment
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number", 'account_id' => "account_id" ]; // or if you want to pay the order with new amount $params = [ 'order_number' => "order_number", 'account_id' => "account_id", 'new_amount' => "new_amount", 'currency' => "currency" ]; $client->subscription->pay($params);
Example for checking transaction status
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number", 'currency_code' => "currency_code" ]; $client->transaction->status($params);
Example for checking PIS transaction status
$config = ['store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment"]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number", 'currency_code' => "currency_code" ]; $client->pisTransaction->status($params);
Configuring a Logger
It can be configured with a PSR-3 compatible logger for example with MonologLogger:
$logger = new Monolog\Logger('Test'); $logger->pushHandler(new Monolog\Handler\StreamHandler(__DIR__ . '/app.log', Monolog\Logger::DEBUG)); $config = [ 'store_id' => "store_id", 'secret_key' => "secret_key", 'environment' => "environment", 'logger' => $logger ]; $client = new CorvusPay\CorvusPayClient($config); $fp = fopen("path/to/file", 'r'); $client->setCertificate($fp, "certificate_password"); $params = [ 'order_number' => "order_number" ]; $client->transaction->refund($params);
Images
The images used in this library can be found on the official CorvusPay website.
Documentation
See the integration manual for more information.
corvuspay/corvuspay_wallet_php_sdk 适用场景与选型建议
corvuspay/corvuspay_wallet_php_sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38.06k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 corvuspay/corvuspay_wallet_php_sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 corvuspay/corvuspay_wallet_php_sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 38.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-15