#gecko-checkout-metadata

1 messages · Page 1 of 1 (latest)

buoyant charmBOT
mortal rapids
#

Let's chat here. Can you provide a summary of your issue and your question?

grave lintel
#

ok

#

I am trying to get metadata to flow through my checkout process

#

i create metadata, during checkout session creation, and I see it there, great.

#

I can see it in checkout-session-completed event as well, great.

#

when I get the invoice.paid event, I don't see it

#

so I have previously done a subscription.update, and explicitly added the metadata in...which seemed to work in most cases.

#

but I'm getting events out of order....and this is causing issues

#

so my question is: is there a way, that a subscription maintains the metadata, so that when I get an invoice.paid event, I can fetch the subscription object from the invoice, and expect that the metadata will be in the subsciption object?

#

because it doesn't work

#

metadata is blank in the subscription event...

mortal rapids
#

I'm confused. If you add metadata to the Subscription object itself, I imagine it would stay persistent on that object and you would be able to get metadata from the Subscription object for all subsequent Invoices. You're saying that's not the case?

#

If so, can you provide a Subscription ID along with the Request ID for the request where you added metadata to it?

grave lintel
#

I'm saying that's the case

#

sub_1MrOcoDeb8L7gMecBFVnkQ7Q

#

flow: checkout-create, with metadata. it's added there on creation.
checkout-session-completed: it shows there
invoice.paid: it's not there (in the sub object)

mortal rapids
#

Do you have the request for the API call you made to update the Subscription object with metadata?

grave lintel
#

I didn't update....I said I created it, with metadata, not update.

mortal rapids
#

You said you are using Checkout, right? So you're specifying metadata somewhere. Which API call are you adding metadata?

grave lintel
#
const addMetadata = await stripePayment.subscriptions.update(
                    checkoutSession.subscription,
                    {
                        metadata: checkoutSession.metadata,
                    }
                );
#

and I do that in the checkout.session.completed event

#

but I think I'm hitting a race condition, where I get an invoice.paid event before the checkout.session.completed event finishes....so, can I do the subscription.metadata update action earlier, say in the checkout event, where I create the session itself, perhaps as the .then()?

#

I know there is a timing problem...on test runs when checkout.completed arrives before invoice.paid, it works fine. but if invoice.paid arrives before checkout.completed, it doesn't because the sub.update to add metadata is in checkout.completed

#

so how do I guarantee that the sub object will have metadata....in creation of the checkout session itself?

mortal rapids
#

Ahhhhh, okay I understand now. You could chain a .then(), but that won't guarantee the metadata is added before you receive the invoice.paid event. Why not add metadata to the Checkout Session when you create it and then listen for the checkout.session.completed event to get metadata? Like, what underlying process is dependent on there being metadata on the Subscription?

grave lintel
#

today, I add metadata to the Checkout Session. So the Session object has .metadata element.

#

I listen for checkout.session.completed and indeed, the metadata is in the Checkout Session object

#

BUT NOT THE SUBSCRIPTION

#

I want to be able to access metadata, from a subscription object. I do this, so that I can look up subscription from future invoices, and be able to get the metadata, when processing "this" invoice (later in time)

mortal rapids
#

Are you storing the metadata in a local database? Like, what breaks if you cannot get metadata from the Subscription immediately after it's created?

grave lintel
#

I am trying to store the metadata on your side, not mine

mortal rapids
buoyant charmBOT
old viper
#

gecko-checkout-metadata