diff --git a/src/Contracts/HandleSubscriptions.php b/src/Contracts/HandleSubscriptions.php index 7ea87f2..ed94701 100644 --- a/src/Contracts/HandleSubscriptions.php +++ b/src/Contracts/HandleSubscriptions.php @@ -20,13 +20,12 @@ public function checkoutOnSubscription($subscription, $billable, Plan $plan, Req /** * Subscribe the user to a given plan. * - * @param \RenokiCo\CashierRegister\Models\Stripe\Subscription $subscription * @param \Illuminate\Database\Eloquent\Model $billable * @param \RenokiCo\CashierRegister\Plan $plan * @param \Illuminate\Http\Request $request * @return void */ - public function subscribeToPlan($subscription, $billable, Plan $plan, Request $request); + public function subscribeToPlan($billable, Plan $plan, Request $request); /** * Swap the current subscription plan. diff --git a/src/Http/Controllers/Inertia/SubscriptionController.php b/src/Http/Controllers/Inertia/SubscriptionController.php index 49c0a6e..e4cbf43 100644 --- a/src/Http/Controllers/Inertia/SubscriptionController.php +++ b/src/Http/Controllers/Inertia/SubscriptionController.php @@ -114,10 +114,7 @@ public function swapPlan(HandleSubscriptions $manager, Request $request, string // a default payment method set and we will initialize the subscription in case it is not subscribed // to a plan with the given subscription name. return $manager->subscribeToPlan( - $billable->newSubscription($request->subscription, $newPlan->getId()), - $billable, - $newPlan, - $request + $billable, $newPlan, $request ); }); } diff --git a/stubs/stripe/app/Actions/BillingPortal/HandleSubscriptions.php b/stubs/stripe/app/Actions/BillingPortal/HandleSubscriptions.php index 9440ac8..56749e6 100644 --- a/stubs/stripe/app/Actions/BillingPortal/HandleSubscriptions.php +++ b/stubs/stripe/app/Actions/BillingPortal/HandleSubscriptions.php @@ -28,15 +28,16 @@ public function checkoutOnSubscription($subscription, $billable, Plan $plan, Req /** * Subscribe the user to a given plan. * - * @param \RenokiCo\CashierRegister\Models\Stripe\Subscription $subscription * @param \Illuminate\Database\Eloquent\Model $billable * @param \RenokiCo\CashierRegister\Plan $plan * @param \Illuminate\Http\Request $request * @return \RenokiCo\CashierRegister\Models\Stripe\Subscription */ - public function subscribeToPlan($subscription, $billable, Plan $plan, Request $request) + public function subscribeToPlan($billable, Plan $plan, Request $request) { - return $subscription->create($billable->defaultPaymentMethod()->id); + return $billable + ->newSubscription($request->subscription, $plan->getId()) + ->create($billable->defaultPaymentMethod()->id); } /** diff --git a/tests/Actions/HandleSubscriptions.php b/tests/Actions/HandleSubscriptions.php index 69e5354..1566263 100644 --- a/tests/Actions/HandleSubscriptions.php +++ b/tests/Actions/HandleSubscriptions.php @@ -28,15 +28,16 @@ public function checkoutOnSubscription($subscription, $billable, Plan $plan, Req /** * Subscribe the user to a given plan. * - * @param \RenokiCo\CashierRegister\Models\Stripe\Subscription $subscription * @param \Illuminate\Database\Eloquent\Model $billable * @param \RenokiCo\CashierRegister\Plan $plan * @param \Illuminate\Http\Request $request * @return void */ - public function subscribeToPlan($subscription, $billable, Plan $plan, Request $request) + public function subscribeToPlan($billable, Plan $plan, Request $request) { - return $subscription->create($billable->defaultPaymentMethod()->id); + return $billable + ->newSubscription($request->subscription, $plan->getId()) + ->create($billable->defaultPaymentMethod()->id); } /**