Add branch seat selector on Care plan checkout.
Deploy Ladill Care / deploy (push) Successful in 40s
Deploy Ladill Care / deploy (push) Successful in 40s
Let operators pick how many branches to bill next to the monthly/prepaid toggles so Pro and Enterprise totals and charges use branches × per-branch rate.
This commit is contained in:
@@ -129,11 +129,12 @@ class CareProTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe-enterprise'))
|
||||
->post(route('care.pro.subscribe-enterprise'), ['branches' => 1])
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertSame('enterprise', $this->organization->fresh()->settings['plan']);
|
||||
$this->assertSame(1, $this->organization->fresh()->settings['billed_branches']);
|
||||
}
|
||||
|
||||
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
|
||||
@@ -185,13 +186,35 @@ class CareProTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe'))
|
||||
->post(route('care.pro.subscribe'), ['branches' => 1])
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertSame('wallet_monthly', $settings['billing_method']);
|
||||
$this->assertSame(1, $settings['billed_branches']);
|
||||
}
|
||||
|
||||
public function test_subscribe_charges_selected_branch_count(): void
|
||||
{
|
||||
$perBranch = (int) config('care.plans.pro.price_minor_per_branch');
|
||||
|
||||
Http::fake([
|
||||
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||
'billing.test/debit' => function ($request) use ($perBranch) {
|
||||
$this->assertSame($perBranch * 3, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.pro.subscribe'), ['branches' => 3])
|
||||
->assertRedirect(route('care.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertSame(3, $this->organization->fresh()->settings['billed_branches']);
|
||||
}
|
||||
|
||||
public function test_subscribe_prepaid_redirects_to_paystack(): void
|
||||
@@ -207,8 +230,29 @@ class CareProTest extends TestCase
|
||||
->post(route('care.pro.subscribe-prepaid'), [
|
||||
'plan' => 'pro',
|
||||
'months' => 12,
|
||||
'branches' => 2,
|
||||
])
|
||||
->assertRedirect('https://checkout.paystack.com/test');
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
if (! str_contains($request->url(), 'plan-checkout')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$perBranch = (int) config('care.plans.pro.price_minor_per_branch');
|
||||
|
||||
return (int) $request['amount_minor'] === $perBranch * 2 * 12
|
||||
&& (int) ($request['metadata']['billed_branches'] ?? 0) === 2;
|
||||
});
|
||||
}
|
||||
|
||||
public function test_plans_page_shows_branch_selector(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.pro.index'))
|
||||
->assertOk()
|
||||
->assertSee('Branches')
|
||||
->assertSee('x-model.number="branches"', false);
|
||||
}
|
||||
|
||||
public function test_paystack_callback_activates_prepaid_pro(): void
|
||||
|
||||
Reference in New Issue
Block a user