Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: "[email protected]",
  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

like image 806
Lahari Areti Avatar asked Mar 18 '26 01:03

Lahari Areti


1 Answers

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: "[email protected]",
  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) {
  });
});
like image 94
Ywain Avatar answered Mar 20 '26 18:03

Ywain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!