Skip to content

fix: fire onpaymentmethodselected in the Apple Pay wrapper - #293

Draft
roshan-gorasia-cko wants to merge 1 commit into
masterfrom
fix/applepay-paymentmethodselected
Draft

roshan-gorasia-cko wants to merge 1 commit into
masterfrom
fix/applepay-paymentmethodselected

Conversation

@roshan-gorasia-cko

Copy link
Copy Markdown
Contributor

Problem

ApplePay exposes a public onpaymentmethodselected handler, but the constructor never assigns session.onpaymentmethodselected. The handler never runs when the user changes card on the payment sheet.

Fix

tokenize() binds session.onpaymentmethodselected just before session.begin(), and only when the merchant has set a handler. Once the session has this handler, Apple waits for completePaymentMethodSelection on each card change. Binding it unconditionally would stall the sheet for integrations that never call it, Dynamic Checkout included.

Testing

  • Two new tests in test/processout/applepay.test.ts: the handler fires when set, and the session handler stays unset otherwise. The first fails on master with session.onpaymentmethodselected is not a function.
  • yarn lint, yarn build, yarn test (275 passed).
  • Not tested on a real Apple Pay sheet in Safari.

Version bumped to 1.9.22.

🤖 Generated with Claude Code

The constructor never bound session.onpaymentmethodselected, so a
merchant's handler never ran. Bind it in tokenize(), and only when a
handler is set, so integrations that don't handle it keep their current
sheet behaviour.

Bump version to 1.9.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant