#SpicyJungle

1 messages ยท Page 1 of 1 (latest)

wheat bridgeBOT
opal fog
#

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.

#

and then updating the Invoice via the API with metadata from the Subscription.

sudden ice
# opal fog Hi ๐Ÿ‘‹ Are you asking if the Subscription metadata will be auto-populated to th...

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.

opal fog
#

Okay, yes in this case the guild_id will not propagate to the Invoice

sudden ice
#

Okay, cheers!

opal fog
#

But using the Update API to update the Invoice will allow you to copy this data across all related records

sudden ice
#

So invoice.created triggers whenever a subscription renews?

opal fog
#

Whenever an invoice is created. So when you first create the subscription, when it renews, or if you create a one-off invoice

sudden ice
#

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?

opal fog
#

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

sudden ice
#

How do I put the metadata in the invoice i recieve? Do I do this when creating the checkout session?