Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -103,4 +103,26 @@ class EventsProTest extends TestCase
|
||||
$this->assertTrue($svc->canUsePaymentGateway($user));
|
||||
$this->assertTrue(app(\App\Services\Payments\MerchantGatewayService::class)->isConfigured($user));
|
||||
}
|
||||
|
||||
public function test_invalid_credentials_and_downgrade_disable_owner_gateway_without_deleting_keys(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
ProSubscription::create([
|
||||
'user_id' => $user->id, 'plan' => 'enterprise', 'status' => 'active',
|
||||
'price_minor' => 14900, 'current_period_end' => now()->addMonth(),
|
||||
]);
|
||||
$setting = \App\Models\PaymentGatewaySetting::create([
|
||||
'owner_ref' => $user->public_id, 'provider' => 'paystack',
|
||||
'public_key' => 'bad', 'secret_key' => 'bad', 'is_active' => true,
|
||||
]);
|
||||
$gateway = app(\App\Services\Payments\MerchantGatewayService::class);
|
||||
$this->assertFalse($gateway->shouldUseOwnerGateway($user));
|
||||
|
||||
$setting->update(['public_key' => 'pk_test_saved', 'secret_key' => 'sk_test_saved']);
|
||||
$this->assertTrue($gateway->shouldUseOwnerGateway($user));
|
||||
|
||||
ProSubscription::where('user_id', $user->id)->update(['status' => 'past_due']);
|
||||
$this->assertFalse($gateway->shouldUseOwnerGateway($user->fresh()));
|
||||
$this->assertDatabaseHas('payment_gateway_settings', ['id' => $setting->id, 'is_active' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user