ampeco / omnipay-fibank
Omnipay插件,用于fibank ECOMM循环付款
1.3.2
2024-01-31 11:35 UTC
Requires
- php: ^7.2|^8.0
- ext-curl: *
- omnipay/common: ^3
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0
README
Omnipay 插件,用于 fibank ECOMM 循环付款
安装
composer require ampeco/omnipay-fibank
入门
创建网关
$gateway = Omnipay::create('\Ampeco\OmnipayFibank\Gateway'); $gateway->initialize([ 'merchantCertificate' => '... The PEM certificate you got from the bank', 'merchantCertificatePassword' => 'The Certificate Password', 'createCardAmount' => 1.00, // The amount and currency to use for the create account initial payment 'createCardCurrency' => 'BGN', 'testMode' => true, ]);
添加新的信用卡
try{ $response = $gateway->createCard([ 'clientIp' => 'CLIENT IP ADDRESS', 'expiry' => date('Y-m-d', strtotime('+10 years')), 'description' => 'Register a new payment method. The amount will be credited to your account', ])->send(); } catch (EcommException $e) { abort(422, $e->getMessage()); } if (!$response->isSuccessful()) { abort(422, $response->getMessage()); } // You must redirect the client to: echo $response->getRedirectUrl(); echo $response->getTransactionId(); // The transaction ID assigned by the bank
检查客户是否完成了卡注册
$transactionReference = '1234567890'; // Fetched from above - $response->getTransactionId() try { $result = $gateway->transactionResult([ 'transactionId' => $transactionReference, 'clientIp' => 'CLIENT IP ADDRESS', ])->send(); } catch (EcommException $e) { abort(422, $e->getMessage()); } if (!$result->isSuccessful()){ abort(422, $result->getMessage()); } // The card reference echo $result->getCardReference(); // recurring_test_reference1234`
对已保存的信用卡参考进行收费
try { $cardReference = 'recurring_test_reference1234'; // saved from above - $result->getCardReference(); $response = $gateway->purchase([ 'cardReference' => $cardReference, 'amount' => 3, 'currency' => 'BGN', 'description' => 'Purchase #1234', ])->send(); } catch (EcommException $e) { abort(422, $e->getMessage()); } if ($response->isSuccessful()) { echo $response->getTransactionReference(); } else { abort(422, $response->getMessage()); }