Repository navigation
fix: dispatch apple pay session events in dc - #288
Open
jakubjasinsky wants to merge 2 commits into
Open
jakubjasinsky wants to merge 2 commits into
jakubjasinsky wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the Apple Pay session-event changes.
No open issues 🎉
What changed in this PR
This PR enables the documented Apple Pay session events in Dynamic Checkout while preserving the existing behavior of callbacks passed to newSession().
Changes:
- Adds merchant-validation handlers and connects them to session success and error events.
- Standardizes session error payloads to
error_typeanderror_message, including constructor failures. - Adds regression tests and bumps the version to 1.9.21.
| File | Description |
|---|---|
test/support/loadNamespace.ts |
Adds an Apple Pay loader with an injectable browser session. |
test/processout/applepay.test.ts |
Tests validation handlers and existing callback behavior. |
test/dynamic-checkout/wallet-events.test.ts |
Tests session event dispatch and error payloads. |
src/processout/applepay.ts |
Adds validation handlers and shared validation-error handling. |
src/processout/applepay-wrapper.ts |
Makes the unused success callback optional and documents compatibility. |
src/dynamic-checkout/utils/events.ts |
Normalizes Apple Pay session error payloads. |
src/dynamic-checkout/clients/apple-pay.ts |
Wires validation events and reports constructor failures. |
package.json |
Bumps the version to 1.9.21. |
Review effort: Balanced
tomasz-pazdziurek-cko
approved these changes
Nov 12, 2026
Comment on lines
+57
to
+58
| * @param {callback} onsuccess unused, kept for backward compatibility | ||
| * @param {callback} onerror unused, kept for backward compatibility |
Contributor
There was a problem hiding this comment.
Does it make sense to add @deprecated as well?
As far as I understand, we cannot just remove them, because this constructor function may be used by the external callers directly (i.e. merchants)?
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.
Summary
processout_dynamic_checkout_apple_pay_new_sessionandprocessout_dynamic_checkout_apple_pay_session_errorare documented but never fired: Dynamic Checkout passed the dispatchers as callbacks toapplePay.newSession(), which has always ignored them.Changes
ApplePaygets two optional handlers,onmerchantvalidatedandonmerchantvalidationerror(same pattern asoncancel/onpaymentauthorizedPostprocess); Dynamic Checkout uses them to dispatch the eventsapple_pay_new_sessionfires once the merchant is validated;apple_pay_session_errorfires when merchant validation fails or theApplePaySessionconstructor throwsapple_pay_session_errorpayload is nowerror_type/error_message, as documented, instead of the spread raw exceptionnewSessionbehaviourImpact
applePay.newSession()directly: its callbacks are still accepted and still never called (onsuccessis now optional in the type)apple_pay_session_errorfollowed by the existingpayment_error, so listeners on both get bothAdditional Context
newSession()honour its callbacks was rejected as a backward-compatibility risk: integrations passing tokenization-style handlers there would have them run at merchant validation