Handling a 2-year subscription in Stripe - stripe-payments

I need to be able to handle two types of subscriptions that Stripe doesn't seem to support out of the box:
A lifetime subscription
A two-year subscription
Lifetime subscription is easy. I'll just create a single charge and be done with it. It would've been nice to have a subscription record that I could check for validity.
Two-year subscription is where I am not sure what to do. I figure I'd create a one year subscription (current max in Stripe) and will have to use web hooks for when a new invoice will be generated. What would be the proper way of cancelling an upcoming charge? I am also worried that customers will receive an email alerting them for an upcoming charge in the middle of the period. Any way to avoid this?
Thanks in advance!

Stripe's subscriptions do not have a set end date. The 1 year maximum that you mention is the maximum interval, i.e. the frequency at which the customer will be billed.
If you want to end a subscription after a set number of payments, your best bet is to use webhooks to count the number of successful payments (via the invoice.payment_succeeded events) and cancel the subscription when the desired number of payments has been reached.
Stripe does not send emails to customers about upcoming charges. It can optionally send email receipts after a charge is created, but you can disable this from your dashboard.

Related

How can you pre-auth a subscription payment with stripe (after the first payment)

I know I can pre-auth a stripe subscription with a trial period. I want to pre-auth the 2nd, 3rd, 4th, nth subscription payment. The info we are sending out is time critical and if their subscription lapses due to NSF or something else, it would be nice for them if they could rectify the problem BEFORE it lapses.
There is a pending invoice you can get for a subscription, and you can create a payment intent with an invoice ID so that when the invoice is paid, the payment intent (that captured the money) will be used to collect the money. BUT the pending invoice doesn't have an ID until one or 2 hours before they try to collect the money which is 3-4 days too late.
Has anyone figured out how to pre-auth subscription payments other than the first one?
Is there a subscription engine I could use (with stripe/paypal/venmo) that would mean I could quit using the deficient stripe subscription system?
Subscription invoices don't exist until the renewal of the billing cycle, and the underlying payment intent is created by the invoice. It's not supported to "pre-auth" subscription payments. Instead, you need to handle payment failures when those occur, optionally by letting Stripe handle that for you.
If you want to have successful payment in advance of some time-sensitive event, then I'd suggest one of two alternatives:
Shift your billing cycle to invoice 3-4 days ahead of what you have set now, allowing you time to recover from payment failures before the delivery timing.
Alternatively you would implement your own recurring payments using saved payment details. You would similarly want to authorize the payment ahead of time to allow for recovery. You could optionally use manual capture to defer capture until the time of delivery.

can i create a sku object into a service type product?

suppose i have a membership service which cost $10/month in a subscription way
but some users can not have a reusable source to make a subscription via plan api ,alternatively i will let him to do an one-time payment via order api.(at least accept one month's money)
it is the same product,same amount,difference is one is for plan,another is for order,so question is, should i create two products one is goods type(for order),one is service(for plan/subscription). or one service type product is enough?
As a concept in the Stripe Dashboard, product SKUs are only used for recurring plans or invoicing. Any one time purchase can just be a charge, and does not need to be associated with any "Product" within your Stripe configuration.
If the product in this case is literally just one month of the plan, then you should probably use the same Product you have specified.
If the payment method will only work once, you could do nothing, and when the first period is up, and Stripe tries to renew, the payment will fail and the subscription will be canceled.
Or, if you're positive beforehand that it should only be charged once, you could cancel the subscription right after the first payment is completed. The customer would still have an active subscription for the period they paid for, but Stripe would not try to charge them automatically when that first period expired.

How to start a subscription in stripe with delay?

I have a number of users who are currently subscribers to a monthly subscription.
For business reason, I want to be able to
1) Charge the customer when he decides to subscribe to our plan
2) Let the subscription become effective a number of days after the purchase
Currently a charge is immediately attempted when a subscription is added to a customer in stripe.
I want to stick to the stripe subscription because a) I still want to have stripe to manage subscription for me in future dates, and b) I have written a lot of code for the subscription model.
Is it feasible at all to demarcate the charge/invoice and the subscription start date?
You can control the time when the subscription actually starts (i.e. when Stripe will start billing the customer) by using the trial_end parameter in your subscription creation request. Simply set the value of the parameter to the timestamp of the exact time you wish Stripe to start automatically billing the customer.
If I understand your desired payment flow correctly, you'd want to do something like this when a customer signs up:
Collect and tokenize the customer's payment information (using Elements or Checkout).
Using the resulting token, create a customer object and save the resulting customer ID in your database.
Create a one-off charge using the customer object for the first payment.
Create a subscription using the customer object and the trial_end parameter set to the time you want Stripe to start automatically billing the customer.
See https://stripe.com/docs/subscriptions/trials for more information about using trial periods.
This is possible now through Stripe Subscription Schedules. With that, you can create a one phase schedule that starts in the future. By default, this will start the subscription on the date you want, automatically renew, and charge the customer on the start date. Also by default, it will immediately perform a transaction to pay for the subscription.
I found the required iterations to be a bit confusing. Essentially that is a multiplier against how many times the original price's interval repeats before moving on.
If all you want to do is start a subscription price in the future, use the Subscription Schedule API call. Create an items array of 1. Set the price_id of the price, the iterations on that item, and the start_date to the unix timestamp you want to start the subscription.
Stripe has different use cases for subscription schedules. The first one they list is exactly this purpose, starting and charging a subscription on a future date. Look through them if you want to adjust some more, like making the first phase a trial period instead.

Can you set a l limited time period for a Stripe plan?

We are writing a Saas application that users will only use for 10 months. Is there a way to define in the payplan API to limit the number of payments to take from the customer?
I have spent some time looking over the API but I just can't see it. Perhaps I'm just overlooking it.
Stripe's subscriptions will always charge indefinitely by default so you'd need some custom development to cancel the subscription after a certain number of payments. The solution would be to use webhooks to be notified about events that happen in your Stripe account.
If you listen for the invoice.payment_succeeded event you can count how many times your customer has paid and then cancel the subscription when you want to stop the payments.
Now we can use a subscription schedule and set the phases.iterations
property: https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases-iterations
And set the end_behavior to "cancel"
Here's the full guide: https://stripe.com/docs/billing/subscriptions/subscription-schedules

Stripe: How can I create a non-renewable subscription plan?

We would like to have a yearly plan for our service, but legally we cannot automatically-renew our customer's yearly plan. We need to communicate with our customers in a timely manner within the weeks leading up to the end of their yearly plan so that they will manually purchase another year. (this is a legal thing). So we need some method of setting up a Stripe subscription plan that will either not auto-renew, or that we can cancel via API when we're informed via a webhook that their subscription's year is about to end.
Has anyone had any luck with any creative ways of setting up a non-renewable yearly subscription plan with Stripe? Trying to avoid needing to setup a cron job that hits Stripe everyday to find subscriptions that need to be cancelled.
After contacting Stripe support, there's not an "official" way to do so.
One thought I had was to setup a custom subscription plan of 10 days with a 355 day trial period. That way I could set a webhook to trigger based on the customer.subscription.trial_will_end event.
I'm doing this with the node.js Stripe module.
Well, you could set up a $0.00 subscription, and then a listener for invoice.created webhook, and use that to trigger a flow where you inform the user that their invoice is due, and direct them to a page where they can 'approve' the payment. When they approve it, you could then just create a good old fashioned Charge to collect the money.
Basically, use Stripe as your cron job, and do the actual Charge creation separately.

Resources