55namespace Veeqtoh \Cashier \Classes ;
66
77use Carbon \Carbon ;
8- use Illuminate \Database \Eloquent \Model ;
98use Veeqtoh \Cashier \Exceptions \FailedToCreateSubscription ;
109use Veeqtoh \Cashier \Models \Subscription ;
1110use Veeqtoh \Cashier \Services \PaystackService ;
@@ -37,12 +36,12 @@ class SubscriptionBuilder
3736 * Create a new subscription builder instance.
3837 *
3938 * @param mixed $owner The model that is subscribing.
40- * @param Model $plan The model instance of the plan being subscribed to.
39+ * @param string $plan The name of the plan being subscribed to.
4140 * @param string $name The name of the subscription.
4241 *
4342 * @return void
4443 */
45- public function __construct (protected mixed $ owner , protected Model $ plan , protected string $ name )
44+ public function __construct (protected mixed $ owner , protected string $ plan , protected string $ name )
4645 {
4746 //
4847 }
@@ -82,7 +81,7 @@ public function add(array $options = []): Subscription
8281 'name ' => $ this ->name ,
8382 'paystack_id ' => $ options ['id ' ],
8483 'paystack_code ' => $ options ['subscription_code ' ],
85- 'paystack_plan ' => $ this ->plan -> plan_code ,
84+ 'paystack_plan ' => $ this ->plan ,
8685 'quantity ' => 1 ,
8786 'trial_ends_at ' => $ trialEndsAt ,
8887 'ends_at ' => null ,
@@ -92,13 +91,13 @@ public function add(array $options = []): Subscription
9291 /**
9392 * Charge for a Paystack subscription.
9493 */
95- public function charge (array $ options = []): mixed
94+ public function charge (int $ amount , array $ options = []): mixed
9695 {
9796 $ options = array_merge ([
98- 'plan ' => $ this ->plan -> plan_code
97+ 'plan ' => $ this ->plan
9998 ], $ options );
10099
101- return $ this ->owner ->charge ($ this -> plan -> price , $ options );
100+ return $ this ->owner ->charge ($ amount , $ options );
102101 }
103102
104103 /**
@@ -137,7 +136,7 @@ protected function getSubscriptionPayload(array $customer, array $options = []):
137136
138137 return [
139138 'customer ' => $ customer ['customer_code ' ], // Customer email or code
140- 'plan ' => $ this ->plan -> plan_code ,
139+ 'plan ' => $ this ->plan ,
141140 'start_date ' => $ startDate ->format ('c ' ),
142141 ];
143142 }
0 commit comments