I am looking for the best way to support product autoship / subscription which has a validity period (start, end date and shipping interval - (e.g 1 month) and associated product
Customer can subscribe to product autoship.
Products in the customer's order are grouped within the fulfillment group if they share the same autoship the customer has subscribed to.
On every autoship date, the same order is generated in the background.
Suggestions are much appreciated,
Thanks,
Milan
Broadleaf provides an enterprise-compatible module called Subscription that meets these requirements.
If you are looking for something in regards to community edition, you would have to make custom changes.
From a high level, you would want to do the following:
Some indication on your Product or Sku that indicates it is compatible with autoship / subscription.
An entity that holds the fields that you mentioned - start, end date, shipping interval, and also order, customer, customer payment, and status.
During checkout, add a new activity at the end of blCheckoutWorkflow that checks for compatible order items to create your "autoship" entity.
You will need to create some cron job or quarts scheduler that can trigger events. Sounds like you might want this to be set to a daily recurrence. This is provided in enterprise licenses, but you will have to do something custom for community.
Create an endpoint or service that the job/scheduler calls when triggered.
In your endpoint, you will want to create a new workflow with a set of activities. These activities will need to:
Prepare a new order by copying the required entities of the existing order from the "autoship" entity.
Trigger the blCheckoutWorkflow with your newly created order.
Update the "autoship" entity depending on success of the attempted payment.
This should get you to a good place given the requirements.
Related
I have a long list of old customers (>10K) in Stripe for which I would like to give a new trial period. Is there a way to bulk process those or we have to do that manually one by one?
I guess this depends entirely on what exactly you mean by 'new trial'. Do these customers have pre-existing Stripe subscriptions?
There's really no way to do this via the dashboard. However if there are no pre-existing subscriptions, you could programmatically create subscriptions for each customer object accordingly. You can specify the trial period on the price or on a per subscription basis.
As there are no batch endpoints for these operations, please be wary of the rate limiting if working with the API in this way
I am having a hard time finding the right webhooks in Stripe to use since it seems a lot of get fired off for multiple situations.
So my site sells a few items (like 10) that can be bought as a single purchase or a subscription (you get the item every X days, no SASS jut products). I am using Stripe's Checkout and Portal to handle all subscriptions and single purchase and those parts work great. Person adds stuff to cart, checkouts out, pays, we are all good. The issue is adding an order to our system from the webhook.
Look at this scenario: a person adds 2 single items and 1 subscription to their cart. They checkout and pay. When that happens we had the checkout.session.completed catching the checkout session was completed and we add those items from their cart to an order. The subscription re-ups after "X" Days we would listen for the invoice.payment_succeeded webhook to create a new order in our system. This logic is flawed though since invoice.payment_succeeded is called on the first order too so basically when they checkout our system adds 2 subscription orders: one from the checkout.session.completed and one from the invoice.payment_succeeded. How can we handle this?
What I would like to have is:
1 webhook to know when the checkout is complete and is only called then, which they do: checkout.session.completed
1 webhook that is only called when a subscription is renewed, not also when created, which I cant find.
If they dont have that webhook for subscription renewals only, how can I tell in the "invoice" object is the very first one so I dont do anything on checkout, only create a new order on renewal?
Instead of using invoice.payment_succeeded you should consider using invoice.paid, as it will also fire when you mark an Invoice as paid out-of-band (which won't happen with invoice.payment_succeeded). Both describe an Invoice, so you should be able to switch between them with minimal or no changes to your code.
You're correct that there is no Event specific to renewals for a Subscription only, but you can use the billing_reason property on an Invoice to determine why the Invoice was created. If it's the first Invoice for a new subscription the Invoice will have billing_reason set to subscription_create.
I am working with Stripe to manage subscriptions. I would like to delegate payment of a subscription to another customer.
Specifically, I want the customer of the subscription to reap the benefits of a subscription, but assign another customer to pay for it.
Is that possible? If not, what are the possible workarounds? Thanks.
Notes:
Once a subscription is created, an invoice is automatically generated and is not editable according to what I have tried previously
I would like to keep as close to the usual subscription flows as possible, as I don't want to lose out on things such as being able to pro-rate an invoice (which becomes messy if I have to manually craft invoices myself)
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.
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.