feat: add reason to payment cancelled for dc#245
Merged
jakubjasinsky merged 3 commits intomasterfrom Mar 16, 2026
Merged
Conversation
tomasz-pazdziurek-cko
approved these changes
Mar 16, 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
Adds a
tab_closedreason to the payment cancelled event in Dynamic Checkout. When a customer closes the APM payment tab, the cancellation event now includes metadata indicating the tab was closed, allowing consumers to distinguish between different cancellation reasons.Changes
src/processout/exception.ts: ExtendedExceptionclass with an optionalmetadataproperty (ExceptionMetadatainterface) to carry additional context alongside error codessrc/processout/actionhandler.ts: Pass{ reason: "tab_closed" }metadata when creating thecustomer.canceledexception upon payment window closuresrc/dynamic-checkout/payment-methods/apm.ts: Readerror.metadata?.reasonand includetab_closed: true/falsein the payment cancelled event payloadsrc/dynamic-checkout/utils/events.ts: Added optionaltab_closedboolean to thePAYMENT_CANCELLEDevent type definitionImpact
metadatais optional onExceptionandtab_closedis optional on the event payloadPAYMENT_CANCELLEDevent can now react differently when the user explicitly closed the payment tab vs other cancellation scenariosTesting Plan
PAYMENT_CANCELLEDevent payload includestab_closed: truetab_closedisfalseor absentAdditional Context
ExceptionMetadatainterface uses an index signature ([key: string]: any) to keep it flexible for future use cases beyondreasonactionhandler.tsthat was added to investigate payment window closure issues