As you might know, the Stripe payment extension for Firebase does the following:
products
collection that gets filled with products managed in Stripe.customers/{id1}/checkout_sessions/{id2}
creates a payment in stripe. The document gets updated with the payment URL that the user can use to pay.customers/{id1}/payments/{id3}
How do you associate the payment that gets registered to the document in checkout_sessions?
The checkout_session
document looks like
{
cancel_url: (CancelUrl),
client: "web",
created: (Timestamp),
mode: "payment",
price: (The priceId associated to the product),
sessionId: (The session id of the checkout_session),
success_url: (SuccessUrl)
}
I create the checkout_session
document myself, so I can add extra meta data in there but I'm not sure if Stripe can use it.
The payment
document is significantly more complex. But the only id that I can associate to anything is the customer stripeId
which appears as customer
on the payment document.
Basically I'm trying to do the following.
checkout_sessions
document.payments
document is createdOne idea that I have that will probably work is to do the following: Instead of allowing the creation of the digital item during the creation of the checkout_sessions
document, I can create a "voucher" for that specific item. It won't have any personalization or options, but what I can do is create document onCreate cloud function on the payment document. If the payment is successful, allow the creation of the digital item. I can look up the 'template' based on the item purchased.
I dont like this option because there are at least 2 potential cold start delays that could make this a bad user experience.
When creating the checkout_sessions
document, you can add a metadata
object that can contain key:value pairs that will appear on the root of the document that is created in payments
collection.