fix: fix customer cancelled typo - #276
Open
jakubjasinsky wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Dynamic Checkout cancellation detection so that cancellations occurring on gateway-hosted pages (which can surface as customer.cancelled) correctly trigger processout_dynamic_checkout_payment_cancelled instead of processout_dynamic_checkout_payment_error.
Changes:
- Introduces
isCustomerCancellationErrorto treat bothcustomer.canceledandcustomer.cancelledas customer cancellations. - Replaces all six Dynamic Checkout payment-method cancellation checks to use the new helper.
- Adds unit tests (plus a small test harness helper) and bumps version to
1.9.11.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/support/loadNamespace.ts | Adds loadNamespaceFile helper to execute a single namespace-style source file in tests and return the ProcessOut namespace. |
| test/dynamic-checkout/errors.test.ts | Adds unit tests validating isCustomerCancellationError behavior for both spellings and non-cancellation codes. |
| src/dynamic-checkout/utils/errors.ts | Adds isCustomerCancellationError helper to unify cancellation detection across SDK-internal and API-reported codes. |
| src/dynamic-checkout/references.ts | Includes the new utils/errors.ts file in the Dynamic Checkout outFile reference list. |
| src/dynamic-checkout/payment-methods/saved-card.ts | Switches cancellation check to isCustomerCancellationError. |
| src/dynamic-checkout/payment-methods/saved-apm.ts | Switches both cancellation checks to isCustomerCancellationError. |
| src/dynamic-checkout/payment-methods/card.ts | Switches cancellation check to isCustomerCancellationError. |
| src/dynamic-checkout/payment-methods/apm.ts | Switches both cancellation checks to isCustomerCancellationError. |
| package.json | Bumps package version from 1.9.10 to 1.9.11. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
In Dynamic Checkout, cancelling a payment on a gateway's hosted page (e.g. KCP) fired
processout_dynamic_checkout_payment_errorinstead ofprocessout_dynamic_checkout_payment_cancelled. Reported by Caterpillar via KCP.Changes
isCustomerCancellationErrorhelper that matches bothcustomer.canceled(SDK-internal: overlay cancel, tab closed) andcustomer.cancelled(API error code returned when the customer cancels on the gateway's page)apm,saved-apm,saved-card,card), which previously only matched the SDK-internal spellingAdditional Context
customer.cancelled(two "l"s), which reaches the SDK via the checkout page'serroraction and failed the strictcustomer.canceledcheckactionhandler.tsis intentionally untouched so legacy (non-DC) integrations keep receiving the raw error codetab_closedstays correct: backend-originated cancels carry notab_closedmetadata, so it reportsfalse