cashier-stripe: Proration Invoice after subscription swap do not include tax, if tax is used
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:
/**
* Invoice the billable entity outside of regular billing cycle.
*
* @return StripeInvoice|bool
*/
public function invoice()
{
if ($this->stripe_id) {
try {
return StripeInvoice::create(['customer' => $this->stripe_id, 'tax_percent' => $this->taxPercentage()], $this->getStripeKey())->pay();
} catch (StripeErrorInvalidRequest $e) {
return false;
}
}
return true;
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 23 (7 by maintainers)
@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.
I’ve sent in a PR which should fix the issue from @emergingdzns and provide @jlmmns with a way to add the
tax_percentto one off invoices: https://github.com/laravel/cashier/pull/598I see. Thanks for researching this. The proper way to solve this is to create an
invoicemethod on theSubscriptionmodel I believe. And let theswapandincrementAndInvoicemethods call those instead. This will be the cleanest solution.I can send a PR for this later, otherwise feel free to send one in already.
Noted and I understand. Thank you though and I apologise if it went off topic.