Files
ladill-give/tests/Feature/PaymentGatewayPolicyTest.php
isaacclad 5d642900c5
Deploy Ladill Give / deploy (push) Successful in 58s
Require Ladill Pay only for Give donations.
Remove custom/owner payment gateway option and always collect donations through Ladill Pay with platform fees.
2026-07-24 14:15:43 +00:00

34 lines
1.2 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\PaymentGatewaySetting;
use App\Models\User;
use App\Services\Billing\PlanEntitlementService;
use App\Services\Payments\MerchantGatewayService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class PaymentGatewayPolicyTest extends TestCase
{
use RefreshDatabase;
public function test_owner_gateway_is_never_used_even_with_saved_keys(): void
{
config(['billing.api_url' => 'https://ladill.com/api/billing', 'billing.api_key' => 'give-test']);
$owner = User::factory()->create(['public_id' => 'usr_give_policy']);
PaymentGatewaySetting::create([
'owner_ref' => $owner->public_id, 'provider' => 'paystack',
'public_key' => 'pk_test_saved', 'secret_key' => 'sk_test_saved', 'is_active' => true,
]);
Http::fake(['*/suite-entitlements*' => Http::response(['data' => [
'effective_plan' => 'enterprise', 'features' => ['custom_payment_gateway'],
]])]);
$this->assertFalse(app(PlanEntitlementService::class)->canUseCustomPaymentGateway($owner));
$this->assertFalse(app(MerchantGatewayService::class)->shouldUseOwnerGateway($owner));
}
}