#alex.esch
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
hello
we are selling a bundle, for which one, in a feature, we are creting an subscription
right now, to increase or MRR, we are moving to selling a subscription with add_invoice_items
our checkout flow is based on payment intent + stripe elements
so, now, in case of any problem with the payment method, we are getting an error and showing it to the customer
with the new approach (setup intent, confirm, get webhook, create a subscription), how can we handle any possible errors with the payment method?
as far i remember, if i'll create a subscription with payment method, it will not be charged at the moment, it takes up to 1 hour
Why are you creating a SetupIntent here?
Why not just use the Subscription's PaymentIntent or SetupIntent to set up your Payment Method?
i'm using setupintent to set payment method
but "set" means attached, no?
is not being validated
Yes that is the correct way to set up a PaymentMethod
Are you collecting the PaymentMethod before creating the Subscription later on when your customer is not in your checkout flow?
yes
Okay
can you please confirm, if i'll create a subscription for a payment method set in setupintent, it will be charged at the moment? or it will take some time?
If you create a collection_method: charge_automatically Subscription then it charges immediately.
and in case there are no any suficint funds, i 'll get an error about it?
Yes the charge will fail if there is an insufficient funds decline
so, it will not a good idea to move this flow (creation of a new subscription) into stripe webhook callback, right?
What webhook?
setupintent.succeed
That would indicate your customer is still in your checkout flow then.... ?
So that is back to the beginning.
you are right...
Let's pause.
Are you using trials here?
Is the initial Invoice for your Subscription $0?
look, i'll try to explain in more details
right now we are selling a bundle, for 399
this bundle includes a subscription, but this subscription is create in 2 months after bundle purchase
everything is managed by a payment intent and is working fine
now, i have a requirement from marketing team, to increate MRR for our products (subscriptions)
this means, i need to charge the user and create a subscription at the moment
but, as the real subscription will become active in 2 months, i though about to
- create a subscription
- and just after, pause it
- then the moment will arrive, unpause it
If the Subscription isn't active for 2 months then it is on trial, no?
So you would just use a trial period?
paused
we don't have a fixed time, when it will become active
it can be a month, can be 6, not depends on us
Okay still though... that is a trial. You can't pause a Subscription that was never active.
So really you have to use a trial here
well, ok
So here is your flow:
- Create Subscription with a 2 year trial period (https://stripe.com/docs/api/subscriptions/create#create_subscription-trial_end) since that is the max trial
- When you create a Subscription with a $0 initial Invoice then the
pending_setup_intentprop will provoide you a SetupIntent: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
So in step 1 you want to also expand: [pending_setup_intent]
- Take that SetupIntent's client_secret and set up the PaymentMethod
- When your customer wants to activate the Subscription, end the trial.
thank you
but i need to charge the user for bundle purchase
this is that i'm trying to do right now
$subscription = $stripe->subscriptions->create([
'customer' => $stripe_customer_id,
'default_payment_method' => '',
'items' => [
[
'price' => $subscription_id,
],
],
'add_invoice_items' => [
[
'price' => $bundle_product_id,
],
],
]);
bundle price = 399
subscription price = 99
so in invoice items, i'm adding a custom product, for 300$
so my idea was to create a subscription with a payment method from setupintent
charge the user for 399$ there 99 will go to MRR of the subscription
and just after this, pause the subscription
wait till arrive the moment, and reactivate the subscription
Ah I thought you said you weren't taking any initial payment at all?
Oh okay well then yeah you still don't need a SetupIntent -- you just use the initial PaymentIntent from the Subscription to collect the PaymentMethod.
ok, so flow will be
- create a subscription without payment method
- get the payment intent from subscription
- send it to frontend
- the frontend will do all the stuff related to payments
- the frontend will complete the payment (paymentintent confirm)
- subscription will be created and paid
- at the moment of receving webhook for paymentintent.complete, i'll get this subscription and will pause it
Yep
The key is you want to use payment_behavior: default_incomplete when you create your Subscription
That will ensure that the initial payment attempt isn't triggered until you pass the client_secret to the frontend and confirm on the frontend
great
thank you
last question
if i'll create a subscription
and the payment intent is not completed
will i receive any webhook? something like abandoned in 1 hour?
or i should check these orders by cron on my side and canceling this created subscriptions?
The Susbcription will moved to incomplete_expired in 23 hours if there is no successful payment
And a customer.subscription.updated Event will be sent for that
Feel free to test this out with test clocks as well
ok, and, in this case i'll be unable to process multiple subscriptions, right?
user can purchase multiple bundles at once, each one have a subscription
Once you have successfully attached the PaymentMethod from the initial payment of the first Subscripton then you can use that same PaymentMethod for other Subscriptions if you want.
I believe that is what you are asking?
👍