hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat(connector): add integrity check support for thunes authorize, ps…

Open musharafmaqbool opened this issue 2 months ago • 2 comments

Fixes juspay/hyperswitch#9992

Type of Change

  • [ ] Bugfix
  • [x] New feature
  • [ ] Enhancement
  • [ ] Refactoring
  • [ ] Dependency updates
  • [ ] Documentation
  • [ ] CI/CD

Description

This PR adds integrity check support for the Thunes connector across multiple payment flows:

  • Payment Authorization flow: Added integrity object validation for authorized payments
  • Payment Sync (PSync) flow: Added integrity object validation for payment status synchronization
  • Refund Execute flow: Added integrity object validation for refund creation
  • Refund Sync (RSync) flow: Added integrity object validation for refund status synchronization

Changes Made

1. Updated crates/hyperswitch_connectors/src/connectors/thunes.rs:

  • Changed import to use utils as connector_utils for better clarity
  • Added get_authorise_integrity_object() call in authorize response handling
  • Added get_sync_integrity_object() call in payment sync response handling
  • Added get_refund_integrity_object() call in refund execute response handling
  • Added get_refund_integrity_object() call in refund sync response handling
  • Modified response handling to store integrity objects in router_data.request.integrity_object

2. Updated crates/hyperswitch_connectors/src/connectors/thunes/transformers.rs:

  • Added amount and currency fields to ThunesPaymentsResponse struct
  • Added amount and currency fields to RefundResponse struct
  • These fields are required for integrity validation

Additional Changes

  • [ ] This PR modifies the API contract
  • [ ] This PR modifies the database schema
  • [ ] This PR modifies application configuration/environment variables

Motivation and Context

Integrity checks ensure data consistency and help detect potential issues with payment amounts and currencies during transaction processing. By adding integrity validation for Thunes connector flows, we can:

  1. Validate that response amounts match expected values
  2. Ensure currency consistency across payment operations
  3. Provide additional safeguards against data corruption or manipulation
  4. Maintain audit trails for compliance and debugging purposes

This enhancement aligns with the existing integrity check framework used by other connectors in the codebase.

How did you test it?

  • [x] Code compiles successfully without errors
  • [x] No linter errors from cargo clippy
  • [x] Code formatting verified with cargo +nightly fmt --all
  • [ ] Manual testing with Thunes sandbox environment (pending access)
  • [ ] Integration tests updated (if applicable)

The changes follow the existing pattern used in other connector implementations and utilize the standard connector_utils helper functions for integrity object creation.

Checklist

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code
  • [ ] I added unit tests for my changes where possible

musharafmaqbool avatar Oct 28 '25 13:10 musharafmaqbool

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/thunes.rs  15% smaller
  crates/hyperswitch_connectors/src/connectors/thunes/transformers.rs  0% smaller

semanticdiff-com[bot] avatar Oct 28 '25 13:10 semanticdiff-com[bot]

Updated PR description with issue link #9992

musharafmaqbool avatar Oct 28 '25 14:10 musharafmaqbool