Skip to content

✨ server: show friendly decline reasons - #1141

Open
aguxez wants to merge 2 commits into
mainfrom
notifications
Open

✨ server: show friendly decline reasons#1141
aguxez wants to merge 2 commits into
mainfrom
notifications

Conversation

@aguxez

@aguxez aguxez commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added clearer, normalized decline reasons for declined transactions.
    • Added localized decline reason translations in Spanish and Portuguese.
    • Added friendly push notification messages for supported decline reasons.
  • Bug Fixes
    • Improved handling of varied decline reason formats and unknown errors.
    • Prevented duplicate decline notifications for previously recorded transactions.
  • Tests
    • Expanded coverage for normalized reasons, translations, transaction events, and notifications.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Decline handling now normalizes mapped reasons, stores canonical text, conditionally sends localized push notifications, adds Spanish and Portuguese translations, expands coverage in server tests, and declares patch releases for the server and mobile packages.

Changes

Decline reason mapping and notifications

Layer / File(s) Summary
Decline reason mapping and notification trigger logic
server/hooks/panda.ts
Decline inputs are lowercased and mapped to canonical reasons, unknown values default to transaction declined, and notifications use mapped push reasons only for newly inserted records.
Server-side decline reason tests
server/test/hooks/panda.test.ts
Parameterized tests verify stored reasons, merchant-blocked normalization, localized notification contents, and randomized transaction identifiers.
Decline reason translations
server/i18n/*.json, src/i18n/*.json
Spanish and Portuguese translations are added for card, PIN, merchant, and transaction decline states.
Package release metadata
.changeset/*.md
Patch release changesets are added for @exactly/server and @exactly/mobile.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant reject
  participant TransactionStore
  participant sendPushNotification
  reject->>reject: Normalize and resolve declineReason
  reject->>TransactionStore: Upsert declined transaction
  TransactionStore-->>reject: Return isNew
  reject->>sendPushNotification: Send localized mapped reason when eligible
Loading

Possibly related PRs

  • exactly/exa#622: Both changes update decline-reason mapping and declined push-notification behavior in the Panda hook and its tests.

Suggested reviewers: cruzdanilo, nfmelendez, dieguezguille, franm91

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: server-side handling now shows friendlier decline reasons.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch notifications
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch notifications

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request expands the transaction decline reasons in the Panda webhook hook, normalizing the reasons to lowercase and introducing a pushReason property for customized push notifications. It also adds corresponding translations in Spanish and Portuguese, along with comprehensive test coverage. The review feedback suggests sorting the newly added translation keys alphabetically across all modified translation files to maintain consistency and avoid future merge conflicts.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread server/i18n/es.json Outdated
Comment thread server/i18n/pt.json Outdated
Comment thread src/i18n/es.json
Comment thread src/i18n/pt.json
Comment thread src/i18n/es.json
Comment thread src/i18n/pt.json
Comment thread src/i18n/es.json
Comment thread src/i18n/pt.json

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6291fb3f-2f5c-4a79-a30a-64e1f0121a1c

📥 Commits

Reviewing files that changed from the base of the PR and between f0f3659 and f8e112c.

📒 Files selected for processing (7)
  • .changeset/tall-geese-share.md
  • server/hooks/panda.ts
  • server/i18n/es.json
  • server/i18n/pt.json
  • server/test/hooks/panda.test.ts
  • src/i18n/es.json
  • src/i18n/pt.json

Comment thread server/hooks/panda.ts Outdated
Comment thread server/test/hooks/panda.test.ts Outdated
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6196eff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@exactly/mobile Patch
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@aguxez
aguxez marked this pull request as ready for review July 13, 2026 11:22

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 749b81ae-a65e-4523-9d53-6b64758891c4

📥 Commits

Reviewing files that changed from the base of the PR and between 1c53e77 and 5e2e44a.

📒 Files selected for processing (9)
  • .changeset/calm-wolves-translate.md
  • .changeset/tall-geese-share.md
  • cspell.json
  • server/hooks/panda.ts
  • server/i18n/es.json
  • server/i18n/pt.json
  • server/test/hooks/panda.test.ts
  • src/i18n/es.json
  • src/i18n/pt.json

Comment thread server/hooks/panda.ts Outdated
Comment thread server/test/hooks/panda.test.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e2e44a14e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts Outdated
Comment thread cspell.json Outdated
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1229 1 1228 1
View the top 1 failed test(s) by shortest run time
test/api/activity.test.ts > authenticated > declined transactions > ignores a non-declined requested operation when finding a decline reason
Stack Traces | 0.159s run time
Error: bad panda activity
 ❯ api/activity.ts:542:15
 ❯ Object.operation api/activity.ts:520:8
 ❯ Object.~run ../node_modules/.pnpm/valibot@1.4.2_typescript@5.9..../valibot/dist/index.mjs:3460:25
 ❯ Object.~run ../node_modules/.pnpm/valibot@1.4.2_typescript@5.9..../valibot/dist/index.mjs:7496:100
 ❯ Module.safeParse ../node_modules/.pnpm/valibot@1.4.2_typescript@5.9..../valibot/dist/index.mjs:7574:32
 ❯ test/api/activity.test.ts:830:22

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@coderabbitai coderabbitai Bot 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.

♻️ Duplicate comments (1)
server/test/hooks/panda.test.ts (1)

3086-3092: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Test expectation should match implementation's .trim() on merchantName.

The implementation at server/hooks/panda.ts uses spend.merchantName.trim(), but the test expectation here passes authorization.json.body.spend.merchantName without .trim(). If the test fixture's merchant name has leading or trailing whitespace, the notification contents won't match and the test will fail.

💚 Proposed fix
-          merchantName: authorization.json.body.spend.merchantName,
+          merchantName: authorization.json.body.spend.merchantName.trim(),

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9cb9ce8a-2122-47bd-9d17-b616e557fa34

📥 Commits

Reviewing files that changed from the base of the PR and between db89620 and f4e8500.

📒 Files selected for processing (8)
  • .changeset/calm-wolves-translate.md
  • .changeset/tall-geese-share.md
  • server/hooks/panda.ts
  • server/i18n/es.json
  • server/i18n/pt.json
  • server/test/hooks/panda.test.ts
  • src/i18n/es.json
  • src/i18n/pt.json

@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 98fc94a to e872dc9 Compare July 15, 2026 14:48

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e872dc9e11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts Outdated
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from d0403ef to e9aaf57 Compare July 15, 2026 17:18

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9aaf5730c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/utils/panda.ts Outdated
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from ab83b45 to 42af7ac Compare July 16, 2026 09:01

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42af7ac6a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/utils/panda.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 163eac8daf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/utils/panda.ts Outdated
Comment thread server/utils/panda.ts Outdated
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from d99b701 to a610a7e Compare July 16, 2026 11:44

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f4cd309da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/api/activity.ts Outdated
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 4a88a63 to 9021d2e Compare July 18, 2026 09:30

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9021d2eb02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts
Comment thread server/hooks/panda.ts
@cruzdanilo cruzdanilo linked an issue Jul 20, 2026 that may be closed by this pull request
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 92d823a to e41b979 Compare July 30, 2026 10:47

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ada5212fbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/test/hooks/panda.test.ts Outdated
Comment thread server/utils/panda.ts
Comment thread server/hooks/panda.ts
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 28763b2 to faa8ec9 Compare August 3, 2026 16:47

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: faa8ec91cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/test/api/activity.test.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f908e967b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 66376874dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc4e46ffb5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 3f02b8c to 92fb005 Compare August 4, 2026 18:44

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92fb005ce4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/panda.ts
Comment thread server/api/activity.ts
@aguxez
aguxez force-pushed the notifications branch 2 times, most recently from 88372a6 to 66a4530 Compare August 5, 2026 12:30

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 66a4530bc7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/test/api/activity.test.ts Outdated
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.

server: show user-friendly card decline reasons

1 participant