Skip to content

fix: fix customer cancelled typo - #276

Open
jakubjasinsky wants to merge 2 commits into
masterfrom
jakub-fix-dc-cancelled-error-code
Open

fix: fix customer cancelled typo#276
jakubjasinsky wants to merge 2 commits into
masterfrom
jakub-fix-dc-cancelled-error-code

Conversation

@jakubjasinsky

Copy link
Copy Markdown
Collaborator

Summary

In Dynamic Checkout, cancelling a payment on a gateway's hosted page (e.g. KCP) fired processout_dynamic_checkout_payment_error instead of processout_dynamic_checkout_payment_cancelled. Reported by Caterpillar via KCP.

Changes

  • Add isCustomerCancellationError helper that matches both customer.canceled (SDK-internal: overlay cancel, tab closed) and customer.cancelled (API error code returned when the customer cancels on the gateway's page)
  • Use it at all 6 cancellation checks in DC payment methods (apm, saved-apm, saved-card, card), which previously only matched the SDK-internal spelling
  • Add unit tests for the helper + a generic namespace-file loader in the test harness
  • Bump version to 1.9.11

Additional Context

  • Root cause: tessel9 normalizes gateway-page cancels to customer.cancelled (two "l"s), which reaches the SDK via the checkout page's error action and failed the strict customer.canceled check
  • Not KCP-specific — Klarna, RevolutPay, Xendit and others map to the same code
  • actionhandler.ts is intentionally untouched so legacy (non-DC) integrations keep receiving the raw error code
  • tab_closed stays correct: backend-originated cancels carry no tab_closed metadata, so it reports false

Copilot AI lite review requested due to automatic review settings August 5, 2026 07:17
@jakubjasinsky jakubjasinsky changed the title Jakub fix dc cancelled error code fix: fix customer cancelled typo Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isCustomerCancellationError to treat both customer.canceled and customer.cancelled as 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.

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.

2 participants