没有可供该商家使用的可接受银行卡 - Google Pay

2024-02-16

我正在尝试将 Google Pay 网络集成到我的网站中,但是当我单击“使用 googlepay 付款”时,它显示以下错误:

该商户没有可使用的可接受的银行卡。

当我阅读文档时,它说您可以添加示例作为商家进行测试,我只想使用测试环境,但它仍然不起作用。

这是我正在使用的代码:

const allowedAuthMethods = ['PAN_ONLY','CRYPTOGRAM_3DS'] ;

const baseCardPaymentMethod = {
  type: 'CARD',
  parameters: {
    allowedCardNetworks: allowedNetworks,
    allowedAuthMethods: allowedAuthMethods 
  }
};

const googlePayBaseConfiguration = {
  apiVersion: 2,
  apiVersionMinor: 0,
  allowedPaymentMethods: [baseCardPaymentMethod]
};

/**
 * Holds the Google Pay client used to call the different methods available
 * through the API.
 * @type {PaymentsClient}
 * @private
 */
let googlePayClient;

/**
 * Defines and handles the main operations related to the integration of
 * Google Pay. This function is executed when the Google Pay library script has
 * finished loading.
 */
function onGooglePayLoaded() {
  googlePayClient = new google.payments.api.PaymentsClient({
        environment: 'TEST'
    });

  googlePayClient.isReadyToPay(googlePayBaseConfiguration)
  .then(function(response) {
    if(response.result) {
      createAndAddButton();
    } else {
      alert("Unable to pay using Google Pay");
    }
  }).catch(function(err) {
    console.error("Error determining readiness to use Google Pay: ", err);
  });

}

/**
 * Handles the creation of the button to pay with Google Pay.
 * Once created, this button is appended to the DOM, under the element 
 * 'buy-now'.
 */
function createAndAddButton() {

  const googlePayButton = googlePayClient.createButton({

    // currently defaults to black if default or omitted
    buttonColor: 'default',

    // defaults to long if omitted
    buttonType: 'long',

    onClick: onGooglePaymentsButtonClicked
  });

  document.getElementById('buy-now').appendChild(googlePayButton);
}

/**
 * Handles the click of the button to pay with Google Pay. Takes
 * care of defining the payment data request to be used in order to load
 * the payments methods available to the user.
 */
function onGooglePaymentsButtonClicked() {

  const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    gateway: 'example',
    gatewayMerchantId: 'exampleGatewayMerchantId'
  }
 };

  const cardPaymentMethod = {
  type: 'CARD',
  tokenizationSpecification: tokenizationSpecification,
  parameters: {
    allowedCardNetworks: ['VISA','MASTERCARD'],
    allowedAuthMethods: ['PAN_ONLY','CRYPTOGRAM_3DS'],
    billingAddressRequired: true,
    billingAddressParameters: {
      format: 'FULL',
      phoneNumberRequired: true
      }
    }
  };

  const transactionInfo = {
  totalPriceStatus: 'FINAL',
  totalPrice: '123.45',
  currencyCode: 'USD',
  countryCode: 'US'
  };

  const merchantInfo = {
   merchantId: '01234567890123456789', //Only in PRODUCTION
  merchantName: 'Example Merchant Name'
  };

  const paymentDataRequest = Object.assign({}, googlePayBaseConfiguration, {
  allowedPaymentMethods: [cardPaymentMethod],
  transactionInfo: transactionInfo,
  merchantInfo: merchantInfo   
  });

  googlePayClient
  .loadPaymentData(paymentDataRequest)
  .then(function(paymentData) {
    processPayment(paymentData);
  }).catch(function(err) {
    // Log error: { statusCode: CANCELED || DEVELOPER_ERROR }
  });
}

function processPayment(paymentData) {
  // TODO: Send a POST request to your processor with the payload
  // https://us-central1-devrel-payments.cloudfunctions.net/google-pay-server 
  // Sorry, this is out-of-scope for this codelab.
  return new Promise(function(resolve, reject) {
    // @todo pass payment token to your gateway to process payment
    const paymentToken = paymentData.paymentMethodData.tokenizationData.token;
    console.log('mock send token ' + paymentToken + ' to payment processor');
    setTimeout(function() {
      console.log('mock response from processor');
      alert('done');
      resolve({});
    }, 800);
  });
} ```

该商户没有可使用的可接受的银行卡。

此消息表示当前 Google 用户没有任何与商家提供的付款选项兼容的银行卡。具体来说allowedCardNetworks and allowedAuthMethods.

这是我根据您的代码片段创建的 JSFiddle:https://jsfiddle.net/aumg6ncb/ https://jsfiddle.net/aumg6ncb/

这是我点击按钮后得到的结果:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

没有可供该商家使用的可接受银行卡 - Google Pay 的相关文章

随机推荐

  • 在 RHEL 6.5 上安装 RPostgreSQL libpq-fe.h 错误

    我有 RHEL 6 5 服务器 安装了 R 3 1 1 和 RStudioServer 0 98 1062 我安装了 postgresql 9 3 并处理一个大型数据库 为了将 R 连接到 PostgreSQL 我过去使用过 RPostgr
  • 通过 python/JS 发送 Whatsapp 消息

    我编写了一个程序 它从 excel 获取信息并通过 python 发送消息 我使用 selenium 和 span 来查找我需要的元素 现在 WhatsApp 更改了 HTML 不再有跨度 旧代码在这里 import time import
  • HTML 中
    标签的使用:版权还是网站管理员?

    在我客户网站的页脚上有他的地址和版权声明 下面是网站管理员的地址 对于两者 我将使用 hCard 微格式 我应该使用其中的哪一个
  • 将 netCDF 文件转换为 csv

    我正在努力将几个 Berkeley Earth netCDF 文件转换为 CSV 或其他表格格式 我意识到以前曾提出过类似的问题 但我无法应用我遇到的任何解决方案 例如 这个数据集 http berkeleyearth lbl gov au
  • 将图像绕一个圆圈

    在这个例子中我想做的是将图像包裹在一个圆圈上 如下所示 为了包装图像 我简单地使用 trig 计算了 x y 坐标 问题是计算出的 X 和 Y 位置被四舍五入以使其成为整数 这会导致上面的包裹图像中出现空白像素 x y 位置必须是整数 因为
  • 如何在 JSF 托管 bean 中创建、访问和销毁会话?

    目前 我正在为在线购物车创建一个 Web 应用程序 我需要在每个 jsf 页面上维护会话 我的问题是 如何在托管 bean 中创建和销毁会话 如何访问存储在会话变量中的值 像这样 FacesContext getCurrentInstanc
  • 我的react-native expo 应用程序的已编译 typescript js 文件在哪里?

    我刚刚创建了一个默认的打字稿博览会项目expo init 并且它有一个简单的App tsx主目录中的文件 我可以对文件进行更改并将这些更改反映在我的应用程序中 但我似乎找不到相应的输出文件 App js文件随处可见 我觉得这很令人困惑 深入
  • 选择器 div + p(加号)和 div ~ p(波形符)之间的区别

    那样的方式w3学校 http www w3schools com 短语它 它们听起来是一样的 W3Schools 的 CSS 参考 http www w3schools com cssref css selectors asp div p选
  • 如何在 Nginx 服务器上允许 PUT 文件请求?

    我正在使用一个需要的应用程序PUTHTTP 服务器上的文件 我使用 Nginx 作为服务器 但得到了一个405 Not Allowed错误返回 以下是使用 cURL 进行测试的示例 curl X PUT H Content Type app
  • IIS 连接池询问/泄漏跟踪

    根据这个有用的文章 http www 15seconds com issue 040830 htm我已确认运行 W2k3 的 IIS 6 服务器上的某些应用程序存在连接池泄漏 困难的部分是 我正在从该服务器的 6 个应用程序池中为 700
  • React-Testing-Library - 使用 Redux 和 Router 包装组件

    我正在尝试设置一个测试文件来在我的应用程序上呈现路线 页面 我试图用 Redux 和 Router 包装所有内容 这就是我所拥有的 import React from react import render from react testi
  • 如何与 Talend 中的 joblet 共享数据库连接

    我有一个带有 tMSSqlConnection 设置的作业 我需要与 joblet 共享该连接 我在网上找到了说明 说将其注册为共享连接 然后在具有该连接名称的 joblet 组件的动态设置中添加一个选项 以便可以从连接的组件列表中选择它
  • 使用 MVC 控制器进行 ServiceStack 身份验证

    我已遵循 SocialBootstrapAPi for ServiceStack 中的示例 但我不明白重定向是如何连接的 当我进入未经身份验证的安全控制器时 我会被重定向回索引页面 我无法在我自己的应用程序中复制该行为 未找到此接线的位置
  • java 多重映射数组列表

    是否可以将键映射到多维数组列表 有些事情就像下面的例子 Map
  • iOS 自定义 URL 方案与通用链接和 Android 对应方案

    我正在寻找这样的功能 当用户收到一条消息 假设通过 WhatsApp 应用程序 包含以特定方案 前缀 开头的链接时 当用户点击该链接时将调用我的应用程序 据我所知 此功能已经作为 自定义 URL 方案 提供 但我现在也注意到通用链接也有类似
  • 如何在 Swift 5.5 中将 async/await 与 SwiftUI 一起使用?

    我一直在测试 Swift 5 5 版本中预览的异步 等待功能 但我无法从异步函数收集结果并使用 SwiftUI 显示它们 这是我的代码 import SwiftUI struct AsyncTestView View State var t
  • 如何在不接触磁盘的情况下创建带有目录的内存中 zip 文件?

    在 python Web 应用程序中 我将一些内容打包在 zip 文件中 我想在内存中完全动态地完成此操作 而不接触磁盘 只要我创建一个平面目录结构 使用 ZipFile writestr 就可以了 但是如何在 zip 中创建目录呢 我使用
  • 声明一个未知大小的二维数组 C

    我有一个数组声明为 C 中结构的成员 该数组声明为 char mValue MAXROWS MAXCOLUMNS where MAXROWS and MAXROWS是 300 有更好的方法吗 我的意思是 我应该将它们声明为指针吗 Thank
  • 添加 UIButton 作为 UIWebView 的子视图并在缩放时调整其大小

    我有世界地图的图像 svg我加载到UIWebView 我使用了svg格式和UIWebView 因为图像太大而无法加载到UIImageView中 我想在这张地图上放置一堆具有固定位置的图钉 例如 如果我在巴西放置了一个图钉 则无论我滚动或缩放
  • 没有可供该商家使用的可接受银行卡 - Google Pay

    我正在尝试将 Google Pay 网络集成到我的网站中 但是当我单击 使用 googlepay 付款 时 它显示以下错误 该商户没有可使用的可接受的银行卡 当我阅读文档时 它说您可以添加示例作为商家进行测试 我只想使用测试环境 但它仍然不