Repository navigation
feat(apm)(POCP-1408): poll the payment while the redirect tab is open - #300
Draft
lukasz-k-bieszczad-cko wants to merge 1 commit into
Draft
lukasz-k-bieszczad-cko wants to merge 1 commit into
lukasz-k-bieszczad-cko wants to merge 1 commit into
Conversation
lukasz-k-bieszczad-cko
force-pushed
the
feat/apm-sessions-redirect-polling
branch
from
December 3, 2026 14:51
1c8c34f to
8e85d6e
Compare
A deep link, or a Universal Link that opens the provider app, never posts
back from the redirect tab, and a return through checkout can land in a
new tab the widget does not know. The redirect step then ended with
`customer.canceled` (`tab_closed`) or waited forever.
Polling now uses the mobile SDK backoff, 150 ms * 1.45^n clamped to
3-90 s with no jitter, capped by `confirmation.timeout`. The pending
polling uses it too, instead of a fixed 1 s. A poll runs at once when the
page becomes visible again, and `initialise` and `sendFormData` restart
the backoff.
`APIImpl.pollRedirect` starts when the redirect tab opens and POSTs
apm-payment. The payment has left the step when `action_id` changes, or,
without one, when the answer is no longer a REDIRECT to the same origin
and path. Status 0, 409 (api lock busy) and >500 retry at the next step;
validation and api errors count as left. On left, the tab closes through
the new silent `ActionHandler.cancel({ silent: true })`, the view emits
`redirect-completed` once and reloads the step, which emits `success`.
At `confirmation.timeout` the chain ends silently.
When the tab is closed, `checkRedirectOnce` polls once before failing,
and the old `customer.canceled` path runs only if nothing changed.
Also fixes network retries without limit: a retry spread the original
options back over the decremented `serviceRetries`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukasz-k-bieszczad-cko
force-pushed
the
feat/apm-sessions-redirect-polling
branch
from
December 3, 2026 14:56
8e85d6e to
2081933
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.
Description
A deep link, or a Universal Link that opens the provider app, never posts back from the redirect tab. A return through checkout can also land in a new tab the widget doesn't know about. In both cases the redirect step ended with
customer.canceled(tab_closed) or waited forever. #298 now opens deep links when there is no web link, so this PR is what makes them complete.Agreed on the APM sync (2026-12-03): processout.js polls the payment during the redirect step and stops when the backend returns a different
action_id.Stacked on #298.
Solution
src/apm/API.ts): the mobile SDK values, 150 ms × 1.45ⁿ clamped to 3–90 s, with no jitter. The wait is capped byconfirmation.timeout(900 s by default).visibilitychange), the scheduled poll runs at once and the backoff restarts.initialiseandsendFormDatarestart it too.APIImpl.pollRedirect, started byviews/Redirect.tswhen the tab opens): each poll is POSTapm-payment.action_iddiffers from the step's. Without anaction_id, it has left when the answer is no longer a REDIRECT to the same origin and path. Query and hash are ignored, and custom schemes need an exact match.ActionHandler.cancel({ silent: true }), with no error and no telemetry. The view emitsredirect-completedonce and reloads the step, and that reload emitssuccess. The poll itself never emitssuccess.confirmation.timeoutthe chain ends silently. The tab's postMessage path keeps working.APIImpl.checkRedirectOnce): one last poll before failing. If the payment left the step, the page reloads as above. If nothing changed, or the poll failed on the network, the oldcustomer.canceledfailure path runs.serviceRetries.Demo
Not tested against the api yet, because the api doesn't send
action_idyet. Covered by unit tests: 482 in 12 files, including the newtest/apm/redirect-view.test.tsand silent-cancel tests forActionHandler. They cover the backoff timing, the stop rule, retries, timeouts, the visibility reset, the last poll, and races with reloads, unmounts and second clicks.Checklist
yarn bump-versionNotes
customer.canceled.action_idis missing.action_idas a top-level field onapm-paymentanswers.Jira Issue
POCP-1408
🤖 Generated with Claude Code