简体   繁体   中英

Implementing ach with stripe in node.js

I took the customers bank details and converted into token .Based on that token I created the customer id .Next I need to do the verifySource . but I am getting error at verifySource , error is **

Unhandled rejection TypeError: Cannot read property 'verifySource' of undefined**

** **Here is My code is****

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) {
   });
   });

Please help me out .After verifySource what is the next step to process. How to verify the user bank accounts

Thanks

As @Titus pointed out, you have a typo in your code: stripe.customer.verifySource should be stripe.customers.verifySource instead.

Additionally, verifySource expects a bank account ID ( ba_... ), not a bank account token ID ( btok_... ). Also the customer ID should be the first argument and the bank account ID should be the second argument (cf. the API reference ).

Try upgrading your code like this:

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) {
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM