juspay / juspay/hyperswitch

[FEATURE] : [DATATRANS] Add Integrity Check Support for Authorize, PSync, Refund and RSync Flows

Open
#9,166 2 comments 0 reactions 0 assignees View on GitHub
A-connector-integration E-easy Rust S-unassigned
Dominant language
Rust
Stars
43.7k
Forks
5.1k
Avg merge
2d 21h
Merged PRs (30d)
210

Description

### Feature Description/Summary

Integrity check is a scenario where there is a discrepancy between the amount sent in the request and the amount received from the connector, which is checked during response handling.

### Context
Integrity checks in a payments flow are critical for ensuring data consistency, correctness, and security when dealing with amounts between Hyperswitch and connectors like Adyen, Stripe, Razorpay, etc.

### Starter Tasks

- In the `handle_response` function of Authorize/PSync/Refund/RSync, you will have to call the respective functions - `get_authorise_integrity_object` for Authorize, `get_sync_integrity_object` for Payments Sync, `get_refund_integrity_object` for Refund and RSync and `get_capture_integrity_object` for Capture.
- You would have to call these functions from `crates/hyperswitch_connectors/src/utils.rs`.
- These functions expect `amount_convertor`, `amount` and `currency`.
- You can take a look at this [PR](https://github.com/juspay/hyperswitch/pull/8075) for reference.

### Implementation Hints

- You can go to `crates/hyperswitch_connectors/src/connectors/datatrans.rs` and call the respective integrity check function as stated above in the `handle_response` function

### Acceptance Criteria

- [ ] Request and Response body added for each of the flows where integrity check is applied.
- [ ] All the required GitHub checks passing
- [ ] Formatted the code using `cargo +nightly fmt --all`

### How to Test it

- Hardcode the amount or currency field that is being passed to the connector different from the one you are passing in the request body
- This way you would be able to reproduce the integrity checks error message while testing.

### Mentor Contact

- Tag @bsayak03 [Sayak Bhattacharya] in the comments if you have any doubts/queries

### Resources

Here are a few sample PRs :

- https://github.com/juspay/hyperswitch/pull/8075
- https://github.com/juspay/hyperswitch/pull/8049

### Pre-Flight

#### Have you spent some time checking if this feature request has been raised before?

- [x] I checked and didn't find a similar issue

#### Have you read the Contributing Guidelines?

- [x] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Submission Process:
- Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
- Once assigned, submit a pull request (PR).
- Maintainers will review and provide feedback, if any.
- Maintainers can unassign issues due to inactivity, [read more here](https://github.com/juspay/hyperswitch/wiki/Hacktoberfest-Contribution-Rules).

Refer [here](https://github.com/juspay/hyperswitch/blob/main/docs/TERMS_OF_CONTEST.md) for Terms and conditions for the contest.

Contributor guide

Open the contributing guide

Research direction

Start in crates/hyperswitch_connectors/src/connectors/datatrans.rs and inspect the handle_response functions for Authorize, PSync, Refund, and RSync. Compare the integrity-check calls and request/response examples in PR 8075, then use the functions in crates/hyperswitch_connectors/src/utils.rs; done means the required flows include their bodies, checks pass, and cargo +nightly fmt --all succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
payments
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.