#SpicyJungle
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Are you asking if the Subscription metadata will be auto-populated to the Invoice and/or Payment Intent?
If so, that is not something we currently do. Stripe treats the metadata on the Subscription, Invoice, and Payment Intent as separate entities.
If that is what you want to do you will need to update the Invoice after creation with the metadata from the Subscription. I recommend listening to the invoice.created event: https://stripe.com/docs/api/events/types?lang=php#event_types-invoice.created
and then updating the Invoice via the API with metadata from the Subscription.
Yes; If the data passed here will be there when the next payment occurs and is sent to the webhook.
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'auto',
line_items: [
{
price: prices.data[0].id,
quantity: 1,
}
],
mode: "subscription",
subscription_data: {
metadata: {
guild_id: "123",
},
},
success_url: "http://localhost:3000/?success=true&session_id={CHECKOUT_SESSION_ID}",
cancel_url: "http://localhost:3000/?canceled=true",
});
Thanks for the reply, I'll look into the links you sent.
Okay, yes in this case the guild_id will not propagate to the Invoice
Okay, cheers!
But using the Update API to update the Invoice will allow you to copy this data across all related records
So invoice.created triggers whenever a subscription renews?
Whenever an invoice is created. So when you first create the subscription, when it renews, or if you create a one-off invoice
Gotchu, thanks
So I still don't quite understand how to go about this although this may be more or less unrelated to stripe in itself.
But i need guild_id to be sent to the webhook every time I recieve a payment for a subscription, how would I do this?
You would need to update the Invoice if you are listening to invoice.payment_succeeded or update the related Payment Intent if you are listening to payment_intent.payment_succeeded
How do I put the metadata in the invoice i recieve? Do I do this when creating the checkout session?