Reputation: 1198
I am currently using laravel spark for stripe v5.0.
I have setup 2 plans
On the /billing page, my application users based on their gender who are male should see only one plan to subscribe to which is $10 and female users should be able to see only one plan to subscribe to which is $5.
how can I conditionally show them plans based on such User model property?
Upvotes: -1
Views: 170
Reputation: 1198
Okay, I found the answer to this:
We will be able to achieve this in the resolve closure inside SparkServiceProvider like follows:
public function boot(): void
{
Spark::billable(User::class)->resolve(function (Request $request) {
app('config')->set(
'spark.billables.user.plans',
[
[
'name' => $request()->user()->plan->name,
'short_description' => 'Only 1 user access',
'monthly_id' => 'price_id',
'features' => [
'Single Person Access',
'Monthly Subscription',
'Automatic Renewal',
],
'options' => [
'uk' => true,
'others' => false,
],
],
]
);
return $request->user();
});
}
Upvotes: 0