✨ server: add rejection code to authorization declines#1051
Conversation
🦋 Changeset detectedLatest commit: cd7514b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
WalkthroughThis PR adds standardized ChangesRejection codes for authorization declines
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds rejection codes to authorization decline responses. It updates the PandaError class to accept a rejectionCode and includes this code in the JSON responses for various decline scenarios, such as inactive or frozen cards, insufficient funds, and timeouts. Corresponding unit tests have been added and updated to verify these changes. There are no review comments, and I have no feedback to provide.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
server/hooks/panda.ts (2)
1310-1319:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd trailing comma to parameter list.
The parameter list is missing a trailing comma after the last parameter. As per coding guidelines, trailing commas should be used in all structures including function parameters to maintain diff-friendliness.
📝 Proposed fix
class PandaError extends Error { constructor( message: string, public statusCode: number, - public rejectionCode: "INSUFFICIENT_FUNDS" | "NOT_PERMITTED" | "UNKNOWN" = "UNKNOWN", + public rejectionCode: "INSUFFICIENT_FUNDS" | "NOT_PERMITTED" | "UNKNOWN" = "UNKNOWN", ) { super(message); this.name = "PandaError"; } }
728-728: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winConsider adding
rejectionCodefor API consistency.This "card not found" error response at Line 728 (in the
created/updated/completedaction cases) does not include arejectionCodefield, while the similar error at Line 298 (in therequestedaction case) does include it.This creates an inconsistent API where some error responses include
rejectionCodeand others don't. If the scope is intentionally limited to authorization declines (therequestedaction), consider documenting this distinction. Otherwise, for consistency, all error responses should includerejectionCode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 259929ff-7286-4218-be49-2be1923b6b1a
📒 Files selected for processing (3)
.changeset/brisk-otter-tag.mdserver/hooks/panda.tsserver/test/hooks/panda.test.ts
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
==========================================
- Coverage 74.02% 73.48% -0.55%
==========================================
Files 243 243
Lines 10931 10627 -304
Branches 3720 3555 -165
==========================================
- Hits 8092 7809 -283
+ Misses 2527 2505 -22
- Partials 312 313 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Summary by CodeRabbit
Release Notes