#byron-firebase-help
1 messages ยท Page 1 of 1 (latest)
Hi ๐
The Firebase Extension is no longer supported by Stripe and a new version has been set up by Invertase. You can find it here: https://extensions.dev/extensions/invertase/firestore-stripe-payments
Hi Snufkin
I'm using that extension ๐ It was also only transferred a few days ago and I've checked the commit history and nothing has changed in the last little while (so it's effectively the same thing)
Right but we are directing all support for it to Invertase
I see. I have tried contacting them (through issues on Github) but am not getting anywhere.
How else can I reach them?
I think the GH Issues board is the preferred method. I know ~0 about Firebase functions but.... do you have any API requests logged of the payment link creation or purchases made with them in your stripe account?
They will start with req_
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
haha that's a lot of firebase function knowledge ๐
Once sec I'll find some logs for you
Here is the event ID for the webhook firing after a customer made a successful purchase. It is trying to obviously update that user's data on Firestore but subsequently fails when it can't find the matching user.
evt_1NgAxKB2IaEU6ucijCtDIUZg
I'll try find an API request for you...
Okay so I'm guessing you know that
- Since you are creating Subscriptions, a Customer object is required
- Payment Links do not "look up" if a customer exists with that email, they just create a new Customer if required.
IS it the case that in Firestore customers are identified by their email?
I suspect there won't be a req_ log because this originated from Stripe
Oh I see some, like this one: https://dashboard.stripe.com/logs/req_xRlO6RR5PtMpDP
Yeah like that (although that's not a session complete, which is what I assume updates anything on the firestore side).
But, that aside, lemme maybe ask from the fundamentals because again, I reckon the issue here is my understanding and not the code ๐
If a user has signed up on my site, and they want to now make a purchase. They open the product table, hit the button and the purchase happens.
What does that flow look like? How does Stripe or Firestore know the others' state?
So you have your own product table that uses Payment Links to send the user to a payment interface (Checkout Session)?
yes
I don't know how Firestore keeps itself in sync but I would imagine they listen to any number of webhook events
I see 14 different events all related to that 1 confirm call I shared
I imagine they would sync the Customer on the customer.created event: https://dashboard.stripe.com/events/evt_1NgAxKB2IaEU6ucigYjM8Hpr
As well as the .updated events after that
when it tries to find that user in Firestore, it doesn't exist (because its a new user now)
Here is where my ignorance of Firestore is unhelpful. I'm not sure what you mean by "it's a new user now"
byron-firebase-help
(Scenario 1)
So when someone makes a purchase, and Stripe creates a new customer within Sripe, it also creates a new customer in firestore. New.
However, that new user doesn't have an authentication account on firebase so it technically isn't really a "user account". It's just a customer in the database now. Bit pointless.
BUT (scenario 2)
If I create a user on firebase first, it creates a customer in firestore AND a customer in Stripe automatically. That new customer in Stripe also carries with it a customerID in the metadata, which can be used to link it to a customer in firestore.
So both side work. Nice.
The issue is (lets assume scenario 2) when the user now goes over to Stripe and makes the purchase, using the same email, Stripe goes and makes a whole new customer and falls back to scenario 1.
That part is mostly expected
We don't do any "de-duplication" of Customer(s) by email or anything like this.
It's something you need to control/own via your own code/integration
Is there a way to pass some kind of key (for example a stripe customerID) back to the payment link? So Stripe knows that its working with an existing user?
No that's impossible. A PaymentLink is kind of a reusable link for everyone to just pay
in this world you should not use a PaymentLink at all. If you know who the end customer is and they have a Customer object in Stripe then you should be using Checkout directly and create a Session with their existing Customer id in customer: 'cus_123'
PaymentLink is more a "factory" to create N Checkout Sessions. Like you sell a book and you tweet a link and anyone can click it, get to Checkout and pay. Does that make sense?
I see. That does make sense. Ok.
So how would I direct the user after they've clicked "buy" on my site, to a Stripe checkout?
(I say Stripe checkout hoping there's some UI so I don't have to build out an entire checkout process manually)
yeah you're misunderstanding a bit
Our PaymentLink product is a layer on top of our Checkout product
1/ Create a Checkout Session: https://stripe.com/docs/api/checkout/sessions/create
2/ Redirect to that Session's url so that the customer can pay
ok ok ok I think I understand.
So basically:
const session = await stripe.checkout.sessions.create({
customer: 'cus_123'
success_url: 'https://example.com/success',
line_items: [
{price: 'price_H5ggYwtDq4fbrJ', quantity: 2},
],
mode: 'payment',
});
Then on response, direct them to the url.
Ok that makes sense.
(I just copied that code from your docs for example)