-
Notifications
You must be signed in to change notification settings - Fork 680
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
Proration Invoice after subscription swap do not include tax, if tax is used #384
Comments
Is there a way to add this fix without editing the Thanks for sharing this fix. |
@Mr-Anonymous Well, technically you don't have to do this in the Billable Trait itself, but you can just define your own swap method in the Model that is billable. In my instance I have a custom swap method in my Tenant model, because I exclusively bill tenants:
Obviously this needs to be maintained when an update breaks with the previous Billable Trait. Thats why I opened this issue, so it could be fixed with the next version. |
Thank you so much @tobiasvielmetter Your reply HUGELY helped!! I added your code into my User Model and then call this custom swap method to change the plan and it worked perfectly. It now adds the I was stressed on this since I had to complete my project by this weekend. Your timely response helped me a great deal. I am truely grateful. Thank you so much for taking the time to help me out!! Thanks, |
@Mr-Anonymous Glad my answer was of help, good luck with your project! |
Hi @tobiasvielmetter Sorry to get back on this again. When I use this Swap method to change a Daily Plan to a Monthly plan, I end up getting the error:
However, it appears the Stripe has received the request, the upgrade was done successfully, the new invoice was generated and the invoice was paid. I can see these in the Stripe Log. However, my App API throws this errors and it fails to proceed with the remaining code which is to update the subscription table after that. The code this error shows is in these lines of the swap method:
The customer id is valid, the invoice is being generated so I am not sure why this error shows up. Do you have an idea on what may cause this issue here please? Here is my full Swap method that I am using:
|
@Mr-Anonymous Sorry, don't have time to debug this. I'd just properly debug the code, dd() out all the values, check if everything is set correctly etc. Good luck. |
@tobiasvielmetter I understand. Thanks for the input. When I look at the log, I can see the customer number is right and all the params are right so I am not sure why stripe is throwing this error. While I am still debugging this issue, I do have a quick question. What will happen if I remove this
Is my understand correct that if I remove the above block, the following happens:
Is that correct? In other words, if I don't include the above code block, then customer will not be charged straight away after plan change but instead any due or credit amount will be added to the next month's invoice. Is that right? Can I then safely remove this block if that is the behaviour? |
@Mr-Anonymous Once again, no time for this, as giving a proper answer would require for me to dig into the code/docs to validate how it works exactly, which you can easily do yourself. Also this is getting off topic, this is not a help forum but a issue tracker for the class. |
Noted and I understand. Thank you though and I apologise if it went off topic. |
Just joining the conversation to confirm that this is problem with client's project too (which uses Spark) so it would be nice to have it fixed. Do maintainers/contributers need any help on this? @tobiasvielmetter I only added your modified |
Also having this issue (using spark). When someone makes changes to plan, then there is no mention of taxes on receipt. |
Hey everyone 👋 Just wanted to share my own findings because I did quite some research on this. It's indeed important to update the It is however not necessary to overwrite the What you'll need to do is manually update the subscription if ($billable->subscribed()) {
$subscription = $billable->subscription()->asStripeSubscription();
$subscription->tax_percent = $billable->taxPercentage();
$subscription->save();
} This will apply and save the new The reason for this is that if you auto-bill your customers, Stripe will continue to use the old value until you've updated the value itself. It's therefor very important that you update the subscriptions as soon as the tax value changes. If you take this further and apply a package like https://github.com/mpociot/vat-calculator then you should update the subscription value every time the customer's billing details change. This is the only way to make sure Stripe correctly applies the intended Tax. |
If proration isn't very important to you, disable the proration feature. Yes, this is not a solution to the problem, rather avoidance of it, but for those who don't want to spend too much time resolving the issue, it's a quick solution. For those users using Laravel Spark. This is achieved by adding Spark::noProrate(); to App\Providers\SparkServiceProvider |
I'll throw my hat in the ring on this one as well. We have some clients that are taxable for the subscriptions and some that are not. In my testing I discovered that using ->swap() is charging through Stripe but only the difference between the original plan ($299) and the new plan ($699). However there's an 8% tax on the original subscription (which is passed to stripe upon initial purchase). I can view the original invoice in Stripe as well showing that it has a line entry in the invoice totals showing "Tax (8.00%)". So clearly, simply having the tax attached to the original subscription does NOT force Stripe to apply tax to the new subscription. Would be good to have this fixed. |
I've sent in a PR with a convenience method so you can easily sync the tax percentage of the billable model with the subscription. Please read my remarks on the PR and above. What it comes down to: when the value of the With the new method you could for example call it right before the swap method: $subscription->syncTaxPercentage();
$subscription->swap('new-plan'); Hope this helps. Feel free to provide any other feedback. |
Thanks @driesvints but the tax isn't changing. The initial subscription is set to 8%. The swap should also be 8%. It seems that the cashier module isn't passing in the tax_percent at all. There appears to be somewhat of a bug in the Stripe system and I'm working with them to fix this because according to their documentation you only need to pass in the tax_percent when the tax is changed (in which case your above PR and instruction would be applicable). I tried modifying it to pass the tax and it still didn't charge the tax, but the future invoice does in fact have tax applied. So clearly there's a problem with Stripe. |
Hey @emergingdzns, thanks for letting us know. Seems like this is indeed a problem on Stripe's end. Definitely let us know if you or they find a solution. |
Ok working with Stripe we found the problem! It's actually an issue in Cashier. It's an odd issue, but in the Billable.php you have:
But, if you look at their documentation: https://stripe.com/docs/api#create_invoice it shows that subscription_id needs to be passed for it to tie the invoice to the subscription, which will cause them to apply the tax from the subscription. So that code should be:
and in Subscription.php you need to change:
to:
Hopefully that makes sense. I don't have the ability at the moment to do a PR. Hopefully you can fix based on this info. |
I see. Thanks for researching this. The proper way to solve this is to create an I can send a PR for this later, otherwise feel free to send one in already. |
@driesvints Just found out about this as well, when dealing with one-off charges / manual invoices. I guess the new |
@jlmmns there's a note about this in the docs:
But I see that there's no way to pass it with the |
I've sent in a PR which should fix the issue from @emergingdzns and provide @jlmmns with a way to add the |
Cashier 9.0 has been released which fixes these issues. |
Turns out the proration invoice created by cashier does not include tax when a tax amount is defined.
This should be changed. Here is an example how to change the invoice() method in Billable.php:
The text was updated successfully, but these errors were encountered: