#ali-ahmadi_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1218121626407927869
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, let me help you with this.
You need collection_method: "send_invoice": https://docs.stripe.com/api/subscriptions/create#create_subscription-collection_method
thanks for your reply. this option in create subscription Api, when should I call this api in my flow? at this time I only call checkout api and this api creates subscriptions for my users
That's right, sorry. I don't see a similar parameter in Session.subscription_data, unfortunately: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data
Let me check if you can update the generated Subscription after the Checkout Session is completed...
Yes, that should be possible.
So the plan is the following:
- Create a Checkout Session in mode "subscription", as you already are.
- Listen to
checkout.session.completedwebhook event: https://docs.stripe.com/api/events/types#event_types-checkout.session.completed - Call Subscription update endpoint with ID of the new Subscription (event.data.subscription), with
collection_method: "send_invoice"anddays_until_due: https://docs.stripe.com/api/subscriptions/update#update_subscription-days_until_due
thank you very very much. for clarification, this method will act same as create subscription from dashboard and in Subscription settings-> check Email invoice to the customer to pay manually?
Actually there's an easier way. You can just create a Subscription directly, and specify collection_method: "send_invoice". You don't need Stripe Checkout for this, the first Invoice will be sent to the customer's email immediately.
Using this endpoint âď¸
This is the same as my last suggestion, no Checkout Session needed.
1- As docs mentioned:"and mark the subscription as active", is there any way to set the subscription incomplete until the user pays the invoice?
2- I didn't get any invoice email after creating subscription for pay the invoice
- Only the first Invoice?
- Are you trying in test mode?
- It's okay to change the status of the first invoice to incomplete.
- Yes, I'm currently in test mode
- No unfortunately, it's only possible to configure this with
collection_method: "charge_automatically": https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_behavior - Stripe won't send emails in test mode. You can access the hosted invoice page here: https://docs.stripe.com/api/invoices/object#invoice_object-hosted_invoice_url
Thank you very much
Happy to help.