refactor(checkout): remove unused completion endpoint

This commit is contained in:
2026-08-27 12:11:08 -03:00
parent 2524f00dfd
commit 971c5f6cd9
6 changed files with 2 additions and 115 deletions

View File

@@ -898,57 +898,6 @@ class StorePurchaseTest extends TestCase
]);
}
public function test_it_moves_a_created_purchase_to_pending_payment_when_finalized(): void
{
$tenant = $this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
$user = User::factory()->create([
'email' => 'buyer@example.com',
]);
$variant = $this->createVariantForTenant('sonder', 10, '50.00');
$cartId = $this->actingAs($user, 'sanctum')
->postJson('/api/tenants/sonder/cart/items', [
'catalog_item_id' => $variant->catalog_item_id,
'variant_id' => $variant->id,
'cantidad' => 2,
])
->assertOk()
->json('data.id');
$purchaseId = $this->actingAs($user, 'sanctum')
->postJson('/api/tenants/sonder/compras/start-checkout', [
'cart_id' => $cartId,
])
->assertCreated()
->json('data.id');
Purchase::query()
->whereKey($purchaseId)
->update([
'payment_method' => 'transfer',
]);
$this->actingAs($user, 'sanctum')
->postJson("/api/tenants/sonder/compras/{$purchaseId}/complete")
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_PENDING_PAYMENT);
$this->assertDatabaseHas('compras', [
'id' => $purchaseId,
'status' => Purchase::STATUS_PENDING_PAYMENT,
'payment_method' => 'transfer',
]);
$this->assertDatabaseHas('value_changes', [
'trackable_type' => (new Purchase)->getMorphClass(),
'trackable_id' => $purchaseId,
'attribute' => 'status',
'old_value' => Purchase::STATUS_CREATED,
'new_value' => Purchase::STATUS_PENDING_PAYMENT,
'actor_type' => 'user',
'user_id' => $user->id,
]);
}
public function test_it_moves_a_submitted_purchase_to_review_idempotently(): void
{
$this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
@@ -984,11 +933,6 @@ class StorePurchaseTest extends TestCase
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_IN_REVIEW);
$this->actingAs($user, 'sanctum')
->postJson("/api/tenants/sonder/compras/{$purchase->id}/complete")
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_IN_REVIEW);
$this->actingAs($user, 'sanctum')
->postJson("/api/tenants/sonder/compras/{$purchase->id}/payment-intent", [
'method' => 'qr',
@@ -1204,10 +1148,9 @@ class StorePurchaseTest extends TestCase
$purchase->update([
'payment_method' => 'transfer',
'status' => Purchase::STATUS_PENDING_PAYMENT,
]);
app(CheckoutService::class)->completePurchase($purchase);
$this->actingAs($user, 'sanctum')
->getJson("/api/tenants/sonder/compras/{$purchase->id}")
->assertOk()
@@ -1260,7 +1203,6 @@ class StorePurchaseTest extends TestCase
]);
$checkoutService = app(CheckoutService::class);
$purchase = $checkoutService->completePurchase($purchase);
$checkoutService->confirmPurchase($purchase);
$purchase->refresh()->markAsPaid();
@@ -1478,7 +1420,6 @@ class StorePurchaseTest extends TestCase
$purchase->update(['payment_method' => 'transfer']);
$checkoutService = app(CheckoutService::class);
$purchase = $checkoutService->completePurchase($purchase);
$checkoutService->confirmPurchase($purchase);
$checkoutService->confirmPurchase($purchase);