fix(saman-shaparak-payment): handle missing TransactionDetail gracefu…#116
Open
alip990 wants to merge 1 commit into
Open
fix(saman-shaparak-payment): handle missing TransactionDetail gracefu…#116alip990 wants to merge 1 commit into
alip990 wants to merge 1 commit into
Conversation
…lly in Saman payment adapters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle missing TransactionDetail gracefully in Saman payment adapters
Description
Saman verify responses can include
"TransactionDetail": nullon failed verification (for example{"TransactionDetail": null, "ResultCode": -2, "Success": false}). The sync and async Saman adapters useddata.get("TransactionDetail", {}), which only substitutes when the key is missing; when the key is present with a null value,.get()returnsNoneand the next.get("RRN")raisesAttributeError. That exception is caught at the adapter boundary and re-raised asInternalError, so callers cannot handle a normal gateway failure fromsuccess,result_code, andresult_description.This change treats a null
TransactionDetailas an empty object in bothverify_paymentimplementations, so failed verifications returnVerifyResponseDTOwith optional detail fields left unset instead of raisingInternalError.Fixes # (issue)
Type of change
How Has This Been Tested?
uv run ty check archipy/adapters/internet_payment_gateways/ir/saman/adapters.pyruff-format,ruff,add-trailing-comma,validate-pyproject,tyTransactionDetail(not added in this PR)Manual local testChecklist:
Additional context
VerifyResponseDTOalready allows optional detail fields on failure; no port or DTO changes were required. Scope is limited toarchipy/adapters/internet_payment_gateways/ir/saman/adapters.pyin sync and asyncverify_payment.