fix(connectors): graceful response deserialization for cryptopay#12720
fix(connectors): graceful response deserialization for cryptopay#12720sai-harsha-vardhan wants to merge 1 commit into
Conversation
Changed Files
|
XyneSpaces
left a comment
There was a problem hiding this comment.
Review: Cryptopay Graceful Response Deserialization
✅ Approved
This PR applies the standard graceful response deserialization fixes to the Cryptopay connector:
- Fix 2 (Enum catch-alls): Added
#[serde(other)] Unknownvariant toCryptopayPaymentStatus - Fix 3 (Opaque optional types): Wrapped unused response fields in
Option<Secret<String>>for forward compatibility - Webhook handling: Replaced wildcard match with explicit enum variants
💡 Findings
1. Clean pattern following established conventions
The to_attempt_status method correctly takes existing status as parameter and returns it unchanged for Unknown variants, preserving existing payment state.
2. NMI connector change
The addition of Response::Unknown to the error match arm in NMI transformers appears to be a related fix - ensure this is intentional and not a cross-contamination from another branch.
3. Warning log placement
The warning log for unknown status is correctly placed inside the match arm, providing visibility when Cryptopay introduces new status values.
Summary
| Severity | Count |
|---|---|
| Critical | 0 |
| Warning | 0 |
| Nitpick | 0 |
Verdict: Clean implementation following established patterns. Ready to merge.
Summary
#[serde(other)] Unknowncatch-all variant toCryptopayPaymentStatusenumForeignTryFromto preserve existing payment status when unknown status is received (with warning log)Unknown) instead of using wildcard_Option<Secret<String>>for forward compatibilityChanges
crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rscrates/hyperswitch_connectors/src/connectors/cryptopay.rsChecklist
#[serde(deny_unknown_fields)]present on response structsUnknownvariant added to response enum used in business logicOption<Secret<String>>Unknownmatch arm preserves existing state (returnsOk(existing_router_data))