haykkarapetyan / omnipay-ameriabank
美洲银行包
1.0.0
2018-07-04 07:55 UTC
This package is not auto-updated.
Last update: 2024-09-20 19:25:00 UTC
README
Ameriabank 驱动程序,用于 Omnipay Laravel 支付处理库
Omnipay 是一个针对 PHP 5.5+ 的无框架、多网关支付处理库。此包实现了 Omnipay 的 iDram 支持。
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
{ "require": { "haykkarapetyan/omnipay-ameriabank": "dev-master" } }
然后运行 composer 更新依赖项
composer update
或者您可以直接运行
composer require haykkarapetyan/omnipay-ameriabank
基本用法
- 使用 Omnipay 网关类
use Omnipay\Omnipay;
- 初始化 Ameriabank 网关
$gateway = Omnipay::create('Ameriabank'); $gateway->setClientId('Client_ID'); // Shoud be your Ameriabank Client ID (e.g. 7e7ef8ff-6300-4a78-bb31-3ad1a8c67d5f) $gateway->setUsername('Username'); // Should be your Ameria Username $gateway->setPassword('Password'); // Should be your Ameria password $gateway->setOpaque('Opaque'); // Is not mandatory field and used as additional information during information exchange $gateway->setOrderId('Order_ID'); // Is randomly generated ID. Integer which is generated by using system local time e.g. time() $gateway->setCurrency('AMD'); // Uses national currency e.g. AMD, USD, EUR $gateway->setTestMode(false); // Boolean and can be only true or false $payment = $gateway->purchase([ 'amount' => '100', 'returnUrl' => 'http://example.com/xxx', // The URL to which you will be redirected after completing the purchase. Please also refer to poin 4 below 'description' => 'Description ...' ] )->createPaymentRequest();
- 处理支付
在支付请求批准后,调用接收正或负响应
if (empty($payment->GetPaymentIDResult->PaymentID) || $payment->GetPaymentIDResult->Respmessage != 'OK') { return $payment->GetPaymentIDResult; // in case if response was negative (rejected). } else { $gateway->setPaymentId($payment->GetPaymentIDResult->PaymentID); //if positive, call receive payment ID $gateway->setClientUrl("http://example.com/ameriarequestframe.aspx"); // Setting /ameriarequestframe.aspx inside your site $gateway->setLanguage('en'); $response = $gateway->purchase()->send(); // generate unique URL return [ 'redirectUrl' => $response->getRedirectUrl() // redirection to previously generated unique URL ]; }
- 完成支付
您将被重定向到 AmeriaBank VPOS 表单页面。填写并提交信用卡数据后,AmeriaBank 页面将通过 webhook http://example.com/xxx(也请参考第 2 点)
$gateway = Omnipay::create('Ameriabank'); $gateway->setClientId('Client_ID'); // Shoud be your Ameriabank Client ID (e.g. 7e7ef8ff-6300-4a78-bb31-3ad1a8c67d5f) $gateway->setUsername('Username'); // Should be your Ameria Username $gateway->setPassword('Password'); // Should be your Ameria password $gateway->setOrderId('Order_ID'); // Is randomly generated ID. Integer which is generated by using system local time e.g. time() $gateway->setTestMode(false); // Boolean and can be only true or false $$webService = $gateway->completePurchase([ 'amount' => '100' ] )->getPaymentFields(); if ($paymentFields = $webService->GetPaymentFieldsResult) { // Your logic return $paymentFields; } return $webService; // Return error text in case of connection errors
出于测试目的,您应仅使用 AMD 货币,并且费用不超过 10 AMD
有关一般使用说明,请参阅主 Omnipay 存储库。
支持
如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发布。请务必添加 omnipay 标签,以便它更容易被发现。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您已经发现了一个错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,fork 库并提交一个 pull request。