#lesc-subscription-paymentintent
1 messages ยท Page 1 of 1 (latest)
Hi ๐
When you create a Subscription it creates an initial invoice which includes a payment intent. However, if you have the payment method set as the customer default it should also be able to charge automatically
https://site-admin.stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method
Well I tried to create the subscription like that:
subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{
price: priceId,
}],
payment_behavior: 'default_incomplete',
metadata: metadata,
default_payment_method: paymentMethodId,
off_session: true,
expand:['latest_invoice.payment_intent'],
});
But it leaves the subscription on incomplete even though the payment method was set. Can I just confirm the payment intent on the backend which I received from the subscription creation?
Do you have the API request ID for this subscription creation?
Wait...this is the first invoice, correct?
Yes
In that case it will remain in draft state for 1 hour so you can apply any changes you might need.
And after that 1 hour? Will the payment intent be confirmed? If so can I do that manually after the subscription creation?
You wouldn't confirm the Payment Intent directly but you could finalize the invoice: https://site-admin.stripe.com/docs/api/invoices/finalize
Yea but if I take the payment intent id and call stripe.paymentIntents.confirm() it should be confirmed right?
@azure tartan What are you really trying to do here? What's your overall integration flow?
lesc-subscription-paymentintent
Like your code is explicitly passing payment_behavior: 'default_incomplete'. This is literally here to say "please do not attempt to do anything, I'll get the customer to pay client-side" which doesn't seem like what you want at all right?
In the docs it says the following:
Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment
To me that just sounds like if that's the right value if the invoice requires payment in general which is obviously the case
It isn't no, this is solely for integrations that will then collect paymeht method details client-side later
In your flow, it doesn't make sense I'd say to use this
Hmm ok, didn't know that sorry. I figured it out now. Thanks for your support!
sorry wrong button
Okay so if you remove that parameter, it should in theory attempt to charge the customer's default payment method. Or set the right one on Subscription creation in default_payment_method
and then it should do the right thing for you. Can you try @azure tartan and let me know?
It worked yes. Thank you
@azure tartan awesome! so make sure to handle declines too since that synchronous payment could fail
and then you need to decide what behaviour you want: do you want the Subscription to fail creation, or do you want it to go to incomplete
I think failing creation would be better.
Also I have one additional question. In my subscription system customers can subscribe to the same plan again if they have a canceled plan that is still running out. In this case can I just pass billing_cycle_anchor with the canceled sub's end date and proration_behavior: 'none' for the subscription to start at a later date?
I don't understand what that sentence could mean
Sorry ๐
I'll try again: Let's say a customer starts a monthly subscription plan. Then they cancel the subscription after 2 weeks. This means the subscription is canceled and the current cycle ends in 2 weeks. Now the customer starts a new subscription plan of the same product/price. If the customer tries to do that, I fetch the old, canceled subscription. Now how do I make it so billing of the new subscription starts at the end of the canceled subscription's cycle (and from there every 4 weeks)? By setting billing_cycle_anchor and proration_behavior: 'none'?
...without using subscription schedules
All you want to do is "stop the cancellation" right? Like they changed their mind and are basically re-activating their subscription, no?
Basically yes. But I want to create a new subscription that starts when the canceled subscription ends (like when the last cycle ends)
Figured it out. That's all I needed. Thanks again for your support guys
@azure tartan why aren't you keeping the current Subscription?
Basically what I would do is call https://stripe.com/docs/api/subscriptions/update and set https://stripe.com/docs/api/subscriptions/update#update_subscription-cancel_at_period_end to false so that the Subscription just continues as is
it's better than a new Subscription
In my case it's more convenient and gives customers a better overview
Will take a look at that though
sounds good, just wanted to make sure you were aware of this possibility
Yea I am aware of that
awesome!
You can close this thread. Thanks for helping out :)