Braintree Google 支付沙箱打开实时域

Braintree Google Pay sandbox opens live domain

我正在尝试在我的页面上集成 Google 支付,正如预期的那样,首先在沙盒环境中这样做,但我遇到了一个问题,当我单击 Google 支付按钮时,它会打开实时域并要求我输入真实卡,虽然我设置了所有与沙盒环境相关的内容。

这是 BT documentation.

之后的代码
  var createGooglePaymentComponent = function(clientInstance){
    var button = document.querySelector('#google-pay-button');
    var paymentsClient = new google.payments.api.PaymentsClient({
      environment: 'TEST' // Or 'PRODUCTION'
    });

    braintree.googlePayment.create({
      client: clientInstance,
      googlePayVersion: 2,
    }, function (googlePaymentErr, googlePaymentInstance) {
      paymentsClient.isReadyToPay({
        apiVersion: 2,
        apiVersionMinor: 0,
        allowedPaymentMethods: googlePaymentInstance.createPaymentDataRequest().allowedPaymentMethods,
      }).then(function(response) {
        if (response.result) {
          button.addEventListener('click', function (event) {
            event.preventDefault();

            var paymentDataRequest = googlePaymentInstance.createPaymentDataRequest({
              transactionInfo: {
                currencyCode: 'USD',
                totalPriceStatus: 'FINAL',
                totalPrice: '100.00',
              }
            });
            var cardPaymentMethod = paymentDataRequest.allowedPaymentMethods[0];
            cardPaymentMethod.parameters.billingAddressRequired = true;

            paymentsClient.loadPaymentData(paymentDataRequest).then(function(paymentData) {
              googlePaymentInstance.parseResponse(paymentData, function (err, result) {
                if (err) {
                  // Handle parsing error
                }
                // Send result.nonce to your server
              });
            }).catch(function (err) {
            });
          });
        }
      }).catch(function (err) {
      });
    });
  };

这是我得到的截图:

知道为什么会这样吗?

在 TEST 环境中使用 Google Pay 将 return 一个 TEST 付款凭据,它实际上不会通过您提供的付款方式收费。您不想使用 真实 付款详情是可以理解的。

如果您希望能够从预定义的测试卡列表中进行选择,请按照此处的说明进行操作:https://developers.google.com/pay/api/web/guides/resources/test-card-suite

简而言之,您将需要加入 googlepay-test-mode-stub-data Google Group,当访问该用户的 Google 付款 sheet 时,它将显示测试帐户列表。