hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

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

Open bsayak03 opened this issue 6 months ago • 0 comments

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 for reference.

Implementation Hints

  • You can go to crates/hyperswitch_connectors/src/connectors/trustpay.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?

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.

Refer here for Terms and conditions for the contest.

bsayak03 avatar Sep 01 '25 20:09 bsayak03

What does this output when you run it on that machine?

sysctl -n machdep.cpu.brand_string

henrygd avatar May 24 '25 22:05 henrygd

sysctl -n machdep.cpu.brand_string
Apple M2 Ultra

DPattee avatar May 25 '25 01:05 DPattee

Interesting, thanks.

Looking closer at your screenshot, the spacing seems slightly off. I wonder if this is an encoding issue and related to https://github.com/henrygd/beszel/issues/531.

Does it have a leading whitespace character if you select the text or inspect the element ?

henrygd avatar May 25 '25 02:05 henrygd

I was looking at that same issue for a different reason... This machine is supposedly 'offline' even though the agent is running as far as ps aux | grep beszel is concerned.

Looking in the web-based log I see an error level entry

message | System down
-- | --
data.err | invalid character '' looking for beginning of value

DPattee avatar May 25 '25 02:05 DPattee

Seeing this on a MacBook Air M3 too, no extra space:

Image

HTML is:

Image

blackketter avatar May 30 '25 13:05 blackketter

Fairly sure this is caused by the same core issue as #531 and #796.

Seems to only affect Apple Silicon devices. I'll see if I can find a cheap used one for sale locally.

henrygd avatar May 31 '25 03:05 henrygd

Same issue here

Image

mguilherme avatar Jun 15 '25 13:06 mguilherme

Interesting, I don't have that issue 🤔 I've installed through the "Add System" command

curl -sL https://get.beszel.dev/brew -o /tmp/install-agent.sh && chmod +x /tmp/install-agent.sh && /tmp/install-agent.sh -p 45876 -k "ssh-ed25519 ....."

Image

DanielSSilva avatar Jun 15 '25 13:06 DanielSSilva

@DanielSSilva I did manually with brew but it seems that script does exactly the same thing but checks if you have brew installed first

mguilherme avatar Jun 15 '25 21:06 mguilherme

If possible can someone experiencing this issue try setting the env var SENSORS="" to see if it fixes it?

There's a known issue with the sensors package on Darwin ARM and I'm wondering if it's somehow corrupting the encoding. We're also switching from JSON to CBOR in 0.12.0 which might help.

henrygd avatar Jul 01 '25 21:07 henrygd

If possible can someone experiencing this issue try setting the env var SENSORS="" to see if it fixes it?

There's a known issue with the sensors package on Darwin ARM and I'm wondering if it's somehow corrupting the encoding. We're also switching from JSON to CBOR in 0.12.0 which might help.

Sure, I've added that to my env, give me a few hours to see if it crashes.

mguilherme avatar Jul 02 '25 08:07 mguilherme

It seems to display correctly, however it doesn't display the sensors which is expected 😄 Image

mguilherme avatar Jul 02 '25 08:07 mguilherme

@henrygd after a few hours it's working correctly, it didn't crash due to #796 and the display seems correct, it's not showing the sensors (but that's expected)

mguilherme avatar Jul 02 '25 14:07 mguilherme

I have the same issue. The client was added in version 0.12.0. It's now upgraded to 0.12.3(Server&Client), but it still displays 'pple'. Image

Client List

Image

cloverzrg avatar Aug 05 '25 03:08 cloverzrg

https://server_domain/api/collections/systems/records?page=1&perPage=500&skipTotal=1&sort=%2Bname&fields=id%2Cname%2Chost%2Cport%2Cinfo%2Cstatus return:

Image

cloverzrg avatar Aug 13 '25 10:08 cloverzrg