refactor: remove PaymentProviderInterface and TelepagosProvider, simplify CheckoutService and related tests

This commit is contained in:
2026-07-03 16:55:11 -03:00
parent 057e6757dc
commit 0cb1c37566
7 changed files with 9 additions and 105 deletions

View File

@@ -5,7 +5,6 @@ namespace Tests\Feature\Purchase;
use App\Domains\Auth\Models\User;
use App\Domains\Catalog\Models\Product;
use App\Domains\Catalog\Models\ProductVariant;
use App\Domains\Integration\Models\Integration;
use App\Domains\Tenant\Models\Tenant;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -19,33 +18,12 @@ class StorePurchaseTest extends TestCase
// 1. Setup Tenant
$tenant = $this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
// 2. Setup Integration
$integration = Integration::create([
'integration_code' => 'telepagos',
'name' => 'Telepagos',
'url' => 'https://api.telepagos.com.ar',
'integration_data_schema' => [
'username' => 'required|string',
'password' => 'required|string',
]
]);
$tenantIntegrationService = app(\App\Domains\Integration\Services\TenantIntegrationService::class);
$tenantIntegrationService->updateOrCreateIntegration(
'sonder',
$integration,
[
'username' => 'sonder_telepagos',
'password' => 'secret123',
]
);
// 3. Setup User
// 2. Setup User
$user = User::factory()->create([
'email' => 'buyer@example.com'
]);
// 4. Setup Product & Variant
// 3. Setup Product & Variant
$category = \App\Domains\Catalog\Models\Category::query()->create([
'tenant_code' => 'sonder',
'nombre' => 'Test Category',
@@ -68,7 +46,7 @@ class StorePurchaseTest extends TestCase
'precio' => '50.00',
]);
// 5. Add item to user's cart
// 4. Add item to user's cart
$this->actingAs($user, 'sanctum')
->postJson('/api/tenants/sonder/cart/items', [
'product_variant_id' => $variant->id,
@@ -82,17 +60,14 @@ class StorePurchaseTest extends TestCase
'user_id' => $user->id,
]);
// 6. Submit Purchase
// 5. Submit Purchase with payment_method at root
$response = $this->actingAs($user, 'sanctum')
->postJson('/api/tenants/sonder/compras', [
'dni' => '987654321',
'telefono' => '+54 9 341 555-4321',
'nombre_apellido' => 'Juan Perez',
'email' => 'juan.perez@example.com',
'integration_code' => 'telepagos',
'payment_data' => [
'payment_method' => 'transferencia',
],
'payment_method' => 'transferencia',
'items' => [
[
'producto_variante_id' => $variant->id,
@@ -101,7 +76,7 @@ class StorePurchaseTest extends TestCase
]
]);
// 7. Assertions
// 6. Assertions
$response->assertCreated();
$response->assertJsonPath('data.dni', '987654321');
$response->assertJsonPath('data.telefono', '+54 9 341 555-4321');