Open
Conversation
tomasz-pazdziurek-cko
previously approved these changes
Mar 4, 2026
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
Normalize all Dynamic Checkout event payloads to consistently include
invoice_id, use snake_case keys, and flatten nested data structures. This ensures consumers receive a uniform event shape regardless of the event type, and adds missing events (tokenize_payment_success) to payment methods that were not dispatching them.Changes
Event payload normalization (
events.ts)invoiceIdas a parameter and includeinvoice_idin every event payloadinvoiceId→invoice_id,returnUrl→return_url){ details: { ... } }wrapping indispatchPaymentSubmittedEvent,dispatchPaymentCancelledEvent, anddispatchPaymentPendingEvent— data is now passed directly as the event detailreasonfield to payment error and pending event payloadserrorDatanormalization indispatchPaymentErrorEventto handle non-object errors (e.g., string) safely before spreadingTokenize success event coverage
dispatchTokenizePaymentSuccessEventtocard.ts,apm.ts(both regular and save-for-future flows), andsaved-apm.tsapple-pay.tsandgoogle-pay.tsdispatched this eventPending callback signature update (
processout.ts)makeCardPaymentpending callback from(data: any) => voidto(resourceId: string, reason: string | null) => voiddata?.messageas the reasonNative APM improvements (
native-apm.ts)onPaymentSubmitcallback, invoked onPAYMENT_INIT, so Dynamic Checkout can dispatchpayment_submittedfor native APM methodsApple Pay / Google Pay event fixes
dispatchApplePaySessionErrorwhich previously created the event but never included the error in the payloadthiscontext forinvoiceIdExample HTML cleanup
Impact
invoice_idinstead ofinvoiceId). Thepayment_submitted,payment_cancelled, andpayment_pendingevents no longer nest data undere.detail.details— fields are now directly one.detail.makeCardPaymentpending callback: Signature changed from(data) => voidto(resourceId, reason) => void.Testing Plan
invoice_idin its payloadtokenize_payment_successfires with{ token, invoice_id }tokenize_payment_successfires after redirecttokenize_payment_successfirestokenize_payment_successfirespayment_errorevent includesinvoice_idandreasonpayment_pendingevent includesinvoice_id,payment_method_name, andreasondirectly one.detail(not nested underdetails)invoice_idpayment_submittedevent fires on inite.detail.detailsnesting exists on any eventAdditional Context
The previous event system had inconsistent shapes: some events included
invoice_id, some didn't; some used camelCase, some snake_case; some wrapped data in{ details }, others didn't. This made it difficult for consumers to rely on a consistent contract. This PR establishes a uniform pattern: every event includesinvoice_id, all keys are snake_case, and no unnecessary nesting.