hyperswitch
hyperswitch copied to clipboard
fix(connector): [STRIPE] Retrieving Connect Account Id from Mandate Metadata in MITs
Type of Change
- [x] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
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?
Do a CIT Call in Stripe :
cURL :
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_xBcDc9pB8qAMMQPKevYgWc9OmJX4g8uJNdumSg0r0MJniBLmiIKg2RGZd8xfZaKJ' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data '{
"amount": 200,
"currency": "USD",
"confirm": true,
"capture_method": "automatic",
"amount_to_capture": 200,
"customer_id": "knhfhka1777771lsklkdlo",
"setup_future_usage": "off_session",
"customer_acceptance": {
"acceptance_type": "offline",
"accepted_at": "1963-05-03T04:07:52.723Z",
"online": {
"ip_address": "125.0.0.1",
"user_agent": "amet irure esse"
}
},
"authentication_type": "no_three_ds",
"return_url": "https://google.com",
"name": "John Doe",
"phone": "999999999",
"phone_country_code": "+65",
"description": "Its my first payment request",
"payment_method": "card",
"payment_method_type": "debit",
"payment_method_data": {
"card": {
"card_number": "4242424242424242",
"card_exp_month": "09",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"card_cvc": "123"
}
},
"billing": {
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"country": "US",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "8056594427",
"country_code": "+91"
}
},
"split_payments": {
"stripe_split_payment": {
"charge_type": "direct",
"application_fees": 100,
"transfer_account_id": "STRIPE_CONNECT_ACCOUNT_ID"
}
},
"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": "128.0.0.1"
}
}
'
Response:
{
"payment_id": "pay_cEcqgSSp33PsX5R4uwFM",
"merchant_id": "merchant_1749631905",
"status": "succeeded",
"amount": 200,
"net_amount": 200,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 200,
"connector": "stripe",
"client_secret": "pay_cEcqgSSp33PsX5R4uwFM_secret_boU7DjdGaKtsrnFKMIbK",
"created": "2025-06-11T15:15:55.676Z",
"currency": "USD",
"customer_id": "knhfhka1777771lsklkdlo",
"customer": {
"id": "knhfhka1777771lsklkdlo",
"name": "John Doe",
"email": null,
"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": "off_session",
"off_session": null,
"capture_on": null,
"capture_method": "automatic",
"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": "09",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"payment_checks": {
"cvc_check": "pass",
"address_line1_check": "pass",
"address_postal_code_check": null
},
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": {
"address": {
"city": "San Fransico",
"country": "US",
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"zip": "94122",
"state": "California",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "8056594427",
"country_code": "+91"
},
"email": null
},
"order_details": null,
"email": null,
"name": "John Doe",
"phone": "999999999",
"return_url": "https://google.com/",
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"next_action": null,
"cancellation_reason": null,
"error_code": null,
"error_message": null,
"unified_code": null,
"unified_message": null,
"payment_experience": null,
"payment_method_type": "debit",
"connector_label": null,
"business_country": null,
"business_label": "default",
"business_sub_label": null,
"allowed_payment_method_types": null,
"ephemeral_key": {
"customer_id": "knhfhka1777771lsklkdlo",
"created_at": 1749654955,
"expires": 1749658555,
"secret": "epk_516e99419e6a4258a80564a35597b79f"
},
"manual_retry_allowed": false,
"connector_transaction_id": "pi_3RYqNdB7KCg1IWRp0et6BMH5",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": "pi_3RYqNdB7KCg1IWRp0et6BMH5",
"payment_link": null,
"profile_id": "pro_akVQl6yaf45xunErXMGC",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_apjrpOfsP9HdQUueJzyk",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-06-11T15:30:55.676Z",
"fingerprint": null,
"browser_info": {
"language": "nl-NL",
"time_zone": 0,
"ip_address": "128.0.0.1",
"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,
"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,
"java_script_enabled": true
},
"payment_method_id": "pm_UOhsKOUeYM6fnzWyCHtU",
"payment_method_status": "active",
"updated": "2025-06-11T15:15:58.088Z",
"split_payments": {
"stripe_split_payment": {
"charge_id": "ch_3RYqNdB7KCg1IWRp0ngPDpVO",
"charge_type": "direct",
"application_fees": 100,
"transfer_account_id": "STRIPE_CONNECT_ACCOUNT_ID"
}
},
"frm_metadata": null,
"extended_authorization_applied": null,
"capture_before": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": "pm_1RYqNcB7KCg1IWRpVkNUOCV3",
"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
}
Do a MIT call now (without passing any split payment object now) :
cURL:
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_xBcDc9pB8qAMMQPKevYgWc9OmJX4g8uJNdumSg0r0MJniBLmiIKg2RGZd8xfZaKJ' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data '{
"amount": 200,
"currency": "USD",
"customer_id": "knhfhka1777771lsklkdlo",
"description": "Subsequent Mandate Test Payment (MIT from New CIT Demo)",
"confirm": true,
"off_session": true,
"recurring_details": {
"type": "payment_method_id",
"data": "pm_UOhsKOUeYM6fnzWyCHtU"
}
}'
Response:
{
"payment_id": "pay_yKso0LToFJVpDpiM5e6y",
"merchant_id": "merchant_1749631905",
"status": "succeeded",
"amount": 200,
"net_amount": 200,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 200,
"connector": "stripe",
"client_secret": "pay_yKso0LToFJVpDpiM5e6y_secret_HPX9Di3YfCBAmnK3T9mw",
"created": "2025-06-11T15:16:34.464Z",
"currency": "USD",
"customer_id": "knhfhka1777771lsklkdlo",
"customer": {
"id": "knhfhka1777771lsklkdlo",
"name": "John Doe",
"email": null,
"phone": "999999999",
"phone_country_code": "+65"
},
"description": "Subsequent Mandate Test Payment (MIT from New CIT Demo)",
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": null,
"off_session": true,
"capture_on": null,
"capture_method": null,
"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": "09",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": null,
"email": null,
"name": "John Doe",
"phone": "999999999",
"return_url": null,
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"next_action": null,
"cancellation_reason": null,
"error_code": null,
"error_message": null,
"unified_code": null,
"unified_message": null,
"payment_experience": null,
"payment_method_type": "debit",
"connector_label": null,
"business_country": null,
"business_label": "default",
"business_sub_label": null,
"allowed_payment_method_types": null,
"ephemeral_key": {
"customer_id": "knhfhka1777771lsklkdlo",
"created_at": 1749654994,
"expires": 1749658594,
"secret": "epk_59c99d7518734fa98c1bc49f0d15ee90"
},
"manual_retry_allowed": false,
"connector_transaction_id": "pi_3RYqOEB7KCg1IWRp15Y5b8Ws",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": "pi_3RYqOEB7KCg1IWRp15Y5b8Ws",
"payment_link": null,
"profile_id": "pro_akVQl6yaf45xunErXMGC",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_apjrpOfsP9HdQUueJzyk",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-06-11T15:31:34.464Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": "pm_UOhsKOUeYM6fnzWyCHtU",
"payment_method_status": "active",
"updated": "2025-06-11T15:16:35.853Z",
"split_payments": null,
"frm_metadata": null,
"extended_authorization_applied": null,
"capture_before": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": "pm_1RYqNcB7KCg1IWRpVkNUOCV3",
"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
}
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 |
|---|---|