Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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)]);
|
||||
|
||||
Reference in New Issue
Block a user