编程语言
首页 > 编程语言> > javascript-在node.js中使用条纹实现ach

javascript-在node.js中使用条纹实现ach

作者:互联网

我获取了客户的银行详细信息并将其转换为令牌.基于该令牌,我创建了客户ID.接下来,我需要执行verifySource.但是我在verifySource上遇到错误,错误是
 **

Unhandled rejection TypeError: Cannot read property ‘verifySource’ of
undefined**

** **这是我的代码是****

var stripe = require("stripe")("sk_test_73xfGiaFaZLWO8oVoNr8PqSe");
var tokenId = "btok_1BiIZkKB2GdGniJfVf8H0Yy0";
var data = {amounts: [32,45]}
// Token is created using Stripe.js or Checkout!
// Get the payment token ID submitted by the form:
//var token = request.body.stripeToken; // Using Express
// Create a Customer:
stripe.customers.create({
  email: "paying1.user@example.com",
  source: tokenId,
}).then(function(customer) {
  // YOUR CODE: Save the customer ID and other info in a database for later.
   stripe.customer.verifySource(
   tokenId,
  customer.id,
  {
    amounts: [32,45]
    },
   function(err, bankAccount) {
   });
   });

请帮帮我.verifySource之后,下一步要处理什么.
如何验证用户银行帐户

谢谢

解决方法:

正如@Titus指出的那样,您的代码中有一个错字:stripe.customer.verifySource应该改为stripe.customers.verifySource.

此外,verifySource需要银行帐户ID(ba _…),而不是银行帐户令牌ID(btok _…).另外,客户ID应该是第一个参数,银行帐户ID应该是第二个参数(参见the API reference).

尝试像这样升级代码:

stripe.customers.create({
  email: "paying1.user@example.com",
  source: tokenId,
}).then(function(customer) {
  // YOUR CODE: Save the customer ID and other info in a database for later.
  stripe.customers.verifySource(
    customer.id,
    customer.sources.data[0].id,
    {
      amounts: [32, 45]
    }
  ).then(function(bankAccount) {
  });
});

标签:stripe-payments,node-js,javascript
来源: https://codeday.me/bug/20191025/1928673.html