创建付款请求API

时间:2020-01-23 06:07:19

标签: google-api-nodejs-client payment-request-api

我正在尝试使用javascript集成用于Google Pay for Payments的Payment Request API,但是我的代码返回的PaymentRequest未定义错误。

这是我的代码。

CODE:

const supportedInstruments = [
  {
    supportedMethods: ['https://tez.google.com/pay'],
    data: {
      pa: 'abc@gmail.com',
      pn: 'abc',
      tr: '1234ABCD',  // your custom transaction reference ID
      url: 'http://url/of/the/order/in/your/website',
      mc: '1234', // your merchant category code
      tn: 'Purchase in Merchant',
    },
  }
];

const details = {
  total: {
    label: 'Total',
    amount: {
      currency: 'INR',
      value: '10.01', // sample amount
    },
  },
  displayItems: [{
    label: 'Original Amount',
    amount: {
      currency: 'INR',
      value: '10.01',
    },
  }],
};

let request = null;
try {
  request = new PaymentRequest(supportedInstruments, details);
} 
catch (e) {
  console.log('Payment Request Error: ' + e.message);
  return;
}
if (!request) {
  console.log('Web payments are not supported in this browser.');
  return;
}

错误消息:

付款请求错误:未定义PaymentRequest

0 个答案:

没有答案