codechap / mygate
此包已被弃用且不再维护。未建议替代包。
mygate.co.za 的 PHP 集成
dev-master
2016-05-11 16:06 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2023-02-07 10:18:48 UTC
README
注意!包处于开发阶段,不可使用!
MyGate 的令牌化 - 企业解决方案消除了商户存储卡数据的需要。该解决方案使用商户托管支付页面。通过用唯一的令牌替换卡详细信息,商户可以降低存储卡数据的风险。使用令牌,商户可以使用仅需要持卡人输入 CVV 号码的支付页面。
免责声明
使用此库风险自负,我对此不承担任何责任!
金钱使世界运转
确保您与 myGate 联系关于一键企业选项,在集成一键企业选项之前,您或您的客户可能需要考虑设置成本。
用法
从 myGate 获取 merchant_id、app_name 和 app_id。您需要作为开发者或商户进行注册。
使用 composer 通过您的 composer.json 文件在框架中安装它
"require": {
"codechap/mygate": "dev-master"
}
或简单地包含所需的文件
require("mygate/src/Mygate/connection.php");
require("mygate/src/Mygate/card.php");
您可以使用以下测试信用卡来测试您的实现
$testCards = array(
// Visa Successful
array(
'cardholder' => 'Joe Soap',
'cardnumber' => '4111111111111111',
'expirymonth' => '10',
'expiryyear' => '2015',
'cvv' => '123'
),
// Visa Declined
array(
'cardholder' => 'Joe Soap',
'cardnumber' => '4242424242424242',
'expirymonth' => '10',
'expiryyear' => '2015',
'cvv' => '123'
)
);
连接到 myGate
创建与 myGate 的连接对象
// Open the gateway
$connect = new Mygate\Connection(
array(
'merchant_id' => 'Your-merchant-id-here',
'app_name' => 'Your-app-name-here',
'app_id' => 'Your-app-id-here'
)
);
新的和初次支付
首先创建并令牌化一张信用卡。您需要将令牌记录在数据库中,与用户对应。这个令牌和信用卡持有者的 CVV 号码就是您将来收取款项所需的所有信息
// Create a new credit card and myGate connection details
$card = new Mygate\Card($testCards[0], $connect);
// Create and send the generated token to myGate and store the token in your database against a user.
$token = $card->tokenize();
// First time payment of R1200 over twelve months
$card->pay("1200.00", "First Test Payment", "12");
第二次支付
现在您有了令牌,您可以更容易地收集同一用户的下一次支付
// Repeat or return customer payment.
$card = new Mygate\Card($token, $connect);
$card->setCvv('123'); // Client only needs to enter the CVV number
$card->pay("100.00", "Second test payment");
从 myGate 注销卡
这将从 myGate 中删除该卡,令牌化过程需要重复。
$card = new Mygate\Card($token, $connect);
$card->forget();