Search code examples
google-cloud-firestorestripe-paymentsflutterflow

Stripe creating two customers instead of one (Firestore and FlutterFlow)


I'm trying like heck to get Stripe subscriptions working with Firebase in a web app. I added Stripe as an extension in Firebase but I'm having some issues here and there.

What's working:

  • Stripe and Firestore can talk with each other, so when I log into my web app a user is created in Firestore and then a Stripe webhook updates that Firebase user's information to include a couple of pieces of data, like the stripeId and stripeLink. A Stripe customer is also created in Stripe.

Stripe Customers View:

Stripe Customers view

Firestore: enter image description here

  • When I create a subscription directly on Stripe's website, the user's information gets updated with the payments and subscription subcollections. This does not happen when I do this in the web app. enter image description here

What's NOT working:

  • After the user logs in, goes to the payment page, and submits their payment, a new Stripe customer is created. That shouldn't be the case. It should use the already created customer. The bottom customer was already there. The top one was created after checkout. enter image description here

  • When a payment is made, Firestore is not updated with the subscription that was paid for. (this is probably because of the previous problem where I have two customers created) Is there a way to let Stripe know to use the already existing customer during checkout as opposed to it making a new one after checkout has completed?


Solution

  • The 'checkout' process you're referring to, is it using Stripe Checkout / Payment Links / Pricing Tables ?
    If so, that might be why.

    If you're using one of the following:
    -Checkout in subscription mode.
    -Payment Links / Pricing Tables with recurring items.
    Then Stripe Checkout automatically creates a Customer for you.

    -With Stripe Checkout, you can disable this by setting your own existing Customer with the customer argument:
    https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#handling-existing-customers
    -With Payment Links and Pricing Tables, there is no current way to do this.

    Hope my hunch is correct about your checkout process or else this is pointless.