可変サブスクリプション金額を処理するための最良の方法は、たとえばストライプで基本プランを作成し、freePlan
それに金額を割り当てる1
ことです。
したがって、「あなたのケースにある」可変サブスクリプション金額を処理したい場合は、これにサブスクライブしてから、サブスクリプション数量(金額)でその金額を1freePlan
増やします。
たとえば、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
これは、数量を増減する方法に関するlaravelへのリンクポイントです
https://laravel.com/docs/5.2/billing#subscription-quantity