Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plans to be added to the cart to start a subscription #625

Closed
1 task
lukeholder opened this issue Jan 11, 2019 · 4 comments
Closed
1 task

Allow plans to be added to the cart to start a subscription #625

lukeholder opened this issue Jan 11, 2019 · 4 comments
Labels

Comments

@lukeholder
Copy link
Member

lukeholder commented Jan 11, 2019

@lukeholder lukeholder added the 💡 enhancement Ideas and suggestions label Jan 11, 2019
@jlawrence-yellostudio
Copy link

@lukeholder In our scenario with the current craft commerce version we need to bill the customer for 1 base product + 1 instalment of a 6 instalment service cost.

Currently we would only be able to bill for the base product. So to work around this we're going to setup up products for the subscriptions for the value of 1 of the instalment costs. This will allow us to bill for the base product cost and 1 instalment via stripe and for the value of the cart to reflect this.

To avoid stripe billing the subscription off the back of this straight away, we'll then offset the subscription by using trialDays=30 and the plan will only have 5 instalments.

I hope this helps you to understand what we are trying to achieve and might help you see where potential functionality could lie.

I was thinking you could have it so that certain products were 'subscription' products and would trigger a subscription on purchase. This would cater for our scenario quite well.

@andris-sevcenko
Copy link
Contributor

andris-sevcenko commented Jan 11, 2019

@jlawrence-yellostudio currently the best way to achieve this (one-off payment + subscription) is close to what you're planning to do - you would set up the plan to be 6 months, of which the first 30 days are trial.

There are two ways to avoid creating an order (subscriptions and orders are going to play along nicely only once we make plans to be elements/purchasables).

Add a charge as the first invoice is generated

  1. Have a module/plugin listen for the craft\commerce\stripe\gateways\Gateway::EVENT_CREATE_INVOICE event
  2. Check the invoice data on the event
  3. Make sure that the billing reason is set to subscription_create to indicate the first invoice of the subscription
  4. Add the invoice item

- OR -

Add a charge before subscribing

  1. Have a module/plugin listen for the craft\commerce\stripe\gateways\Gateways::EVENT_BEFORE_SUBSCRIBE
  2. Grab the stripe customer id from the event data
  3. Create an extra invoice item for the first upcoming invoice

Does this sound like something that would fulfill your needs for the project?

@jlawrence-yellostudio
Copy link

@andris-sevcenko Thanks for the input here, I added input as requested from @lukeholder who was conversing with my colleague.

I'll consider your points further, however it is important to us that the customer pays for both base product + subscription in same payment, which is why I'm removing 1 instalment from the subscription.

So say 6 month subscription £10 / month:
1 x Product = £100
1 x Instalment = £10
Customer has to pay £110 by card in first payment.

I can achieve this very easily by adding 1 'Subscription' Product worth £10 and reducing the number of instalments on Stripe to 5 (5 x £10) and delaying using trialDays, if i'm not mistaken.

@andris-sevcenko
Copy link
Contributor

@jlawrence-yellostudio right, the point of my post above is about adding the item to the invoice that the Stripe will charge for. In this scenario let's assume that you have a fixed cost of 100 and a monthly cost of 10.

You would set up a subscription plan to last for 6 months, 10 pounds apiece.

  1. Set up a module to listen for the craft\commerce\stripe\gateways\Gateways::EVENT_BEFORE_SUBSCRIBE event.
  2. Grab the stripe customer from the event data, as above
  3. Add an extra invoice item there - doesn't matter if the data comes from an actual Commerce product or not. Just go with
\Stripe\Stripe::setApiKey("your stripe key");

\Stripe\InvoiceItem::create([
    'amount' => 10000,
    'currency' => 'gbp',
    'customer' => 'the customer id,
    'description' => 'One-time setup fee',
]);
  1. Presto. The customer is billed 110 pounds, the stripe invoice lists both the subscription fee for one month and the setup fee. The customer is next billed after a month for the amount of 10 pounds.

The only deviation from your scenario here is that a Commerce Order is never created, as they are not connected to subscriptions in any way yet.

@lukeholder lukeholder modified the milestones: 3.0, 3.x Oct 11, 2019
@nfourtythree nfourtythree modified the milestones: 3.x, Backlog Apr 1, 2020
@craftcms craftcms locked and limited conversation to collaborators Jul 21, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

5 participants