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

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-21 19:47:10 +00:00
co-authored by Cursor
parent 837c249634
commit 1bcbdbfdb1
6 changed files with 119 additions and 37 deletions
+22
View File
@@ -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]);
}
}