Gate payment gateway behind Pro and Business plans.
Deploy Ladill POS / deploy (push) Successful in 1m9s
Deploy Ladill POS / deploy (push) Successful in 1m9s
Free accounts keep cash sales only; connecting a gateway and card/MoMo checkout require a paid plan, with settings upsell copy for free users.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Pos\ProSubscription;
|
||||
use App\Models\User;
|
||||
use App\Services\Pos\SubscriptionService;
|
||||
@@ -16,6 +17,7 @@ class PosProTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(EnsurePlatformSession::class);
|
||||
config([
|
||||
'billing.api_url' => 'https://ladill.com/api/billing',
|
||||
'billing.api_key' => 'pos-billing-key',
|
||||
@@ -49,6 +51,62 @@ class PosProTest extends TestCase
|
||||
$this->assertFalse(app(SubscriptionService::class)->canUseRestaurantMode($this->user()));
|
||||
}
|
||||
|
||||
public function test_free_user_cannot_use_payment_gateway(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
$svc = app(SubscriptionService::class);
|
||||
|
||||
$this->assertFalse($svc->canUsePaymentGateway($user));
|
||||
$this->assertFalse(app(\App\Services\Payments\MerchantGatewayService::class)->isConfigured($user));
|
||||
}
|
||||
|
||||
public function test_pro_user_can_use_payment_gateway_when_configured(): void
|
||||
{
|
||||
Http::fake(['*/debit' => Http::response(['id' => 1], 201)]);
|
||||
$user = $this->user();
|
||||
$svc = app(SubscriptionService::class);
|
||||
$svc->subscribe($user);
|
||||
|
||||
\App\Models\PaymentGatewaySetting::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'provider' => \App\Models\PaymentGatewaySetting::PROVIDER_PAYSTACK,
|
||||
'public_key' => 'pk_test',
|
||||
'secret_key' => 'sk_test',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->assertTrue($svc->canUsePaymentGateway($user));
|
||||
$this->assertTrue(app(\App\Services\Payments\MerchantGatewayService::class)->isConfigured($user));
|
||||
}
|
||||
|
||||
public function test_free_user_settings_ignores_gateway_credentials(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
\App\Models\PosLocation::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'name' => 'Main',
|
||||
'currency' => 'GHS',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->put(route('pos.settings.update'), [
|
||||
'name' => 'Main',
|
||||
'currency' => 'GHS',
|
||||
'service_style' => 'retail',
|
||||
'printer_paper_mm' => 80,
|
||||
'gateway_provider' => \App\Models\PaymentGatewaySetting::PROVIDER_PAYSTACK,
|
||||
'gateway_public_key' => 'pk_free_blocked',
|
||||
'gateway_secret_key' => 'sk_free_blocked',
|
||||
'gateway_is_active' => '1',
|
||||
])
|
||||
->assertRedirect()
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertNull(
|
||||
\App\Models\PaymentGatewaySetting::query()->where('owner_ref', $user->public_id)->first()
|
||||
);
|
||||
}
|
||||
|
||||
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