我看到处理可变订阅量的最佳方法是例如在条带上创建一个基本计划freePlan
并为其分配一个数量1
。
因此,如果您想处理“在您的情况下”的可变订阅量,您将订阅它,freePlan
然后通过您的订阅量(数量)增加该量1 。
例如,您想分别向 2 位用户收取 10 美元和 15 美元的费用。你会
// Let get first user
$user = User::find(1);
// subscribe to free plan which has an amount of one(1)
// and increment the quantity by 10 so in this case he/she will pay
// $10 every month
$user->subscription('freePlan')->incrementQuantity(10);
// Lets do same for user 2
$user = User::find(2);
// subscribe to free plan which has an amount of one(1)
// and increment the quantity by 15 so in this case he/she will pay
// $15 every month
$user->subscription('freePlan')->incrementQuantity(15);
或者您可以选择使用已创建的计划示例basicPlan
或businessPlan
增加或减少数量
// Let say basicPlan is $30 so increasing it by 5 will be 150
$user->subscription('basicPlan')->incrementQuantity(15);
此链接指向有关如何设置数量的条带https://stripe.com/docs/subscriptions/guide#setting-quantities
这是关于如何增加或减少数量的链接点
https://laravel.com/docs/5.2/billing#subscription-quantity