fix(browser): share Apple Pay SDK load across instances - #1012
Merged
Alexander (alexander-rw) merged 8 commits intoSep 8, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 8cc2f70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Closed
Alexander (alexander-rw)
force-pushed
the
alexander-rw/applepay-availability-two-instance-fix
branch
from
September 8, 2026 09:56
9e56bbb to
9002850
Compare
CARD-1247. #exchangeApplePaymentData returned res.json() without checking res.ok, so a 500 from /frontend/apple-pay/credentials was handed back as if it were a successful exchange. It passed the tryCatch that guards the call and the handler then died on encrypted.card.displayName — thrown outside the caught region, so no error event fired and response.complete() was never called, leaving the sheet spinning until Apple timed it out. Check the status and the body shape, and complete the sheet as failed on the error path so a credentials failure reaches the merchant's error handler. The message is built from the documented API Error schema (detail, falling back to title) plus the HTTP status. Found while investigating the Upgrow outage, where this masked a five-day server-side failure across ~30 real customer authorizations.
A second ApplePayButton on the same page found the first instance's script tag before Apple's SDK had executed, resolved its script wait immediately, and cached the resulting "unsupported" for the life of the instance, so the button never mounted. Move script loading to a single module-level promise and stop memoizing an "unsupported" availability result.
Alexander (alexander-rw)
force-pushed
the
alexander-rw/applepay-availability-two-instance-fix
branch
from
September 8, 2026 10:07
9002850 to
247c5f8
Compare
Alexander (alexander-rw)
changed the base branch from
master
to
alexander-rw/card-1247-apple-pay-web-a-failed-credentials-exchange-throws-an
September 8, 2026 10:09
This was referenced Sep 8, 2026
Alexander (alexander-rw)
changed the base branch from
alexander-rw/card-1247-apple-pay-web-a-failed-credentials-exchange-throws-an
to
master
September 8, 2026 10:12
Max Harrison (maxharrison)
approved these changes
Sep 8, 2026
Alexander (alexander-rw)
deleted the
alexander-rw/applepay-availability-two-instance-fix
branch
September 8, 2026 12:36
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.
Why
Before: Creating two
ui.applePay()buttons on the same page could stop the second button from appearing. It could check availability before Apple’s SDK had loaded, return"unsupported", and cache that result.This change shares the Apple SDK load between buttons. It also waits for the SDK before rendering the Apple Pay button, handles script-load failures, and allows a later button to retry after an Evervault-injected script fails.
It also improves failed Apple Pay credential exchanges. Failed responses now call the configured
errorhandler and close the Apple Pay sheet as failed, rather than causing an uncaught error and leaving the sheet open.