-
Notifications
You must be signed in to change notification settings - Fork 5
Return 400 error for specific auth.net error code #903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Return 400 error for specific auth.net error code #903
Conversation
""" WalkthroughThe code update extends error handling for Authorize.net payment processing by adding explicit handling for the 'E00114' error code, which relates to suspicious activity filter rejections. The change ensures that such errors raise a user-friendly exception with retry guidance, and corresponding unit tests are added to verify this behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PurchaseClient
participant AuthorizeNetAPI
User->>PurchaseClient: process_charge_for_licensee_privileges()
PurchaseClient->>AuthorizeNetAPI: create_transaction()
AuthorizeNetAPI-->>PurchaseClient: API error with code 'E00114'
PurchaseClient-->>User: Raise CCInvalidRequestException with retry message
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Pylint (3.3.7)backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/compact-connect/lambdas/python/purchases/purchase_client.py
(2 hunks)backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py
(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#769
File: backend/compact-connect/lambdas/python/provider-data-v1/handlers/encumbrance.py:39-41
Timestamp: 2025-04-29T02:09:36.291Z
Learning: In the CompactConnect project, authentication/authorization failures like misconfigured authorizers should be allowed to propagate as 500 errors rather than being caught and converted to 4xx errors, as this is intentional to trigger alerts for critical system issues.
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#848
File: backend/compact-connect/lambdas/python/provider-data-v1/handlers/registration.py:111-117
Timestamp: 2025-06-17T19:05:36.255Z
Learning: In CompactConnect PR #848, the user landonshumway-ia decided to leave timezone handling code in _should_allow_reregistration function as-is after testing in sandbox environment confirmed it works correctly. The user's reasoning was that reregistration is an edge case, the code has been tested and verified, and AWS is unlikely to change behavior that would break many clients. This represents a pragmatic engineering decision based on testing and risk assessment.
backend/compact-connect/lambdas/python/purchases/purchase_client.py (1)
Learnt from: jusdino
PR: csg-org/CompactConnect#864
File: backend/compact-connect/lambdas/python/common/cc_common/license_util.py:18-37
Timestamp: 2025-06-18T05:57:18.225Z
Learning: In the `get_license_type_by_abbreviation` method in `license_util.py`, KeyError exceptions from invalid compact codes are intentionally caught and re-raised as CCInvalidRequestException with `from e` to provide a consistent interface between invalid compact and invalid abbreviation scenarios, while preserving the original exception information in the chain.
backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py (1)
Learnt from: jusdino
PR: csg-org/CompactConnect#864
File: backend/compact-connect/lambdas/python/common/cc_common/license_util.py:18-37
Timestamp: 2025-06-18T05:57:18.225Z
Learning: In the `get_license_type_by_abbreviation` method in `license_util.py`, KeyError exceptions from invalid compact codes are intentionally caught and re-raised as CCInvalidRequestException with `from e` to provide a consistent interface between invalid compact and invalid abbreviation scenarios, while preserving the original exception information in the chain.
🧬 Code Graph Analysis (2)
backend/compact-connect/lambdas/python/purchases/purchase_client.py (1)
backend/compact-connect/lambdas/python/common/cc_common/exceptions.py (1)
CCInvalidRequestException
(7-8)
backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py (2)
backend/compact-connect/lambdas/python/purchases/purchase_client.py (2)
PurchaseClient
(888-1080)process_charge_for_licensee_privileges
(931-963)backend/compact-connect/lambdas/python/common/cc_common/exceptions.py (1)
CCInvalidRequestException
(7-8)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: TestPython
🔇 Additional comments (3)
backend/compact-connect/lambdas/python/purchases/purchase_client.py (2)
33-36
: LGTM! Good documentation of the E00114 error code addition.The updated comment clearly explains the purpose of adding E00114 for suspicious activity filter rejections and provides a helpful reference link.
259-267
: Excellent implementation of specific E00114 error handling.The implementation correctly:
- Checks for the specific E00114 error code
- Raises
CCInvalidRequestException
for appropriate 400 response- Provides user-friendly message with retry guidance as recommended by Authorize.net
- Includes helpful context linking to the related GitHub issue
This aligns perfectly with the PR objectives to handle suspicious activity filter rejections gracefully.
backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py (1)
681-711
: Excellent test coverage for E00114 error handling.The test properly verifies:
CCInvalidRequestException
is raised for E00114 errors- The specific user-friendly message is returned
- Integration with the
PurchaseClient.process_charge_for_licensee_privileges
methodThe test structure follows existing patterns and provides good coverage for the new error handling logic.
backend/compact-connect/lambdas/python/purchases/tests/unit/test_purchase_client.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
During user testing with practitioners, because we were using test card numbers with repeated names and privilege prices, the Authorize.net suspicious activity filter denied several requests, and this caused the API to fail with a 5xx error. The system should gracefully handle this scenario.
This adds a check for that specific error code so the backend will return a 400 with a message informing the user to try again.
Closes #889
Summary by CodeRabbit
Bug Fixes
Tests