如何使用Laravel收银台向Stripe订阅添加税款(4.2)


How to add tax to Stripe subscription using Laravel Cashier (4.2)

我想对刚刚将用户交换到的订阅征税。以下是我的尝试:

protected function swapToYearlyPlan(){
    $company = Auth::user()->company;
    $customer = $company->subscription()->getStripeCustomer();
    $company->subscription('Gold Annual Plan')->swap();
    // This doesn't seem to work -- no error message or anything.
    $company->subscription()->tax_percent = 5;
    return 'Upgraded to Gold Annual Plan w/ tax!!';
}

我查看了Laravel收银台的文件,在StripeGateway.php文件中找不到任何与税收有关的代码。我最担心的是,在这个版本的Laravel收银台无法做到这一点。

经过更多的研究,4.2似乎并没有开箱即用地支持这一功能。您必须将税款作为单独的行项目单独添加到发票中。

我觉得这篇文章很有帮助。