ampeco/omnipay-bankart

Bankart Omnipay 插件

1.0.5 2024-02-17 09:48 UTC

This package is auto-updated.

Last update: 2024-09-17 11:15:01 UTC


README

Omnipay 插件,用于 bankart

安装

composer require ampeco/omnipay-bankart

入门指南

创建网关

$gateway = Omnipay::create('\Ampeco\OmnipayBankart\Gateway');
$gateway->initialize([
    'username'           => 'Your API username',
    'password'           => 'Your API password',
    'apiKey'             => 'Your API key',
    'sharedSecret'       => 'Your API shared secret',
]);

添加新的信用卡

$response = $gateway->createCard([
        'transaction_id' => uniqid('', true),
        'description' => 'Description',
        'return_url' => 'https://your-return-url',
        'notify_url' => 'https://your-notify-url',
        'customer' => [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'identification' => 1,
            'email' => 'john@example.com',
            'billingAddress1' => 'None',
            'billingCity' => 'Unknown',
            'billingCountry' => 'NA',
            'billingPostcode' => '0000',
        ]
])->send();

if (!$response->isSuccessful()) {
    abort(422, $response->getMessage());
}

// You must redirect the client to:
echo $response->getRedirectUrl();
echo $response->getTransactionReference(); // The transaction ID assigned by the bank

检查客户端是否完成了卡注册

$transactionReference = '1234567890'; // Fetched from above - $response->getTransactionReference()

$result = $gateway->fetchTransaction([
    'transactionReference' => $transactionReference,
])->send();

if (!$result->isSuccessful()){
    abort(422, $result->getMessage());
}

扣款已保存的信用卡参考

$transactionReference = '1234567890'; // saved from above - $transactionReference;
$response = $gateway->purchase([
    'cardReference'     => $transactionReference,
    'amount'            => 3,
    'currency'          => 'EUR',
    'description'       => 'Purchase #1234',
])->send();

if ($response->isSuccessful()) {
    echo $response->getTransactionReference();
    
} else {
    abort(422, $response->getMessage());
}