Skip to content

fix(browser): share Apple Pay SDK load across instances - #1012

Merged
Alexander (alexander-rw) merged 8 commits into
masterfrom
alexander-rw/applepay-availability-two-instance-fix
Sep 8, 2026
Merged

fix(browser): share Apple Pay SDK load across instances#1012
Alexander (alexander-rw) merged 8 commits into
masterfrom
alexander-rw/applepay-availability-two-instance-fix

Conversation

@alexander-rw

@alexander-rw Alexander (alexander-rw) commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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 error handler and close the Apple Pay sheet as failed, rather than causing an uncaught error and leaving the sheet open.

@alexander-rw
Alexander (alexander-rw) requested a review from a team as a code owner September 8, 2026 09:41
@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8cc2f70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@evervault/browser Patch
@evervault/inputs Patch
example-apple-pay Patch
example-react-google-wallet Patch
@evervault/browser-e2e-tests Patch
e2e-tests-ui-components-vanilla-server Patch
@evervault/inputs-e2e-tests Patch

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

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-rw
Alexander (alexander-rw) force-pushed the alexander-rw/applepay-availability-two-instance-fix branch from 9002850 to 247c5f8 Compare September 8, 2026 10:07
@alexander-rw
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
@alexander-rw
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
@evervault Evervault (evervault) deleted a comment from claude Bot Sep 8, 2026
@alexander-rw
Alexander (alexander-rw) added this pull request to the merge queue Sep 8, 2026
Merged via the queue into master with commit fc87e61 Sep 8, 2026
15 checks passed
@alexander-rw
Alexander (alexander-rw) deleted the alexander-rw/applepay-availability-two-instance-fix branch September 8, 2026 12:36
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.

2 participants