Skip to content

feat(parampos): map Sonuc and bank result codes to PaymentErrorCode - #146

Open
czaydev wants to merge 1 commit into
mainfrom
fix/parampos-error-codes
Open

czaydev wants to merge 1 commit into
mainfrom
fix/parampos-error-codes

Conversation

@czaydev

@czaydev czaydev commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

What and why

Closes #82

Before: every Parampos decline (Param's Sonuc and the bank's code) resolved to code: UNKNOWN, so localizedErrors showed a generic message.

After: a declined Parampos payment returns a specific code. The bank's ISO 8583 code in Banka_Sonuc_Kod wins (51 → INSUFFICIENT_FUNDS, 05 → CARD_DECLINED, 54 → EXPIRED_CARD, 82 → INVALID_CVC); otherwise Param's negative Sonuc codes are mapped (-105 → INVALID_CVC, -119 → INVALID_CARD, -2xx refund/cancel errors → INVALID_REQUEST, configuration errors → PROVIDER_ERROR). Unmapped codes stay UNKNOWN, and errorCode still carries the raw Sonuc.

How: new src/providers/parampos/error-codes.ts (PARAMPOS_ERROR_CODES, exported from src/index.ts), returned from errorCodeTable(). Parampos overrides resolveErrorCode() like Akbank, reading Banka_Sonuc_Kod from the SOAP result (or from payment after 3D completion) and padding one-digit codes. Sources for the codes: Param's TurkPOS result code list (as published in the TurkPOS integration guide, e.g. mirrored in BARISUZN/parampos); the field name Banka_Sonuc_Kod matches parampos.go. The code list is documented without a sign; the table uses negative keys because Param returns failures as negative Sonuc (a positive Sonuc means success, and the existing tests use -100 for "Hesap bulunamadı").

The changeset carries the <!-- docs --> entry from #145 (check-changesets.mjs passes).

Checklist

  • pnpm lint, pnpm typecheck and pnpm test pass
  • Tests cover the change (bank codes, Sonuc codes, fallback, unknown code)
  • A changeset is included for user-facing changes (pnpm changeset)
  • Docs are updated in English and Turkish (node apps/web/scripts/check-translations.mjs), or no docs change is needed
  • New user-facing features include a <Since version="x.y.z" /> badge in their docs, or no badge is needed
  • No credentials, card numbers or personal data in code, tests, fixtures or logs

Failed Parampos results now resolve the bank's ISO 8583 code in
Banka_Sonuc_Kod first, then Param's negative Sonuc codes
(PARAMPOS_ERROR_CODES, exported). Unmapped codes stay UNKNOWN with the
raw Sonuc in errorCode. Closes #82.
@czaydev
czaydev requested a review from poyrazavsever as a code owner October 7, 2026 04:50
Copilot AI balanced review requested due to automatic review settings October 7, 2026 04:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
better-payment-web-xhgb Ready Ready Preview Oct 7, 2026 4:50am UTC

@czaydev

czaydev commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

ParamPOS yasal dava süreci sebebiyle dev dökümanlarına erişilemiyor, bu sebeple teyit edilemediğinden PR bekletilecektir.

This branch was successfully deployed

1 active deployment
Preview — 5fda2208 Deployed Oct 7, 2026 by vercel[bot]
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.

Map Parampos result codes to normalized error codes

2 participants