Skip to content

feat(core,paystack): tell the customer when the provider refuses the currency - #94

Open
moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:fix/clear-currency-refusal
Open

moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:fix/clear-currency-refusal

Conversation

@moset15

@moset15 moset15 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #85 (it changes packages/paystack). Please review it after #85; it then shows only its own commit.

Problem

Found while testing #85: a USD cart on a Paystack account that isn't enabled for USD. Paystack answers 403 unsupported_currency, create-session answers 500, and the customer sees "Payment couldn't start. Please try again in a moment". Retrying never helps.

Change

  • Core exports CurrencyNotSupportedError from @dashcommerce/core/payment-provider. A provider throws it from initCheckout when it refuses the cart's currency.
  • create-session answers it with a 400: { error, code: "currency_not_supported", currency }. The hosted form already shows error, so the customer reads "This shop can't take payments in USD right now. Choose another currency, or contact the shop." Any other error from initCheckout still throws as before.
  • Core recognises the error by code, not instanceof, so a provider bundling its own copy of core still works.
  • Paystack throws it for a currency it doesn't support at all, and for Paystack's unsupported_currency refusal.

README note for provider authors, and a patch changeset for both packages.

Tested

  • Core route tests: the 400 and its message, an error recognised by code alone, and other errors still failing loudly. Two of the three fail without the change.
  • Paystack: a unit test for the 403 mapping, and an integration test through core's real create-session with a Paystack stand-in that refuses KES.

moset15 added a commit to FIKANOVA/dashcommerce that referenced this pull request Nov 26, 2026
…rk main

[FIK-73] feat(core,paystack): tell the customer when the provider refuses the currency (fork integration of upstream emdashCommerce#94)

@cavewebs cavewebs 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.

The CurrencyNotSupportedError to 400 change looks good. Please rebase this after #107 lands, since both touch checkout.ts. I'll merge it after that.

…currency

Core exports CurrencyNotSupportedError; create-session answers it with a
400 the customer can act on instead of a 500. Paystack throws it for an
unsupported currency and for its unsupported_currency refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moset15
moset15 force-pushed the fix/clear-currency-refusal branch from 8286cac to fdb2c45 Compare December 5, 2026 22:53
@moset15

moset15 commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #107. The currency refusal now sits in front of #107's checkout snapshot; no other change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants