v1.0.2 2017-11-05 18:28 UTC

This package is not auto-updated.

Last update: 2024-09-25 02:11:14 UTC


README

安装

$ composer require agile-pay/sdk

使用

$agilePay = new \AgilePay\Sdk\AgilePay([
    'api_key' => '',
    'api_secret' => ''
]);

网关

创建新的网关

$gateway = $agilePay->gateway()->create('stripe', [
    'secret_key' => ''
]);

响应将包含一个网关引用,该引用用于对网关进行交易

$gateway->reference;

支付方式

创建新的支付方式类型为网关令牌

在这种情况下,支付方式将与提供的网关保留,请检查网关中的交易存储是否可用

网关列表 -> http://docs.agilepay.io/#!/gateway

网关令牌 -> http://docs.agilepay.io/#!/payment-method-create-gateway-token

$paymentMethod = $agilePay->paymentMethod()->createGatewayToken($gateway->reference, [
    'number' => '',
    'holder_name' => '',
    'cvv' => '',
    'expiry_month' => '', //mm
    'expiry_year' => '',  //yy
]);

响应将包含一个支付方式令牌,该令牌用于对支付方式进行交易

$paymentMethod->token;

交易

授权(使用网关令牌类型的支付方式对信用卡进行收费)

$transaction = $agilePay->transaction()
                ->setPaymentMethod($paymentMethod->token;)
                ->auth(500, 'eur'); //Charging 5.00 euros

响应将包含一个可用于第二步交易的引用,例如进行取消结算退款

$transaction->reference;

取消(取消授权的交易)

$response = $agilePay->transaction($transaction->reference)->void();

结算(对授权的交易进行结算)

$response = $agilePay->transaction($transaction->reference)->capture();

退款(对已结算的交易进行退款)

$response = $agilePay->transaction($transaction->reference)->credit();