dewbud / cardconnect
CardConnect CardPointe API 的 PHP 适配器
2.1.0
2021-02-04 06:17 UTC
Requires
- php: ^7.3
- ext-json: *
- guzzlehttp/guzzle: ^6.5|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-09 13:32:43 UTC
README
初始化中
$merchant_id = '123456123456'; $user = 'username'; $pass = 'password'; $server = 'https://sub.domain.tld:1111/'; $client = new CardPointe($merchant_id, $user, $pass, $server);
测试凭证
$boolean = $client->testAuth();
验证商户 ID
$boolean = $client->validateMerchantId();
调整
响应被解析,金额字段以分(int)的形式返回。
客户端将最后请求存储为 array
$client->last_request
,可用于调试请求。
响应对象
响应以对象形式返回,可以作为数组访问。
$response = $client->inquire($retref); $response->amount; // returns int $response->toJSON(); // Returns JSON encoded string, accepts format codes (JSON_PRETTY_PRINT, etc) $response->toArray(); // Returns array of attributes
授权交易
$request = new AuthorizationRequest([ 'account' => '4242424242424242', 'amount' => '100', 'expiry' => '0120', ]); $authorization_response = $client->authorize($request);
您还可以像这样在同一个请求中授权和捕获
$request = new AuthorizationRequest([ 'account' => '4242424242424242', 'amount' => '100', 'expiry' => '0120', 'capture' => 'Y', // OR 'capture' => true, 'profile' => 'Y', // OR 'profile' => true, ]); $capture_response = $client->authorize($request);
您还可以使用带有 PROFILE_ID/ACCOUNT_ID 的已保存卡在同一个请求中授权和捕获
$request = new AuthorizationRequest([ 'account' => '4242424242424242', 'amount' => '100', 'expiry' => '0120', 'capture' => 'Y', // OR 'capture' => true, 'profile' => "$profile_id/$account_id", // using a profile/account ]); $capture_response = $client->authorize($request);
要查看所有可用字段,请参阅 授权请求
所有返回字段请参阅 授权响应
捕获交易
$auth_retref = '123456654321'; $params = []; // optional $capture_response = $client->capture($auth_retref, $params);
要查看所有可用字段,请参阅 捕获请求
所有返回字段请参阅 捕获响应
作废交易
$auth_retref = '123456654321'; $params = []; // optional $void_response = $client->void($auth_retref, $params);
要查看所有可用字段,请参阅 作废请求
所有返回字段请参阅 作废响应
退款交易
$capture_retref = '123456654321'; $params = []; // optional $void_response = $client->refund($capture_retref, $params);
要查看所有可用字段,请参阅 退款请求
所有返回字段请参阅 退款响应
交易状态
$retref = '123456654321'; $inquire_response = $client->inquire($retref);
所有返回字段请参阅 查询响应
结算状态
$date = '0118'; $settlements = $client->settleStat($date); $first_settlement = $settlements[0];
所有返回字段请参阅 结算响应
创建/更新配置文件
// update a profile by providing 'profile' => $profile_id in the request $request = [ 'defaultacct' => "Y", 'account' => "4444333322221111", 'expiry' => "0914", 'name' => "Test User", 'address' => "123 Test St", 'city' => "TestCity", 'region' => "TestState", 'country' => "US", 'postal' => "11111", ]; $res = $client->createProfile($request);
所有返回字段请参阅 创建/更新配置文件请求
获取配置文件
$profile_id = '1023456789'; $account_id = null; // optional $profile = $client->profile($profile_id, $account_id);
所有返回字段请参阅 配置文件响应
删除配置文件
$profile_id = '1023456789'; $account_id = null; // optional $profile = $client->deleteProfile($profile_id, $account_id);
所有返回字段请参阅 删除配置文件响应
测试
composer test
注意:小或大的授权/捕获金额似乎与测试商户凭证不兼容。
未来功能
实现剩余的服务端点
- 资金服务
- 签名捕获服务(可能永远不会)
- 打开批次服务
- 关闭批次服务
- BIN 服务