fruitware / php-victoriabank-payment
Victoriabank支付网关集成
1.3
2016-12-08 16:39 UTC
Requires
- php: >=5.3.5
This package is auto-updated.
Last update: 2024-09-04 01:47:37 UTC
README
需求
- PHP > 5.4
用法
######请求授权和完成使用Terranet\Payment; $bankPaymentGateway = new Victoriabank();
//Set basic info
$bankPaymentGateway
->setMerchantName('Your company name')
->setMerchantAddress('Your company address')
->setMerchantUrl('http://' . $_SERVER['HTTP_HOST'])
->setTimezoneName('Europe/Chisinau')
->setLanguage('ro')
->setCountryCode('md')
->setBackRefUrl('https://' . $_SERVER['HTTP_HOST'] . '/after-payment')
;
//Set security options - provided by the bank
$bankPaymentGateway
->setSecurityOptions($signatureFirst, $signaturePrefix, $signaturePadding, $publicKeyPath, $privateKeyPath, $bankPublicKeyPath)
;
//Request payment authorization - redirects to the banks page
$bankPaymentGateway
->requestAuthorization($amount, $code, $paymentDescription, $email)
;
######请求撤销 //请求支付撤销 $bankPaymentGateway ->requestReversal($amount,$orderId,$rrn,$intRef) ;
######接收银行响应 - 所有银行响应都是异步服务器到服务器,并由相同的URI处理
$bankResponse = $bankPaymentGateway->getResponseObject($_POST);
if (!$bankResponse->isValid())
throw new Victoriabank\Exception('Invalid bank Auth response');
switch ($bankResponse::TRX_TYPE) {
case Victoriabank::TRX_TYPE_AUTHORIZATION:
$amount = $bankResponse->{Victoriabank\Authorization_Response::AMOUNT};
$bankOrderCode = $bankResponse->{Victoriabank\Response::ORDER};
$rrn = $bankResponse->{Victoriabank\Response::RRN};
$intRef = $bankResponse->{Victoriabank\Response::INT_REF};
#Funds locked on bank side - transfer the product/service to the customer and request completion
$bankPaymentGateway->requestCompletion($amount, $bankOrderCode, $rrn, $intRef);
break;
case Victoriabank::TRX_TYPE_COMPLETION:
#Funds successfully transferred on bank side
break;
case Victoriabank::TRX_TYPE_REVERSAL:
#Reversal successfully applied on bank size
break;
default:
throw new Exception('Unknown bank response transaction type');
}
安装
通过Composer
将以下行(仅根目录)添加到您的composer.json中
"repositories": [
{
"type": "vcs",
"url": "https://github.com/TerranetMD/php-victoriabank-payment"
}
]
运行
composer update
通过GitHub
git clone https://github.com/TerranetMD/php-victoriabank-payment