#Ali Raza - metadata
1 messages · Page 1 of 1 (latest)
heya @rustic bloom, can you share the request id where you added a metadata to your subscription?
this is my payment
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price' => $price->id,
// For metered billing, do not pass quantity
'quantity' => 1,
]],
'mode' => 'subscription',
'customer' => Auth::user()->customer_id,
// 'transfer_group'=>mt_rand(000000000,999999999),
'subscription_data' => [
'metadata'=>[
'Client email' => $client->email,
'PR email' => $user->email,
'Brief type' => $type,
'Brief Price' => $amount_without_fee_meta,
'VAT' => $vatN,
],
],
this is code
@pseudo heron
the metadata is showing on the Subscription object : https://dashboard.stripe.com/test/subscriptions/sub_1KDtuqHswjr8bdMVpVfx6ayv
As a general rule, metadata that is set on an object will not be silently copied over to any associated objects, so the metadata on a Subscription will not automatically copy over to the PaymentIntent of the Invoice i.e. pi_3KDtuqHswjr8bdMV1QqZQesH
Do you need the metadata of the Subscription to be on every corresponding PaymentIntent?
yes @pseudo heron
i would suggest listening for the invoice.created event - you would then retrieve the subscription metadata using the id in subscription [0][1] , and then update the PaymentIntent by using the id in payment_intent[2][3]
[0] https://stripe.com/docs/api/invoices/object#invoice_object-subscription
[1] https://stripe.com/docs/api/subscription_items/retrieve
[2] https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
[3] https://stripe.com/docs/api/payment_intents/update