如何解决为什么这个“检查版本”步骤的实现仍然失败?
阅读 3DSecure GlobalPay documentation 后,我的团队选择通过 JSON 进行集成,使用我们自己的客户端实现,因为我们已经在生产中与另一个 3DS 验证服务进行了另一次集成。无论如何,我们正在使用 Vue.JS 和 Laravel 实现它。
从他们的文档中可以看出,GlobalPay 示例请求是:
curl https://api.sandBox.globalpay-ecommerce.com/3ds2/protocol-versions
-H "Content-type: application/json"
-H "X-GP-VERSION: 2.2.0"
-H "Authorization: securehash 0204a841510d67a46fbd305a60253d7bade32c6e"
-X POST
-d '{
"request_timestamp": "2019-07-30T08:41:07.590604","merchant_id": "MerchantId","account_id": "internet","number": "4263970000005262","scheme": "VISA","method_notification_url": "https://www.example.com/dsNotificationUrl"
}'
我们在 Vue.JS 组件中创建了一个方法来向此版本检查端点发出 POST 请求,如下所示:
methods: {
verifyTds(price) {
this.setTdsAuth(price);
},setTdsAuth() {
let uri = window.tds.globalPay.checkVersion; // https://api.sandBox.globalpay-ecommerce.com/3ds2/protocol-versions
let tdsHeaders = {
'X-GP-Version': '2.2.0','Content-Type': 'application/json','Authorization': `securehash ${this.billing.threeDs.hash}` // from backend,see below
};
let tdsParams = {
request_timestamp: this.billing.threeDs.timestamp,// from backend,see below
merchant_id: "mymerchantid",account_id: "myaccountid",number: parseInt(this.billing.threeDs.pan),// integer,a VISA card from their test cards list: 4263970000005262
scheme: "VISA",// at this moment,hardcoded,I just want to make it work
method_notification_url: window.tds.globalPay.methodNotification // in my case http://website.test/tds/global-pay/method-notification,we created according their sample in the docs too
};
axios.post(uri,{ body: tdsParams },{ headers: tdsHeaders }).then(response => {
console.log(response);
// then finish purchase process
}).catch(error => {
console.log(error); // then handle error
});
},// ...
}
如果这个请求是正确的,我们为 securehash
标头生成的 Authorization
在我们的后端 (PHP) 中计算如下:
<?PHP
// ...
$globalPayMerchantId = 'mymerchantid';
$globalPaySecret = 'mysecret';
$timestamp = Carbon::Now()->toDateTimeLocalString();
$requestTimestamp = Carbon::Now()->format('YmdHisu');
$requestHashNoSecretStr = "{$requestTimestamp}.{$globalPayMerchantId}.{$billing->threeDs->pan}";
$requestHashNoSecret = sha1($requestHashNoSecretStr);
$requestHashStr = "{$requestHashNoSecret}.{$globalPaySecret}";
$requestHash = sha1($requestHashStr);
$billing->threeDs->hash = $requestHash; // sth like 6200480999455e596ad3dfdb89b0a1db601e9216
$billing->threeDs->requestTimestamp = $requestTimestamp; // 20210127155812886962
$billing->threeDs->timestamp = $timestamp; // 2021-01-27T15:58:12
我们基本上尝试按照 GlobalPay 文档 this part 的“如何构建请求哈希”部分中的说明进行操作。
毕竟,我们只是失败了 ERR_CONNECTION_RESET
。我已经尝试过使用不同的浏览器(Firefox、Chrome、Brave),但它一直崩溃。在 Postman 中模拟时,它会产生 415 HTTP 响应(不支持的媒体类型)。
除了仔细检查我们的凭据(商家等,我仍在尝试通过电话进行)之外,还有其他需要验证的地方吗?
解决方法
在致电 GlobalPay 后,他们坚持我应该尝试使用他们的 PHP SDK(最适合我的堆栈的选项)。事实上,我们现在正在使用它,这个检查版本的过程现在正在工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。