Skip to content

fix(checkout): restaurar carrito al volver del redirect sin completar pago#5

Open
Sebah01a wants to merge 1 commit intomainfrom
fix/restore-quote-on-redirect
Open

fix(checkout): restaurar carrito al volver del redirect sin completar pago#5
Sebah01a wants to merge 1 commit intomainfrom
fix/restore-quote-on-redirect

Conversation

@Sebah01a
Copy link
Copy Markdown

@Sebah01a Sebah01a commented May 8, 2026

Contexto

Cuando el cliente vuelve al store sin completar el pago en Fintoc (botón atrás del navegador), el carrito aparece vacío. Magento cierra el carrito al crear la orden antes del redirect, y los handlers existentes con restoreQuote() solo se ejecutan cuando Fintoc redirige por cancel_url. Entonces cuando el usuario volvía atrás, por otro lado que no sea el cancel_url, no se restauraba el carrito.

quote = carrito

Causa raíz

  1. Place Order → Magento crea la orden → quote.is_active = 0 (carrito muerto)
  2. Plugin llama a Fintoc → recibe redirect_url
  3. Frontend redirige a pay.fintoc.com
  4. Si el usuario hace atrás del browser, nunca se llama a Commit controller → restoreQuote() no se ejecuta → /checkout/cart lo ve vacío.

Solución

Agregar un restoreQuote() en Controller/Checkout/Create.php justo antes de devolver el redirect_url al frontend.

Grabacion.de.pantalla.2026-05-08.a.la.s.5.35.15.p.m.mov

Magento consumes the quote (cart) when placing the order before
redirecting to Fintoc. If the customer hits browser back without
completing payment, the cart appears empty.

Restoring the quote right before returning the redirect_url keeps
the cart alive during the redirect. The success page clears the
quote naturally on payment completion; the cancel callback is
idempotent (already calls restoreQuote in processCancelAction).
@Sebah01a Sebah01a marked this pull request as ready for review May 8, 2026 14:08
throw new LocalizedException(__('Invalid response from Fintoc API'));
}

try {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No entendí, cuando se llama esto? Antes de redireccionar al usuario al Checkout de Fintoc? Si es así, no creo que sea la mejor opción, puede pasar que tengas 2 pagos al mismo tiempo para el mismo carrito.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La Anto me acuerdo que estaba haciendo algo para hacer expired el pago cuando el usuario se va de la página, tal vez es mejor escuchar ese webhook y con eso devolver el carrito

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esto se llama cuando el usuario vuelve del Checkout de Fintoc, pero no por el cancel_url, entonces lo que antes pasaba es que el carrito no se hacíaa restore (solo se hacía cuando llegaba por cancel_url). Por eso aplicamos esta misma lógica fuera del scope

@Sebah01a Sebah01a requested a review from Gonzalo9823 May 8, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants