#mulo_checkout-metadata
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1249763434480799746
đ Have more to share? Add details, code, screenshots, videos, etc. below.
@real gorge no it's not because of Test mode, it's all expected behaviour. Metadata is per object. If you set the metadata on the Checkout Session then the metadata is only on the Checkout Session and not on other related objects like an Invoice. We cover this in https://docs.stripe.com/metadata#copy-metadata
At a high level you should use checkout.session.completed for fulfillment with Checkout. See https://docs.stripe.com/payments/checkout/fulfill-orders
Also you shouldn't use invoice.payment_succeeded as it's been deprecated a few years ago, you should prefer invoice.paid which is better (it is sent even for Invoices paid out of band for example)
mulo_checkout-metadata
so I just have to save the sub create id into db, then on the invoice paid get the id to match the db to get my metadata? Is there not a way to get the metadata out of a re-occurring payment directly?
Yes to the first part of your question.
paypal api gives that custom metadata on subsequent payments, that is handy
And it is definitely possible to do what you are after but I recommend reading that doc I shared end to end first to understand metadata better.
What you can do is configure the metadata on the Subscription instead of the Checkout Session. This is done by passing the subscription_data[metadata] parameter. This will automatically put the metadata on the Subscription that Checkout creates.
Then on an Invoice, you can look at the subscription_details[metadata] property. It's a "cached version" of the Subscription's metadata at the time of Invoice finalization.
thanks
overall is a bit unpractical compare to paypal: many people will open the checkout page which I have to save,but not all will actually pay. So I have to save all those sessions
@real gorge I gave you a detailed answer above on how to do this with metadata with the exact flow
So that should fit exactly what you want and mirror what Paypal offers
Does this apply if the metada on the subscription is dynamic?
what does that mean "the subscription is dynamic"?
to put it simply, users log through discord, then apply the premium subscription to a server ID, so the metadata should contain both user and disocrd server id
You control the Subscription creation with code in that flow right?
hence im confused when u mentioned add the metadata on the sub instead of the checkout, since the sub is manually created in the dashboard?
what
Why would the Subscription be created manually? You mentioned you were using Checkout in your original question and Checkout would create the Subscription
Did I misunderstand that part of your question?
by subscription I mean "plan" where price is set.
let testSubId = 'price_1NH...' //< this i get from creating the sub-tier-plan manually in the dashboard
const session = await stripe.checkout.sessions.create({
success_url: `https://...`,
cancel_url: `https://...`,
line_items: [
{
price: testSubId,
quantity: 1,
},
],
mode: 'subscription',
metadata: {
custom: `${discordUserId}@${guildId}`
},
});
In that code, pass subscription_data: { metadata: { custom: `${discordUserId}@${guildId}` } }