Make POS payment routing plan-aware.
Deploy Ladill POS / deploy (push) Successful in 37s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-21 19:47:11 +00:00
co-authored by Cursor
parent ca08f303c0
commit 4dcc46e319
4 changed files with 136 additions and 27 deletions
+44
View File
@@ -25,6 +25,8 @@ class PosProTest extends TestCase
'pos.pro.price_minor' => 7900,
'pos.plans.pro.price_minor' => 7900,
'pos.plans.enterprise.price_minor' => 24900,
'pay.api_url' => 'https://ladill.com/api/pay',
'pay.api_key' => 'pos-pay-key',
]);
}
@@ -107,6 +109,48 @@ class PosProTest extends TestCase
);
}
public function test_free_and_invalid_owner_gateway_fall_back_to_ladill_pay(): void
{
Http::fake(['*/api/pay/checkouts' => Http::response([
'reference' => 'LP-POS-FALLBACK',
'checkout_url' => 'https://checkout.paystack.com/fallback',
], 201)]);
$user = $this->user();
\App\Models\PaymentGatewaySetting::create([
'owner_ref' => $user->public_id,
'provider' => 'paystack',
'public_key' => 'invalid',
'secret_key' => 'invalid',
'is_active' => true,
]);
$result = app(\App\Services\Payments\MerchantGatewayService::class)->initializeCheckout(
$user, 1000, 'GHS', 'seller@example.com', 'https://pos.test/callback', 'POSP-OLD',
);
$this->assertSame('ladill_pay', $result['provider']);
$this->assertSame('LP-POS-FALLBACK', $result['reference']);
}
public function test_downgrade_disables_owner_gateway_without_deleting_credentials(): void
{
$user = $this->user();
ProSubscription::create([
'user_id' => $user->id, 'plan' => 'pro', 'status' => 'active',
'price_minor' => 7900, 'current_period_end' => now()->addMonth(),
]);
$setting = \App\Models\PaymentGatewaySetting::create([
'owner_ref' => $user->public_id, 'provider' => 'paystack',
'public_key' => 'pk_test_saved', 'secret_key' => 'sk_test_saved', 'is_active' => true,
]);
$this->assertTrue(app(\App\Services\Payments\MerchantGatewayService::class)->shouldUseOwnerGateway($user));
ProSubscription::where('user_id', $user->id)->update(['status' => 'past_due']);
$this->assertFalse(app(\App\Services\Payments\MerchantGatewayService::class)->shouldUseOwnerGateway($user->fresh()));
$this->assertDatabaseHas('payment_gateway_settings', ['id' => $setting->id, 'is_active' => true]);
}
public function test_subscribe_enterprise_charges_wallet_and_activates(): void
{
Http::fake(['*/debit' => Http::response(['id' => 1], 201)]);