fruitware / victoria-bank-gateway
维多利亚银行电子商务网关商户接口
1.1.0
2019-11-26 04:10 UTC
Requires
- php: >=5.5
- ext-openssl: *
Requires (Dev)
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^2.5
Suggests
- monolog/monolog: ^1.0
This package is auto-updated.
Last update: 2024-09-15 16:21:26 UTC
README
Packagist 包(库)为任何基于 PHP 的网站提供访问维多利亚银行(摩尔多瓦共和国)接口的方式,商户系统使用此接口处理基于标准的 CGI/WWW 表单提交方法的信用卡电子商务交易。此接口透明地支持各种持卡人身份验证协议,如 3-D Secure 和 Secure Code,以及传统的非身份验证 SSL 电子商务交易。
🏠 主页
安装
composer require fruitware/victoria-bank-gateway
要求
- PHP >= 5.5
- OpenSSL >=0.9.8
用法
步骤 1. 环境配置(可选)
您可以使用 composer 包之一
composer require vlucas/phpdotenv
或
composer require symfony/dotenv
.env 文件
# Merchant ID assigned by bank VICTORIA_BANK_MERCHANT_ID=xxxxxxxxxxxxxxx # Merchant Terminal ID assigned by bank VICTORIA_BANK_MERCHANT_TERMINAL=xxxxxxxx # Merchant primary web site URL VICTORIA_BANK_MERCHANT_URL='http://example.com' # Merchant name (recognizable by cardholder) VICTORIA_BANK_MERCHANT_NAME='Merchant company name' # Merchant company registered office address VICTORIA_BANK_MERCHANT_ADDRESS='Merchant address' # Security options - provided by the bank VICTORIA_BANK_SECURITY_SIGNATURE_FIRST='0001' VICTORIA_BANK_SECURITY_SIGNATURE_PREFIX='A00B00C00D00EA864886F70D020505000410' VICTORIA_BANK_SECURITY_SIGNATURE_PADDING='00' # Merchant public rsa key VICTORIA_BANK_MERCHANT_PUBLIC_KEY=public.pem # Merchant private rsa key VICTORIA_BANK_MERCHANT_PRIVATE_KEY=private.pem # The public part of the bank key that P_SIGN is encrypted in the response in PEM format. VICTORIA_BANK_MERCHANT_BANK_PUBLIC_KEY=victoria_pub.pem # Default Merchant shop timezone # Used to calculate the timezone offset sent to VictoriaBank VICTORIA_BANK_MERCHANT_TIMEZONE_NAME='Europe/Chisinau' # Merchant shop 2-character country code. # Must be provided if merchant system is located # in a country other than the gateway server's country. VICTORIA_BANK_MERCHANT_COUNTRY_CODE=MD # Default currency for all operations: 3-character currency code VICTORIA_BANK_MERCHANT_DEFAULT_CURRENCY=MDL # Default forms language # By default are available forms in en, ro, ru. # If need forms in another languages please contact gateway # administrator VICTORIA_BANK_MERCHANT_DEFAULT_LANGUAGE=ro
步骤 2. 初始化网关客户端
通过 configureFromEnv 方法初始化网关客户端
<?php use Fruitware\VictoriaBankGateway\VictoriaBankGateway; $victoriaBankGateway = new VictoriaBankGateway(); $certDir = '/path/to/cert/dir'; $victoriaBankGateway ->configureFromEnv($certDir) ;
手动初始化网关客户端
您可以通过复制 configureFromEnv() 方法的实现
步骤 3. 请求支付授权 - 重定向到银行页面
<?php use Fruitware\VictoriaBankGateway\VictoriaBankGateway; $backRefUrl = getenv('VICTORIA_BANK_MERCHANT_URL').'/after-payment/'; /** @var VictoriaBankGateway $victoriaBankGateway */ $victoriaBankGateway ->requestAuthorization($orderId = 1, $amount = 1, $backRefUrl, $currency = null, $description = null, $clientEmail = null, $language = null) ;
步骤 4. 接收银行响应 - 所有银行响应都是异步服务器到服务器,并由相同的 URI 处理
<?php use Fruitware\VictoriaBankGateway\VictoriaBankGateway; use Fruitware\VictoriaBankGateway\VictoriaBank\Exception; use Fruitware\VictoriaBankGateway\VictoriaBank\Response; use Fruitware\VictoriaBankGateway\VictoriaBank\AuthorizationResponse; /** @var VictoriaBankGateway $victoriaBankGateway */ $bankResponse = $victoriaBankGateway->getResponseObject($_POST); if (!$bankResponse->isValid()) { throw new Exception('Invalid bank Auth response'); } switch ($bankResponse::TRX_TYPE) { case VictoriaBankGateway::TRX_TYPE_AUTHORIZATION: $amount = $bankResponse->{Response::AMOUNT}; $bankOrderCode = $bankResponse->{Response::ORDER}; $rrn = $bankResponse->{Response::RRN}; $intRef = $bankResponse->{Response::INT_REF}; # # You must save $rrn and $intRef from the response here for reversal requests # # Funds locked on bank side - transfer the product/service to the customer and request completion $victoriaBankGateway->requestCompletion($bankOrderCode, $amount, $rrn, $intRef, $currency = null); break; case VictoriaBankGateway::TRX_TYPE_COMPLETION: # Funds successfully transferred on bank side break; case VictoriaBankGateway::TRX_TYPE_REVERSAL: # Reversal successfully applied on bank size break; default: throw new Exception('Unknown bank response transaction type'); }
步骤 5. 请求退款
$rrn
和 $intRef
必须在步骤 4 中保存
<?php use Fruitware\VictoriaBankGateway\VictoriaBankGateway; /** @var VictoriaBankGateway $victoriaBankGateway */ $victoriaBankGateway ->requestReversal($orderId = 1, $amount = 1, $rrn = 'xxx', $intRef = 'yyy', $currency = null) ;
作者
👤 由 Fruitware 团队精心制作
- Twitter: @fruitware
- Github: @fruitware
🤝 贡献
欢迎贡献、问题报告和功能请求!
请随意查看 问题页面。
展示您的支持
如果此项目对您有帮助,请给一个 ⭐!