Skip to content

Payments flow adaptation for lazy payments#3

Open
Tiago-Salles wants to merge 1 commit into
nau/teak.masterfrom
Tiago-Salles/issues/767-lazy-payments-flow
Open

Payments flow adaptation for lazy payments#3
Tiago-Salles wants to merge 1 commit into
nau/teak.masterfrom
Tiago-Salles/issues/767-lazy-payments-flow

Conversation

@Tiago-Salles

@Tiago-Salles Tiago-Salles commented May 17, 2026

Copy link
Copy Markdown

Context

When the user clicks Continuar on PayGate for asynchronous payment methods (MB references, MBWAY), the upstream payment is not yet confirmed at that moment. The previous flow tried to resolve the payment synchronously on the success callback, which raised GatewayError and displayed a misleading "You have not been charged." page — even when PayGate would later confirm the payment.

The chosen solution avoids background jobs entirely. Instead:

  1. PayGate's success callback now redirects to a Thank-You page in this MFE.
  2. The Thank-You page sends the user to the existing Order History page.
  3. The Order History page lazily consults the payment processor (per row, on render) through two new nau_extensions endpoints; on confirmation, the Order is created in place. Pending rows stay visible with a clear status badge instead of being hidden or wrongly reported as failed.

This PR implements the frontend part of that flow. The backend bits ship in companion PRs (ecommerce-plugin-paygate and ecommerce-nau-extensions).

What this PR adds

Thank-You page

  • src/thank-you/ThankYouPage.jsx — New page reached after the PayGate "success" callback. Reads the order_number query parameter (passed by PayGateCallbackSuccessResponseView), shows a heading, an explanatory body (mentions that some payment methods are confirmed asynchronously), the order number when known, and a primary "My orders" Paragon Button linking to /orders.
  • src/thank-you/ThankYouPage.messages.js — New i18n messages for heading, body, order-number line, and button label.
  • index.js — Public re-export.
  • index.jsx — Registered the new /thank-you route alongside the existing /orders route.
image

Order History — Status column, action buttons, lazy resolution

  • service.js — Added two helpers that call the new nau_extensions endpoints:

    • fetchBasketPaymentStatus(orderNumber)GET /payment/nau_extensions/basket-payment-status/?order_number=…
    • fetchPendingBaskets()GET /payment/nau_extensions/pending-baskets/

    getOrders() now also merges the pending baskets returned by the second endpoint into the table so that in-flight asynchronous payments are visible right next to confirmed orders. Existing fulfilled orders are flagged with status: "paid".

  • OrderHistoryPage.jsx:

    • Adds component state for per-row statusOverrides and courseUrlOverrides.
    • On mount and whenever the orders prop changes, iterates over every row whose status is not paid and calls fetchBasketPaymentStatus. This is the single place where PayGate is consulted, and only while the user is on this page (no background work).
    • New Status column with a badge per state: paid, pending, failed (data-testid provided for tests).
    • New Actions column that renders, only for paid rows, the existing "Order details" link (using the receipt URL) and the new "Go to course" link (using course_url returned by the backend). For non-paid rows, the cell is empty.
    • Mobile view updated accordingly.
  • OrderHistoryPage.messages.jsx — New messages for the column headers (Status, Actions), the status labels (Paid, Pending payment, Payment failed) and the new action label (Go to course).

  • src/order-history/__snapshots__/OrderHistoryPage.test.jsx.snap — Removed so jest regenerates it with the new columns. The snapshot test still runs and will commit the new baseline on first run.

image

User flow after this PR

  1. User clicks Continuar on PayGate → PayGate redirects to its success callback.
  2. The success callback (paygate plugin PR) redirects to <MFE>/thank-you?order_number=<basket.order_number>.
  3. The Thank-You page appears with the order number and a "My orders" button.
  4. "My orders" navigates to /orders (existing Order History page).
  5. The page renders the table including any pending baskets and, for each non-paid row, lazily calls BasketPaymentStatusView. Confirmed payments flip to paid, fulfilling the order in place; still-pending payments keep the "Pending payment" badge; failures show "Payment failed".
  6. Paid rows expose the existing "Order details" link plus the new "Go to course" button.

Related PRs

Related to: https://github.com/fccn/nau-technical/issues/767

@Tiago-Salles Tiago-Salles force-pushed the Tiago-Salles/issues/767-lazy-payments-flow branch from fa04a11 to 8a90d4a Compare May 17, 2026 17:55
@Tiago-Salles Tiago-Salles marked this pull request as ready for review May 19, 2026 09:21
@Tiago-Salles Tiago-Salles force-pushed the Tiago-Salles/issues/767-lazy-payments-flow branch from 8a90d4a to fb23ff1 Compare May 30, 2026 20:57
@Tiago-Salles Tiago-Salles force-pushed the Tiago-Salles/issues/767-lazy-payments-flow branch from fb23ff1 to 8ef773c Compare June 2, 2026 01:21
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.

1 participant