fix(napm): report failed web redirect to backend when confirmation is required - #536
fix(napm): report failed web redirect to backend when confirmation is required#536dbashtani wants to merge 1 commit into
Conversation
… 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.
|
Hi @dbashtani, thank you for the suggestion! Currently the only use case for confirmation is to allow fallback from deep link to web redirect. So while the use case you described is possible in theory, it's not in possible in practise (also because confirmation is not required for web redirects). |
@andrii-vysotskyi-cko Thanks for the explanation, that makes sense — I didn't realize the confirmation is only there for the deep link → web fallback. So yeah, this change would never actually fire. |
Correct
For now probably not. SDK change alone won't suffice since backend won't change payment's state even if it receives false for a web redirect confirmation. BTW the topic itself is broader than redirects, for example customer dismissing payment screen (or clicking cancel button) won't cause payment to transition to failed state either. |
Fixes #535
Problem
When a
web-type redirect fails during a native alternative payment (customer closesASWebAuthenticationSession, or the session fails to start),uncheckedRedirect(to:)throws beforecontinuePaymentis called. The merchant app receivesprocessout-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_linkbranch, which reports.init(success: didOpenUrl)whenredirect.confirmationRequiredis set.Change
On web redirect failure, when
redirect.confirmationRequiredistrue, reportredirect: .init(success: false)viacontinuePayment— mirroring the deep link semantics — then rethrow the original error.confirmationRequired, the backend's existing opt-in flag, so no confirmations are sent that the backend didn't ask for.try?): a network failure during the report cannot mask the original failure.POFailurepropagates, same events are emitted.Open questions for review
success: falsefor web redirects (fail attempt vs. allow retry) — please confirm the desired invoice transition.handleWebRedirect(failure:)completes locally without sending a redirect confirmation); if this change is accepted, a matching fix there would keep platforms consistent.