feat(connector): [Silverflow] Added integrity check
Fixes #9223
Type of Change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Added integrity checks to Silverflow connector for all payment and refund flows (Authorize, PSync, Refund, RSync). This validates amount and currency consistency between requests and responses to prevent financial discrepancies and detect data corruption.
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
How did you test it?
Payment
Request:
curl --location 'http://localhost:8080/payments/pay_QMXVzbFmKM8NqwVwRlFw/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: *****' \
--data-raw '
{
"amount": 2500,
"currency": "USD",
"confirm": true,
"capture_method": "automatic",
"capture_on": "2022-09-10T10:11:12Z",
"amount_to_capture": 2500,
"customer_id": "abcdef",
"email": "[email protected]",
"name": "John Doe",
"phone": "999999999",
"phone_country_code": "+65",
"description": "Its my first payment request",
"authentication_type": "no_three_ds",
"return_url": "https://duck.com",
"payment_method": "card",
"payment_method_type": "credit",
"payment_method_data": {
"card": {
"card_number": "4242424242424242",
"card_exp_month": "03",
"card_exp_year": "2030",
"card_holder_name": "Max Mustermann",
"card_cvc": "999"
}
},
"billing": {
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "9123456789",
"country_code": "+91"
}
},
"shipping": {
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "9123456789",
"country_code": "+91"
}
},
"statement_descriptor_name": "joseph",
"statement_descriptor_suffix": "JS",
"browser_info": {
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
"accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"language": "nl-NL",
"color_depth": 24,
"screen_height": 723,
"screen_width": 1536,
"time_zone": 0,
"java_enabled": true,
"java_script_enabled": true,
"ip_address": "109.71.40.0"
}
}'
Response:
{
"error": {
"type": "api",
"message": "Integrity Check Failed! as data mismatched for amount expected 2500 but found 10",
"code": "IE_00",
"connector_transaction_id": "chg-zclgswdrdp"
}
}
PSync
Response:
{
"payment_id": "pay_Bq53YmVd8lM5mZi68vrD",
"merchant_id": "merchant_1761918753",
"status": "conflicted",
"amount": 2500,
"net_amount": 2500,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": null,
"connector": "silverflow",
"client_secret": "pay_Bq53YmVd8lM5mZi68vrD_secret_9Tqd2AXE2krfj2vYNtjS",
"created": "2025-10-31T14:04:18.597Z",
"currency": "USD",
"customer_id": "abcdef",
"customer": {
"id": "abcdef",
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"phone_country_code": "+65"
},
"description": "Its my first payment request",
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": null,
"off_session": null,
"capture_on": null,
"capture_method": "manual",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "4242",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "424242",
"card_extended_bin": null,
"card_exp_month": "03",
"card_exp_year": "2030",
"card_holder_name": "Max Mustermann",
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": "token_1QwssGjFwuE9rwZ8GeQC",
"shipping": {
"address": {
"city": "San Fransico",
"country": null,
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"zip": "94122",
"state": "California",
"first_name": "joseph",
"last_name": "Doe",
"origin_zip": null
},
"phone": {
"number": "9123456789",
"country_code": "+91"
},
"email": null
},
"billing": {
"address": {
"city": "San Fransico",
"country": null,
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"zip": "94122",
"state": "California",
"first_name": "joseph",
"last_name": "Doe",
"origin_zip": null
},
"phone": {
"number": "9123456789",
"country_code": "+91"
},
"email": null
},
"order_details": null,
"email": "[email protected]",
"name": "John Doe",
"phone": "999999999",
"return_url": "https://duck.com/",
"authentication_type": "no_three_ds",
"statement_descriptor_name": "joseph",
"statement_descriptor_suffix": "JS",
"next_action": null,
"cancellation_reason": null,
"error_code": "IE",
"error_message": "Integrity Check Failed! Value mismatched for fields amount expected 2500 but found 10",
"unified_code": null,
"unified_message": null,
"payment_experience": null,
"payment_method_type": "credit",
"connector_label": null,
"business_country": null,
"business_label": "default",
"business_sub_label": null,
"allowed_payment_method_types": null,
"ephemeral_key": null,
"manual_retry_allowed": null,
"connector_transaction_id": "chg-ppj1whqfu6",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": {
"redirect_response": null,
"search_tags": null,
"apple_pay_recurring_details": null,
"gateway_system": "direct"
},
"reference_id": null,
"payment_link": null,
"profile_id": "pro_JVt5UNz2c41UAb2lqPwC",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_rw5VGCRrR4PExHRoOgcd",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-10-31T14:19:18.597Z",
"fingerprint": null,
"browser_info": {
"os_type": null,
"referer": null,
"language": "nl-NL",
"time_zone": 0,
"ip_address": "109.71.40.0",
"os_version": null,
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
"color_depth": 24,
"device_model": null,
"java_enabled": true,
"screen_width": 1536,
"accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"screen_height": 723,
"accept_language": "en",
"java_script_enabled": true
},
"payment_channel": null,
"payment_method_id": null,
"network_transaction_id": null,
"payment_method_status": null,
"updated": "2025-10-31T14:04:51.597Z",
"split_payments": null,
"frm_metadata": null,
"extended_authorization_applied": null,
"request_extended_authorization": null,
"capture_before": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null,
"card_discovery": "manual",
"force_3ds_challenge": false,
"force_3ds_challenge_trigger": false,
"issuer_error_code": null,
"issuer_error_message": null,
"is_iframe_redirection_enabled": null,
"whole_connector_response": null,
"enable_partial_authorization": null,
"enable_overcapture": null,
"is_overcapture_enabled": null,
"network_details": null,
"is_stored_credential": null,
"mit_category": null,
"billing_descriptor": null
}
Capture
Request:
curl --location 'http://localhost:8080/payments/pay_F5M6gvm7R1Bd1oKhfpT2/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: *********' \
--data '{
"amount_to_capture": 2500
}'
Response:
{
"error": {
"type": "api",
"message": "Integrity Check Failed! as data mismatched for capture_amount expected 2500 but found 10",
"code": "IE_00",
"connector_transaction_id": "act-ovtpb4qhlt"
}
}
Refund
Request:
{
"payment_id": "pay_fdav1uGA4P0IKcIdvFP1",
"amount": 2500,
"reason": "Customer returned product",
"refund_type": "instant"
}
Response:
{
"refund_id": "ref_9ZKPHNync9pm1TgYPsnz",
"payment_id": "pay_fdav1uGA4P0IKcIdvFP1",
"amount": 2500,
"currency": "USD",
"status": "review",
"reason": "Customer returned product",
"metadata": null,
"error_message": "Integrity Check Failed! as data mismatched for fields refund_amount expected 2500 but found 10",
"error_code": "IE",
"unified_code": null,
"unified_message": null,
"created_at": "2025-10-31T14:13:03.768Z",
"updated_at": "2025-10-31T14:13:03.782Z",
"connector": "silverflow",
"profile_id": "pro_JVt5UNz2c41UAb2lqPwC",
"merchant_connector_id": "mca_rw5VGCRrR4PExHRoOgcd",
"split_refunds": null,
"issuer_error_code": null,
"issuer_error_message": null
}
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
Changed Files
| File | Status |
|---|---|
Hi @sohamm20 , I see the issue #9223 was assigned to somebody else. We request to work on the issues that are assigned to you .
Hi @sohamm20 , I see the issue #9223 was assigned to somebody else. We request to work on the issues that are assigned to you .
@rajdeepdas2000 is not working on this issue.
@sohamm20 ,I see #9223 talks about adding integrity check to Silverflow connector , why have we made changes to Square connector ?
@Vani-1107, I misunderstood reference PRs. My mistake. I made a commit that includes only the Silverflow changes.
Hey @Vani-1107 , fixed all compilation issue by cargo run, just clippy, just clippy_v2. Formated using cargo +nightly fmt --all. Can you review changes again?
@Vani-1107 Can you re-review changes?
@Vani-1107 , review please
@Vani-1107 Resolved comments. please review
@Vani-1107 spell check failed. But they doesn't seem from my PR
@Vani-1107 can you please merge
@Vani-1107 , can you ask someone for next review?