#mochihealth
1 messages ยท Page 1 of 1 (latest)
Hey there
So there are a couple ways to do this.
The easiest way to do this is to actually just update your Subscription to have a one-month trial period after you start it and take payment for the initial invoice.
The second way to handle this would be to use a Subscription Schedule as you noted which starts now but has two phases. The first phase would be the prepay and then the second phase would be the actual Sub
Also realizing I mispoke on that first one
You would have a trial of one month + the first billing period
so if i do it this way i wouldn't have to use the schedules api just the regular subscription one?
can you elaborate on this approach a bit I am new to stripe
Correct
how would I set the first phase for prepay
You create a phase that lasts from now until you want the Sub to start and you would use a one-time item for the prepay and a $0 Price until the actual Sub starts at the point of phase 2 when you move it to the new Price
Honestly more complicated than option one imo
thanks and for option one can you elaborate on that one too?
Sure you just create a Sub with the Price that you would eventually use. Then you update the Sub to set a trial_end (https://stripe.com/docs/api/subscriptions/update#update_subscription-trial_end) to whenever the second Billing Period would be (when the customer should start paying for the Subscription again).
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but wouldn't this charge the customer only after the trial end and not right away
No you update after you take the initial payment
So start Sub --> customer pays initial invoice --> update Sub to trial until you actually want Sub to start + 1 cycle since the initial cycle was already paid for
so basically charge them as a regular subscription that starts now and the after they pay make a call to stripe api to update that subscription to a trial until I would wan the actual subscription to start?
can you elaborate on the "+ 1 cycle since the initial cycle was already paid for"
Well if they are "pre-paying" then they already are paying for the first billing cycle right?
Like they already pay for the first month of the Sub if it is on a monthly Price?
so there are two cases that I want to build for. 1 is for regular monthly subscriptions and the other is actually a one time subscription for 3, 6, and 12 months that doesn't renew
Okay well let's start with the first one
So for that the customer pays Dec 1 but wants to start the Sub on Dec 15. They have already paid for Dec 15 - Jan 15, so you update the Sub after the initial payment to be on trial until Jan 15.
Does that make sense?
yea so would I have to catch that through a webhook on successful payment event to know when to trigger that update logic
Webhooks are definitely the recommended route, you are going to need them any way to handle Subscriptions.
yea that is super helpful
so would you be able to tell me which webhooks are the most important to listen for when integrating stripe subscriptions
and also how about the second case of a one time subscription for 3, 6, and 12 months that doesn't renew
Have you seen https://stripe.com/docs/billing/subscriptions/webhooks yet?
Here you are just taking a single payment, correct?
yea
Okay so in that case you could just use a one-off invoice, or even just take a one-time payment, and not use a Subsription at all.
Or, you can use a Subscription Schedule that has an end_behavior: cancel set
yea I was looking into the Subscription Schedule option with the end_behavior: cancel set but i didnt konw how to charge upfront for that
Yep you would use the two phases in this case like we discussed above.
but you are saying that the one time payment would be easier?
the thing with that is can i schedule it to start in the future but charge now for a one time payment
The one-time payment is definitely easier, the only caveat is you have to track in your own database when the Subscription runs for so you can handle provisioning.
so like they could pay for it now with one time payment and in the backend when i got the webhook event for successful payment i would have to handle the logic of provisioning for when it starts?
I wouldnt be able to rely on a webhook to tell me when the subscription is active for this option correct? because all I know is that they paid for this product and there is no extra meta data that you can use with one time payments that would trigger a webhook event when I actually want the subscription to start
Yep that is what would be needed with one-time
You could set metadata on the one-time PaymentIntents
To ingest in your backend
but if I used the schedule subscriptions api will a webhook event fire when they get off the "trial" so I can know when to provision them access to our services
can you elaborate on the one time item for prepay
Hello, apologies for the delay, bismark had to step out and I am just catching up here. Looking in to this now
You can provide price_data that doesn't include recurring info or create a one-off price object https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases-items-price_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And add that as an item in the first phase
hey all good. let me ask you for recurring payments is there somewhere we need to store the customers payment details or stripe takes care of charging the original payment method automatically every month
As long as the payment method is attached to the customer and set as either the customer's invoice_settings.default_payment_method or the subscription's default_payment_method we will attempt to charge it automaticall
Oh and the subscription's collection_method needs to be charge_automatically but it sounds like that is what you are already doing
so at what point would I attach the customer and set as either the customer's invoice_settings.default_payment_method. when they are actually paying?
That would be charged when the subscription renews.
Ah I see, you are asking about how to collect the initial payment as well. Quick question: are you making your own custom page to charge users from or are you directing them to the Stirpe hosted invoice page?
we are making our own page for now
You can basically follow this guide after this step then https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#collect-payment
Once you create the subscription schedule, that should create a subscription that has an invoice that has a payment intent
You can confirm that payment intent on your custom page as with that doc. Once the payment method is saved, you can set it as the default payment method for the customer https://stripe.com/docs/api/customers/create#create_customer-invoice_settings-default_payment_method
so right now the way we do it is that when someone creates an account i create a customer in stripe with their email and store it on our own db. when our user wants to create a subscription i query the prices that were created on stripe to display to them, they choose one and i create that subscription on our end and send back the client secret to the frontend for them to fill out their payment information through stripe elements. once they do that and press confirm i call the confirm payment api through the frontend. so what I'm asking at what point would I save the payment details on the customer object that is on stripe in that flow
also please let me know if that is the correct flow or if I should change it to one that follows better practices
Hi there ๐ taking over for @west marten
Give me a few minutes to get caught up.
at what point would I save the payment details on the customer object that is on stripe in that flow
The Payment Method is saved once the Customer completes entering their payment info to the Payment Element and you confirm it.
but is the payment method saved in the subscription or on the customer object