1

I am trying to connect actual bank accounts to the stripe accounts in Stripe Connect.

However, I am struggling with the actual implementation.

I use Custom Accounts, so I want to provide the user with the account creation logic through my iOS app.

In the Stripe API Reference it says that the recommended way to accomplish this is: "Destination accounts are added via the external_accounts parameter when creating or updating Custom accounts. The value should be a bank account or debit card token returned from Stripe.js."

Creating the token is documented as follows (I am using NodeJS):

stripe.createToken('bank_account', {
  country: 'US',
  currency: 'usd',
  routing_number: '110000000',
  account_number: '000123456789',
  account_holder_name: 'Jenny Rosen',
  account_holder_type: 'individual',
}).then(function(result) {
  // Handle result.error or result.token
});

Where to I link that token in the account creation process? See related code below:

app.post('/create_account', (req, res) => {
console.log('create account called');
var email = req.body.email;
var firstname = req.body.firstname;
var lastname = req.body.lastname;

stripe.accounts.create({
    country: "CH",
    type: "custom",
    email: email,
    business_name: "examplename",
    legal_entity: {
        first_name: "firstname",
        last_name: "lastname",
        dob: {
            day: 1,
            month: 1,
            year: 1900
        }
    }

}).then((account) => {
    res.status(200).send(account)
}).catch((err) => {
    console.log(err, req.body)
    res.status(500).end()
});
});

Is the token creation just a means of validating the account information client-side?

Would be glad if someone can elaborate on this with a simple step-by-step explanation, thank you in advance!

Besfort Abazi
  • 373
  • 3
  • 18

1 Answers1

1

You'd pass the token in the external_account parameter:

var bankAccountToken = req.body.stripeToken;

stripe.accounts.create({
  country: "CH",
  type: "custom",
  // ...
  external_account: bankAccountToken,
}).then((account) => {
  // ...
Ywain
  • 16,854
  • 4
  • 51
  • 67
  • I did put the "stripe.accounts.create" method inside the result function of "stripe.createToken" (if no error). From there, I pass the token directly to the external_account key. Is that an appropriate way to do it? Also, my log says: "TypeError: stripe.createToken is not a function" Where is the problem? Has it something to to with this line: ? Thank you Ywain! – Besfort Abazi Jan 10 '18 at 16:55
  • @BesfortAbazi The token should be created in your client-side code using Stripe.js. You'd then send the token ID ("btok_...") to your backend server, and use it to create the account in your server-side Node.js code. – Ywain Jan 10 '18 at 22:46
  • Would you mind to explain briefly how to implement the code client-side? I do not find documentation on how to do that specifically in an iOS (Objective-C) app. – Besfort Abazi Jan 11 '18 at 12:42
  • https://stackoverflow.com/questions/43724123/tokenize-bank-info-with-stripe-ios-sdk is this an appropriate solution? – Besfort Abazi Jan 11 '18 at 12:57
  • @BesfortAbazi Right, if your client is an iOS app instead of a web app, you'd need to use Stripe's iOS SDK to tokenize payment information. You can read all about it here: https://stripe.com/docs/mobile/ios – Ywain Jan 11 '18 at 13:16
  • I decided to create the token server-side, which I send back to the app. It works well like this, as documented in: https://stripe.com/docs/api/node#create_bank_account_token Is it important that it has to be client-side code? Thank you for the help! (P.S. the external_account key should be "external_accounts" (with an s, as documented, have not tried if it works without the s as well) – Besfort Abazi Jan 11 '18 at 14:32
  • `external_accounts` (plural) is the name of the attribute returned by the API on account objects. `external_account` (singular) is the name of the parameter that you'd send when creating or updating an account. If you're going to send the bank account information server-side, you might as well not create a token and directly pass the bank account information in the `external_account` parameter (as a hash instead of a string). But keep in mind that this means you'd be manipulating sensitive payment data, and potentially liable for it. – Ywain Jan 12 '18 at 15:06
  • Also, you would not be able to add a debit card as an external account this way. For PCI compliance reasons, card data must never hit your server and so must be tokenized client-side. – Ywain Jan 12 '18 at 15:07