feat(connector): [CELERO] Add Integrity Check for Authorize, PSync, Refund & RSync (#9158)
Type of Change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Adds integrity check support to the Celero connector:
- Authorize and PSync: build integrity from typed response
data(amount,currency) and attach torouter_data.request.integrity_object. - Refund and RSync: best‑effort integrity. Set the integrity object only when both
data.amountanddata.currencyare present; otherwise we skip (no error). This matches Celero’s current refund models wheredatais optional and “usually null.”
Changed files:
crates/hyperswitch_connectors/src/connectors/celero.rs
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
Implements integrity checks for Celero per issue #9158 to ensure discrepancies between request and connector response amounts/currencies are detected. Refund/RSync are best‑effort due to optional response data; we can switch to strict typed handling if connector docs guarantee these fields.
Closes #9158
How did you test it?
- Local build and lint:
cargo clippy -p hyperswitch_connectors --features v1 -- -D warningscargo build -p hyperswitch_connectors --features v1
Test cases:
Payments create
Request:
{
"amount": 2500,
"currency": "USD",
"confirm": true,
"capture_method": "manual",
"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": "670086"
}
}
PSync
{
"payment_id": "pay_fbeSMH64cFIv1SnbSPJv",
"merchant_id": "merchant_1760708655",
"status": "conflicted",
"amount": 2500,
"net_amount": 2500,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": null,
"connector": "celero",
"client_secret": "pay_fbeSMH64cFIv1SnbSPJv_secret_RAY5ZHXgDoREB2OopYT2",
"created": "2025-10-17T13:56:07.348Z",
"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_e1hkFZ7gBUZ7coIF1zeT",
"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": "195587",
"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_OHOvGuraw3oiWerD1yzR",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_7Cv9PXa3sjJjFdABzAKx",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-10-17T14:11:07.348Z",
"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-17T13:56:17.245Z",
"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
}
Capture
Rquest:
curl --location 'http://localhost:8080/payments/pay_DMJ7TwoYA6sRURt2kCGL/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": "txn_y5p62qsevi"
}
}
Refund
Request:
{
"payment_id": "{{payment_id}}",
"amount": 2500,
"reason": "Customer returned product",
"refund_type": "instant"
}
Response:
{
"refund_id": "ref_hMGToqXLLzpJqE0Afaw4",
"payment_id": "pay_W58iws8wDsPmu6LOhZpN",
"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-17T14:01:53.076Z",
"updated_at": "2025-10-17T14:01:53.095Z",
"connector": "celero",
"profile_id": "pro_OHOvGuraw3oiWerD1yzR",
"merchant_connector_id": "mca_7Cv9PXa3sjJjFdABzAKx",
"split_refunds": null,
"issuer_error_code": null,
"issuer_error_message": null
}
Checklist
- [ ] 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
Hi @Vani-1107, I've done the changes that you had commented on, are there any other issues with the PR?
@drdholu , please address the required CI check failures. You can run cargo run , just clippy and just clippy_v2 and address the errors and warnings you get. Format the code using cargo +nightly fmt --all
@drdholu , please address the required CI check failures.
@Vani-1107 Just pushed the changes regarding the CI check failures.
@Vani-1107 Just pushed some more changes regarding errors.
Please add integrity check for capture flow as well @drdholu
@Vani-1107 pushed the changes
Hi @neerajkumar-n @bsayak03, would appreciate an approval for this PR whenever possible.
Hi @neerajkumar-n @bsayak03, just a small reminder :)
Hi @neerajkumar-n @bsayak03, could someone from the team please take a look and approve this when possible? Thanks a lot!
Hi @neerajkumar-n @bsayak03, just a small reminder, Thanks for your time :)