为什么这个“检查版本”步骤的实现仍然失败?

问题描述

阅读 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(最适合我的堆栈的选项)。事实上,我们现在正在使用它,这个检查版本的过程现在正在工作。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...