fix: restaurar carrito al volver del redirect sin completar pago#2
Open
fix: restaurar carrito al volver del redirect sin completar pago#2
Conversation
Magento consumes the quote when the order is placed. If the customer navigates back from Fintoc without completing payment, the cart appeared empty even though items were still in the database. Changes: - Create controller: restore the quote after obtaining the redirect URL so the cart stays active during the external payment flow. - JS payment renderer: reload the cart customer-data section before redirecting to Fintoc so localStorage reflects the restored cart. - Commit controller (success path): deactivate the quote, clear the session, and set order data so the success page renders correctly. - Success template: inline JS to invalidate and reload the cart section so the mini-cart clears after successful payment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d06769c to
47e8166
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexto
Cuando el cliente vuelve al store sin completar el pago en Fintoc (usando el botón atrás del navegador, cerrando la pestaña, etc.), el carrito aparece vacío. Esto ocurre porque Magento consume el quote al crear la orden antes del redirect.
Causa raíz
El flujo actual es:
placeOrderAction()en el JS crea la orden → consume el quote (carrito)/fintoc/checkout/create→ redirige al usuario a FintocCommitcontrollerCommitcontroller (acción cancel) ya tienerestoreQuote(), pero solo se ejecuta cuando Fintoc redirige a lacancel_urlSolución
Se agrega un plugin (before-interceptor) en
Magento\Checkout\Controller\Cart\Indexque detecta la situación y restaura el quote automáticamente.El plugin verifica las siguientes condiciones antes de restaurar:
PROCESSING,CANCELED, etc.)fintoc_transaction_status = success)Archivos agregados
Plugin/RestoreQuoteOnCartLoad.php— Plugin con la lógica de restauraciónetc/frontend/di.xml— Registro del plugin (scope frontend)Plan de pruebas
/checkout/cartbin/magento setup:upgrade+bin/magento cache:flushpost-deploy🤖 Generated with Claude Code