corvuspay / corvuspay_wallet_php_sdk
CorvusPay 钱包 PHP SDK
1.4.3
2024-04-15 08:04 UTC
Requires
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-posix: *
- ext-simplexml: *
- psr/log: *
Requires (Dev)
README
下载项目后,将其添加为应用程序的依赖项。
require_once('/path/to/init.php');
或使用 Composer
Composer 是 PHP 的包管理器。在项目中的 composer.json 文件中添加
{ "require": { "corvuspay/corvuspay_wallet_php_sdk": "*" }, "repositories": [ { "type": "git", "url": "https://github.com/corvuspay/corvuspay_wallet_php_sdk.git" } ] }
然后,在您想使用库的文件中写入
require_once('/path/to/init.php');
依赖
绑定需要以下扩展才能正常运行
- ext-mbstring
- ext-json
- ext-openssl
- ext-posix
- ext-curl
- psr/log
- ext-simplexml
- monolog/monolog
如果您使用 Composer,这些依赖项应自动处理。如果您手动安装,请确保这些扩展可用。
入门指南
基本结账的简单用法如下
$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');
可选参数包括
- 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
取消预先授权交易示例
$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);
完成预先授权交易示例
$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);
部分完成预先授权交易示例
$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);
退款交易示例
$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);
部分退款交易示例
$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);
收取下一次订阅付款示例
$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);
检查交易状态示例
$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);
检查 PIS 交易状态示例
$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);
配置日志记录器
可以使用 PSR-3 兼容的日志记录器进行配置,例如使用 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);
图片
此库中使用的图片可在官方 CorvusPay 网站找到。
文档
有关更多信息,请参阅集成手册。