ฉันกำลังพยายามสมัครสมาชิกรายเดือน รายปี และตลอดชีพ ซึ่งการสมัครสมาชิกรายเดือนและรายปีทำงานได้ดี ฉันจะสมัครสมาชิกตลอดชีพ/ตลอดไปได้อย่างไร? เมื่อใดก็ตามที่ฉันส่งชื่อแผนและรหัสแผนไปที่ $user->newSubscription()
ฉันได้รับข้อผิดพลาด:
You passed a non-recurring price but this field only accepts recurring prices.
ด้านล่างคือรหัสของฉันสำหรับการสมัครสมาชิก:
$paymentMethod = $user->defaultPaymentMethod();
if ($period == 'yearly') {
$selectedPlan = $plan->plan_year;
} elseif($period=='monthly') {
$selectedPlan = $plan->plan_month;
}
else{
$selectedPlan = $plan->plan_lifetime;
}
$subscription = $user->newSubscription($plan->name, $selectedPlan);