Skip to content

fix(napm): report failed web redirect to backend when confirmation is required - #536

Open
dbashtani wants to merge 1 commit into
processout:masterfrom
dbashtani:fix/report-failed-web-redirect
Open

fix(napm): report failed web redirect to backend when confirmation is required#536
dbashtani wants to merge 1 commit into
processout:masterfrom
dbashtani:fix/report-failed-web-redirect

Conversation

@dbashtani

Copy link
Copy Markdown

Fixes #535

Problem

When a web-type redirect fails during a native alternative payment (customer closes ASWebAuthenticationSession, or the session fails to start), uncheckedRedirect(to:) throws before continuePayment is called. The merchant app receives processout-mobile.cancelled, but the backend is never informed — the invoice stays pending in the dashboard, disagreeing with the SDK-reported outcome.

This is inconsistent with the deep_link branch, which reports .init(success: didOpenUrl) when redirect.confirmationRequired is set.

Change

On web redirect failure, when redirect.confirmationRequired is true, report redirect: .init(success: false) via continuePayment — mirroring the deep link semantics — then rethrow the original error.

  • Gated on confirmationRequired, the backend's existing opt-in flag, so no confirmations are sent that the backend didn't ask for.
  • Best-effort (try?): a network failure during the report cannot mask the original failure.
  • Merchant-facing behavior is unchanged — the same POFailure propagates, same events are emitted.

Open questions for review

  1. Backend semantics of success: false for web redirects (fail attempt vs. allow retry) — please confirm the desired invoice transition.
  2. In the user-cancel path the surrounding task is cancelled, so the report request may be cancelled with it. If the report should be guaranteed there too, it would need an unstructured task shielded from cancellation — happy to adjust if that's preferred.
  3. The Android SDK has the same gap (handleWebRedirect(failure:) completes locally without sending a redirect confirmation); if this change is accepted, a matching fix there would keep platforms consistent.

… required

When a web redirect fails (customer cancels ASWebAuthenticationSession or
the session fails to start), the failure was only surfaced locally and
continuePayment was never invoked, leaving the invoice pending on the
backend while the merchant app received a cancellation failure.

This mirrors the existing deep link behavior, which reports
success: didOpenUrl when redirect.confirmationRequired is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Native APM v2: failed web redirect is never reported to the backend — invoice stays pending

1 participant