vahanspetrosyan/omnipay-vpos-ameriabank

v1.0.0 2019-12-27 12:58 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:58 UTC


README

Ameriabank 为 Omnipay Laravel 支付处理库提供的驱动程序

Omnipay 是一个与框架无关的多网关支付处理库,适用于 PHP 5.5+。此包实现了 Omnipay 的 iDram 支持。

安装

Omnipay 通过 Composer 安装。要安装,您可以简单地运行

composer require vahanspetrosyan/omnipay-vpos-ameriabank

基本用法

  1. 使用 Omnipay 网关类
use Omnipay\Omnipay;
  1. 初始化 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();
  1. 处理支付
    在支付请求批准后,调用接收正面或负面响应
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 
    ];
}
  1. 完成支付
    您将被重定向到 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 仓库。

支持