Mysterious Coder
Mysterious Coder

Reputation: 158

Stripe: Send payout to customers' external bank account or debit card

I am trying to send payout to users' added external bank account or debit card and I am getting error like No such external account: ''

I have added an external bank account or card using https://stripe.com/docs/api/external_accounts#external_accounts this object and I am able to add a bank account and card and when I use those details with payout then It gives an error.

What my requirement is: User has their personal wallet where the amount is getting stored. whenever user want to withdraw fund they can add either a bank account or debit card after that they can credit their amount to their bank.

Thanks

Upvotes: 0

Views: 1194

Answers (1)

Yuriy Vorobyov
Yuriy Vorobyov

Reputation: 775

To send money you must save the user's information in Stripe. Insert the registration button into Stripe. Then store the Stripe user id in the database:

const stripe = require('stripe')(StripeSecretKey);

const stripeUser = await stripe.oauth.token({
      grant_type: 'authorization_code',
      code,
});

DB.save(stripeUser.stripe_user_id); // example

Now you can send money this way:

const stripe = require('stripe')(StripeSecretKey);

const stripeUser = await DB.find(id); // example

await stripe.transfers.create({
      amount,
      currency,
      destination: stripeAccount.stripeAccountId,
});

More about transfers and oauth.

Upvotes: 1

Related Questions