Skip to content

Payments flow adaptation for lazy payments#27

Open
Tiago-Salles wants to merge 1 commit into
mainfrom
Tiago-Salles/issues/767-lazy-payments-flow
Open

Payments flow adaptation for lazy payments#27
Tiago-Salles wants to merge 1 commit into
mainfrom
Tiago-Salles/issues/767-lazy-payments-flow

Conversation

@Tiago-Salles

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

Copy link
Copy Markdown
Contributor

Context

When the user clicks Continuar on PayGate, PayGate redirects back to PayGateCallbackSuccessResponseView. Until now, this view called handle_payment_and_create_order synchronously, which in turn invoked PayGate.handle_processor_response. That method queries the PayGate BackOfficeSearchTransactions API expecting to find a completed transaction for the basket.

For asynchronous payment methods (MB references, MBWAY) the upstream payment is not yet confirmed at this exact moment — the user still has to pay at an ATM / home-banking / phone. PayGate correctly returns an empty list, handle_processor_response raises:

oscar.apps.payment.exceptions.GatewayError: PayGate couldn't double check if basket has been payed

…and the user is shown the misleading "You have not been charged." page even when, minutes later, PayGate will confirm the payment via the server-to-server callback.

What this PR changes

The success callback no longer attempts to fulfil the order synchronously when a Thank-You URL is configured. Instead, it records the callback response and redirects the user to a Thank-You page in the ecommerce micro-frontend, where the actual payment status is lazily resolved per basket by the new nau_extensions.BasketPaymentStatusView.

  • processors.pyPayGate now exposes a new thank_you_url property that reads the optional thank_you_url payment-processor configuration entry. Returns None when not configured.
  • views.pyPayGateCallbackSuccessResponseView.get:
    • records the PayGate callback as before;
    • if thank_you_url is configured → redirects to <thank_you_url>?order_number=<basket.order_number> without calling handle_payment_and_create_order and without calling PayGate BackOfficeSearchTransactions;
    • if thank_you_url is not configured → falls back to the previous behaviour (synchronous fulfillment + redirect to the receipt page). This preserves backwards compatibility for any deployment that has not yet rolled out the Thank-You page.

Configuration

Add thank_you_url to the paygate entry of PAYMENT_PROCESSOR_CONFIG to enable the new behaviour. Example:

paygate:
  access_token: PwdX_XXXX_YYYY
  merchant_code: NAU
  api_checkout_url: https://lab.optimistic.blue/paygateWS/api/CheckOut
  api_back_search_transactions: https://lab.optimistic.blue/paygateWS/api/BackOfficeSearchTransactions
  api_basic_auth_user: username
  api_basic_auth_pass: password
  payment_types: ["VISA", "MASTERCARD", "MBWAY", "REFMB", "DUC"]
  # NEW: when set, the success callback redirects here instead of running
  # handle_processor_response synchronously. The basket order_number is
  # appended as a query string parameter.
  thank_you_url: https://orders.nau.edu.pt/thank-you

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 3f44420 to a4a28d4 Compare May 17, 2026 17:52
@Tiago-Salles Tiago-Salles marked this pull request as ready for review May 19, 2026 09:18
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