Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using Stripe Connect, how to handle 'account with this email already exists' errors?

While working on an app that connects with Stripe Accounts, I ran into an issue. If an account already exists for a given email, I can't create a new one. Stripe throws an error.

But how do I connect to that existing account? I can't find anything anywhere to do so.

For clarity, the failing code is:

Stripe::Acount.create(managed: false, email: '[email protected]')

I'm creating a Stripe::Account object, not a Stripe::Customer object. The above code throws an exception if the email already exists on Stripe's API, but does not provide me with any information to connect with it.

My concern is if a user who already has a Stripe account attempts to join the site, how do I link them up.

like image 506
RonLugge Avatar asked Oct 30 '22 06:10

RonLugge


1 Answers

Since you're using standalone accounts, you will not be able to create the account if the user already has a Stripe account with that email address.

In that case, you must use the OAuth flow to connect the existing account to your platform.

Note that you can use the OAuth flow to handle both cases. If the user already has a Stripe account, they can log into their existing account to connect it, and if they don't, they will be able to create a new account and connect it at the same time.

like image 175
Ywain Avatar answered Nov 15 '22 07:11

Ywain