jalr/laravelcardconnect

CardConnect CardPointe API 的 PHP 适配器

v2.0 2022-02-26 06:04 UTC

This package is auto-updated.

Last update: 2024-09-26 12:04:22 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);

所有返回字段请参阅 删除配置文件响应

测试


Note: small or large authorization/capture amounts don't seem to work with the test merchant credentials.

## Future stuff
Implement remains service endpoints
- Funding Service
- Signature Capture Service (probably never)
- Open Batch Service
- Close Batch Service
- BIN Service