Skip to content

fix(connectors): graceful response deserialization for cryptopay#12720

Open
sai-harsha-vardhan wants to merge 1 commit into
mainfrom
fix-cryptopay-response-deserialization
Open

fix(connectors): graceful response deserialization for cryptopay#12720
sai-harsha-vardhan wants to merge 1 commit into
mainfrom
fix-cryptopay-response-deserialization

Conversation

@sai-harsha-vardhan

Copy link
Copy Markdown
Contributor

Summary

  • Added #[serde(other)] Unknown catch-all variant to CryptopayPaymentStatus enum
  • Updated ForeignTryFrom to preserve existing payment status when unknown status is received (with warning log)
  • Updated webhook handler to explicitly match all enum variants (including Unknown) instead of using wildcard _
  • Wrapped unused response fields in Option<Secret<String>> for forward compatibility

Changes

  • crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs
  • crates/hyperswitch_connectors/src/connectors/cryptopay.rs

Checklist

  • Fix 1: No #[serde(deny_unknown_fields)] present on response structs
  • Fix 2: Catch-all Unknown variant added to response enum used in business logic
  • Fix 3: Unused scalar fields converted to Option<Secret<String>>
  • Unknown match arm preserves existing state (returns Ok(existing_router_data))

@sai-harsha-vardhan sai-harsha-vardhan requested a review from a team as a code owner June 11, 2026 13:37
@semanticdiff-com

semanticdiff-com Bot commented Jun 11, 2026

Copy link
Copy Markdown

@XyneSpaces XyneSpaces 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.

Review: Cryptopay Graceful Response Deserialization

✅ Approved

This PR applies the standard graceful response deserialization fixes to the Cryptopay connector:

  1. Fix 2 (Enum catch-alls): Added #[serde(other)] Unknown variant to CryptopayPaymentStatus
  2. Fix 3 (Opaque optional types): Wrapped unused response fields in Option<Secret<String>> for forward compatibility
  3. 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.

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.

2 participants