#Mr.Yang
1 messages · Page 1 of 1 (latest)
Hi there, we can help if you have a technical question, and we can only provide support in English.
那我说中文可以吗
Please use English
Subscription payment metadata callback does not return. Is this normal?
Is this about webhook?
yes
Ok, can you share with me the webhook event ID?
evt_3MPeE5EuVK8MzP3v1RjmJp6k
OK. so I see you've specified a metadata when creating a subscription https://dashboard.stripe.com/test/logs/req_uHQNyLU4Ua75xn
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Please note that this metadata will be set on the subscription object, not the invoice's payment_intent object.
How am I supposed to know which subscription it is when I call back?
Or the callback needs to have my custom parameters, what should I do when I request?
I'd suggest you to listen to customer.subscription.updated instead, they event contains a subscription object and you can retrieve the metadata from there.
Alternatively, you can get the invoice from the payment_intent, and then retrieve the subscription from the invoice and get subscription's metadata there.
customer.subscription.updated
payment_intent.succeeded
I want to listen the two then from the customer.subscription.updated for subscription object?
You can also get the subscription from payment_intent.succeeded, like I explained earlier
you can get the invoice from the payment_intent, and then retrieve the subscription from the invoice and get subscription's metadata there.
Ok, I'll try. Thank you
Are there no event customer.subscription.updated callbacks when I create a subscription?
Please send the document url
👋 Taking over this thread, catching up now
Are there no event customer.subscription.updated callbacks when I create a subscription?
Could you share the subscription ID (sub_xxx) that you created?
sub_1MPfL6EuVK8MzP3vVIjZl3kk
To retrieve the subscription's metadata from the payment intent, you can expand invoice.subscription field with expand: ['invoice.subscription'] in Payment Intent retrieval API and subscription metadata will be present in invoice.subscription.metadata field.
- Payment Intent retrieval API: https://stripe.com/docs/api/payment_intents/retrieve
- Expanding field in the response: https://stripe.com/docs/api/expanding_objects
In the creation request of sub_1MPfL6EuVK8MzP3vVIjZl3kk, all the information required including default payment method have been filled, so the subscription is created and becomes active immediately: https://dashboard.stripe.com/test/logs/req_FlnVbFVASSmkJi
customer.subscription.updated will only be sent when there's any change to the subscription. In this case, there's no change to the subscription after it was created, so customer.subscription.updated wasn't sent.
customer.subscription.created was sent and informed that the subscription status is set to active: https://dashboard.stripe.com/test/events/evt_1MPfL8EuVK8MzP3vQzJRiYrD
Can I use the return field status = active to determine if the subscription is active?
What is the callback time for automatic payments after the subscription period?
Can I use the return field status = active to determine if the subscription is active?
Yes! You can refer to the subscription's status explanations here: https://stripe.com/docs/billing/subscriptions/overview#subscription-statuses
What is the callback time for automatic payments after the subscription period?
Do you mean you want to understand whether the payment is successful for each billing cycle of the subscription?
yes
You can listen to invoice.paid or invoice.payment_failed events to determine if the payment of a billing cycle of a subscription is made successfully: https://stripe.com/docs/billing/subscriptions/webhooks#events