Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(core/connector): [Truelayer] Add support for closed loop payouts (#12281)
Vani Gupta08a99a6f5258
diff --git a/Cargo.lock b/Cargo.lockindex 63a60bf4e1..3f614c45d6 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2264,7 +2264,7 @@ dependencies = [[[package]]name = "config_patch_derive"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["proc-macro2","quote",@@ -3980,7 +3980,7 @@ checksum = "32619942b8be646939eaf3db0602b39f5229b74575b67efc897811ded1db4e57"[[package]]name = "grpc-api-types"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["axum 0.8.4","bytes 1.10.1",@@ -8181,7 +8181,7 @@ dependencies = [[[package]]name = "rust-grpc-client"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["grpc-api-types",]@@ -11015,7 +11015,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"[[package]]name = "ucs_cards"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["bytes 1.10.1","error-stack 0.4.1",@@ -11031,7 +11031,7 @@ dependencies = [[[package]]name = "ucs_common_enums"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["serde","strum 0.26.3",@@ -11042,7 +11042,7 @@ dependencies = [[[package]]name = "ucs_common_utils"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=1ef876126c42e1ed216f61845cff508a90badcf5#1ef876126c42e1ed216f61845cff508a90badcf5"+source = "git+https://github.com/juspay/connector-service?tag=2026.05.15.1#bb55b8f5ba0a3242bfac7bf340c3c4b065ec2949"dependencies = ["anyhow","base64 0.21.7",@@ -11054,6 +11054,7 @@ dependencies = ["hex","http 1.3.1","hyperswitch_masking",+ "josekit","md5","multipart","nanoid",diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 14dff01736..461c3dd6ae 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -26979,6 +26979,7 @@"type": "object","required": ["psp_token",+ "psp_customer_id","token_type"],"properties": {@@ -26987,6 +26988,11 @@"description": "PSP token generated for the payout method","example": "token_12345"},+ "psp_customer_id": {+ "type": "string",+ "description": "PSP customer ID",+ "example": "customer_12345"+ },"token_type": {"$ref": "#/components/schemas/PaymentMethodType"}@@ -31362,6 +31368,12 @@"example": "2022-09-10T10:11:12Z","nullable": true},+ "connector_customer_id": {+ "type": "string",+ "description": "A unique identifier for a customer provided by the connector.",+ "example": "cus_Rnm2pDKGyQi506",+ "nullable": true+ },"currency": {"$ref": "#/components/schemas/Currency"},@@ -31980,6 +31992,11 @@}],"nullable": true+ },+ "sender_payment_instrument_id": {+ "type": "string",+ "description": "A connector-specific identifier representing the stored payment instrument",+ "nullable": true}}},@@ -33014,6 +33031,12 @@"example": "2022-09-10T10:11:12Z","nullable": true},+ "connector_customer_id": {+ "type": "string",+ "description": "A unique identifier for a customer provided by the connector.",+ "example": "cus_Rnm2pDKGyQi506",+ "nullable": true+ },"currency": {"$ref": "#/components/schemas/Currency"},@@ -33657,6 +33680,11 @@}],"nullable": true+ },+ "sender_payment_instrument_id": {+ "type": "string",+ "description": "A connector-specific identifier representing the stored payment instrument",+ "nullable": true}}},diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 052e13aa02..4692c5bd40 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -20002,6 +20002,7 @@"type": "object","required": ["psp_token",+ "psp_customer_id","token_type"],"properties": {@@ -20010,6 +20011,11 @@"description": "PSP token generated for the payout method","example": "token_12345"},+ "psp_customer_id": {+ "type": "string",+ "description": "PSP customer ID",+ "example": "customer_12345"+ },"token_type": {"$ref": "#/components/schemas/PaymentMethodType"}diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 33954b64b1..380d9d6f0a 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -7346,6 +7346,12 @@ pub struct PaymentsResponse {#[smithy(value_type = "Option<String>")]pub modified_at: Option<PrimitiveDateTime>,+ /// A unique identifier for a customer provided by the connector.+ #[schema(value_type = Option<String>, example = "cus_Rnm2pDKGyQi506")]+ #[serde(skip_serializing_if = "Option::is_none")]+ #[smithy(value_type = "Option<String>")]+ pub connector_customer_id: Option<String>,+/// Three-letter ISO currency code (e.g., USD, EUR) for the payment amount.#[schema(value_type = Currency, example = "USD")]#[smithy(value_type = "Currency")]@@ -7820,6 +7826,9 @@ pub struct PaymentsResponse {/// Installment selection confirmed by the customer for this payment#[schema(value_type = Option<InstallmentData>)]pub installment_data: Option<common_types::payments::InstallmentData>,++ /// A connector-specific identifier representing the stored payment instrument+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rsindex f7d44ed10e..7662b0ab2c 100644--- a/crates/api_models/src/payouts.rs+++ b/crates/api_models/src/payouts.rs@@ -611,6 +611,10 @@ pub struct Passthrough {#[schema(value_type = String, example = "token_12345")]pub psp_token: Secret<String>,+ /// PSP customer ID+ #[schema(value_type = String, example = "customer_12345")]+ pub psp_customer_id: Option<Secret<String>>,+/// Payout method type of the token#[schema(value_type = PaymentMethodType, example = "paypal")]pub token_type: api_enums::PaymentMethodType,diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex a051d5f3ba..5a0e1e5f76 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -170,6 +170,7 @@ pub struct PaymentAttempt {pub installment_data: Option<common_types::payments::InstallmentData>,pub external_surcharge_details: Option<common_types::payments::ExternalSurchargeDetails>,pub network_transaction_link_id: Option<String>,+ pub sender_payment_instrument_id: Option<String>,#[diesel(deserialize_as = RequiredFromNullable<storage_enums::PaymentMethod>)]pub payment_method_type_v2: storage_enums::PaymentMethod,pub connector_payment_id: Option<ConnectorTransactionId>,@@ -305,6 +306,8 @@ pub struct PaymentAttempt {/// External surcharge details from InterPayments (stored as JSONB)pub external_surcharge_details: Option<common_types::payments::ExternalSurchargeDetails>,pub network_transaction_link_id: Option<String>,+ /// A connector-specific identifier representing the stored payment instrument+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]@@ -556,6 +559,7 @@ pub struct PaymentAttemptNew {pub installment_data: Option<common_types::payments::InstallmentData>,pub external_surcharge_details: Option<common_types::payments::ExternalSurchargeDetails>,pub network_transaction_link_id: Option<String>,+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]@@ -702,6 +706,7 @@ pub enum PaymentAttemptUpdate {is_overcapture_enabled: Option<OvercaptureEnabledBool>,authorized_amount: Option<MinorUnit>,error_details: Box<Option<Option<ErrorDetails>>>,+ sender_payment_instrument_id: Option<String>,},UnresolvedResponseUpdate {status: storage_enums::AttemptStatus,@@ -1167,6 +1172,7 @@ impl PaymentAttemptUpdateInternal {error_details: source.error_details,retry_type: source.retry_type,installment_data: source.installment_data,+ sender_payment_instrument_id: source.sender_payment_instrument_id,}}}@@ -1245,6 +1251,7 @@ pub struct PaymentAttemptUpdateInternal {pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,pub authorized_amount: Option<MinorUnit>,pub error_details: Option<Option<ErrorDetails>>,+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]@@ -1454,6 +1461,7 @@ impl PaymentAttemptUpdate {authorized_amount,error_details,installment_data,+ sender_payment_instrument_id,} = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source);PaymentAttempt {amount: amount.unwrap_or(source.amount),@@ -1539,6 +1547,8 @@ impl PaymentAttemptUpdate {authorized_amount: authorized_amount.or(source.authorized_amount),tokenization: tokenization.or(source.tokenization),error_details: error_details.unwrap_or(source.error_details),+ sender_payment_instrument_id: sender_payment_instrument_id+ .or(source.sender_payment_instrument_id),..source}}@@ -2854,6 +2864,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {fingerprint_id,payment_method_billing_address_id,updated_by,+ sender_payment_instrument_id: None,net_amount: None,connector_transaction_id: None,connector: None,@@ -2983,6 +2994,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::ConfirmUpdate {amount,@@ -3058,6 +3070,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {client_source,client_version,customer_acceptance,+ sender_payment_instrument_id: None,net_amount: None,connector_transaction_id: None,amount_to_capture: None,@@ -3175,6 +3188,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data: None,error_details: None,installment_data: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::RejectUpdate {status,@@ -3253,6 +3267,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data: None,error_details: None,installment_data: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::BlocklistUpdate {status,@@ -3331,6 +3346,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data: None,error_details: None,installment_data: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::ConnectorMandateDetailUpdate {connector_mandate_detail,@@ -3408,6 +3424,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data: None,error_details: None,installment_data: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::PaymentMethodDetailsUpdate {payment_method_id,@@ -3484,6 +3501,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data: None,error_details: None,installment_data: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::ResponseUpdate {status,@@ -3518,6 +3536,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {is_overcapture_enabled,authorized_amount,error_details: boxed_error_details,+ sender_payment_instrument_id,} => {let error_details = *boxed_error_details;let (connector_transaction_id, processor_transaction_data) =@@ -3597,6 +3616,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {encrypted_payment_method_data,error_details,installment_data: None,+ sender_payment_instrument_id,}}PaymentAttemptUpdate::ErrorUpdate {@@ -3697,6 +3717,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data,error_details,+ sender_payment_instrument_id: None,}}PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {@@ -3771,6 +3792,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::UpdateTrackers {payment_token,@@ -3792,6 +3814,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {surcharge_amount,tax_amount,updated_by,+ sender_payment_instrument_id: None,merchant_connector_id: merchant_connector_id.map(Some),amount: None,net_amount: None,@@ -3946,6 +3969,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details,+ sender_payment_instrument_id: None,}}PaymentAttemptUpdate::PreprocessingUpdate {@@ -4034,6 +4058,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,}}PaymentAttemptUpdate::CaptureUpdate {@@ -4112,6 +4137,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::AmountToCaptureUpdate {status,@@ -4189,6 +4215,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::ConnectorResponse {authentication_data,@@ -4275,6 +4302,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,}}PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate {@@ -4352,6 +4380,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::AuthenticationUpdate {status,@@ -4431,6 +4460,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::ManualUpdate {status,@@ -4520,6 +4550,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,}}PaymentAttemptUpdate::PostSessionTokensUpdate {@@ -4597,6 +4628,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {installment_data: None,encrypted_payment_method_data: None,error_details: None,+ sender_payment_instrument_id: None,},PaymentAttemptUpdate::RecurrenceUpdate {status,@@ -4677,6 +4709,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {authorized_amount: None,installment_data: None,encrypted_payment_method_data: None,+ sender_payment_instrument_id: None,},}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 37ce81a283..8567578d36 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1207,6 +1207,8 @@ diesel::table! {external_surcharge_details -> Nullable<Jsonb>,#[max_length = 255]network_transaction_link_id -> Nullable<Varchar>,+ #[max_length = 255]+ sender_payment_instrument_id -> Nullable<Varchar>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex a37519dfe6..421edf355a 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1148,6 +1148,8 @@ diesel::table! {external_surcharge_details -> Nullable<Jsonb>,#[max_length = 255]network_transaction_link_id -> Nullable<Varchar>,+ #[max_length = 255]+ sender_payment_instrument_id -> Nullable<Varchar>,payment_method_type_v2 -> Nullable<Varchar>,#[max_length = 128]connector_payment_id -> Nullable<Varchar>,diff --git a/crates/diesel_models/src/user/sample_data.rs b/crates/diesel_models/src/user/sample_data.rsindex db1f8750ea..b4fdbe4df2 100644--- a/crates/diesel_models/src/user/sample_data.rs+++ b/crates/diesel_models/src/user/sample_data.rs@@ -226,6 +226,7 @@ pub struct PaymentAttemptBatchNew {pub network_details: Option<NetworkDetails>,pub is_stored_credential: Option<bool>,pub authorized_amount: Option<MinorUnit>,+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]@@ -325,6 +326,7 @@ impl PaymentAttemptBatchNew {retry_type: None,installment_data: None,external_surcharge_details: None,+ sender_payment_instrument_id: None,}}}diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex fbf7f26dff..38c3190262 100644--- a/crates/external_services/Cargo.toml+++ b/crates/external_services/Cargo.toml@@ -74,7 +74,7 @@ http = "0.2.12"url = { version = "2.5.4", features = ["serde"] }quick-xml = { version = "0.31.0", features = ["serialize"] }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "1ef876126c42e1ed216f61845cff508a90badcf5", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.05.15.1", package = "rust-grpc-client" }open-feature = { version = "0.2.5", optional = true }superposition_provider = { version = "0.102.0", optional = true}superposition_types = "0.102.0"diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rsindex c932d78338..32dd39bc2b 100644--- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs+++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs@@ -1446,8 +1446,8 @@ impl ConnectorSpecifications for Airwallex {fn should_call_connector_customer(&self,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- matches!(+ ) -> api::ConnectorCustomerAction {+ if matches!(payment_attempt.setup_future_usage_applied,Some(enums::FutureUsage::OffSession)) && payment_attempt.customer_acceptance.is_some()@@ -1455,5 +1455,10 @@ impl ConnectorSpecifications for Airwallex {payment_attempt.payment_method,Some(enums::PaymentMethod::Card))+ {+ api::ConnectorCustomerAction::CallConnectorCustomer+ } else {+ api::ConnectorCustomerAction::NoAction+ }}}diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rsindex 59721b15ec..7f98394531 100644--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs@@ -1312,7 +1312,7 @@ impl ConnectorSpecifications for Authorizedotnet {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/dwolla.rs b/crates/hyperswitch_connectors/src/connectors/dwolla.rsindex e3f3e191bf..546e6b1921 100644--- a/crates/hyperswitch_connectors/src/connectors/dwolla.rs+++ b/crates/hyperswitch_connectors/src/connectors/dwolla.rs@@ -1019,7 +1019,7 @@ impl ConnectorSpecifications for Dwolla {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs b/crates/hyperswitch_connectors/src/connectors/facilitapay.rsindex 79b8e7cc44..ff1988f600 100644--- a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs+++ b/crates/hyperswitch_connectors/src/connectors/facilitapay.rs@@ -979,7 +979,7 @@ impl ConnectorSpecifications for Facilitapay {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/finix.rs b/crates/hyperswitch_connectors/src/connectors/finix.rsindex 2999d68c34..50dc2a9fe6 100644--- a/crates/hyperswitch_connectors/src/connectors/finix.rs+++ b/crates/hyperswitch_connectors/src/connectors/finix.rs@@ -1096,8 +1096,8 @@ impl ConnectorSpecifications for Finix {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}fn should_call_tokenization_before_setup_mandate(&self) -> bool {falsediff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rsindex d7564b8cdd..26b44d766d 100644--- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs+++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs@@ -963,7 +963,7 @@ impl ConnectorSpecifications for Gocardless {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rsindex 357b1299a8..414dc2d366 100644--- a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs+++ b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs@@ -501,7 +501,7 @@ impl ConnectorSpecifications for HyperswitchVault {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/mollie.rs b/crates/hyperswitch_connectors/src/connectors/mollie.rsindex ccb4544719..182e41a145 100644--- a/crates/hyperswitch_connectors/src/connectors/mollie.rs+++ b/crates/hyperswitch_connectors/src/connectors/mollie.rs@@ -1099,8 +1099,8 @@ impl ConnectorSpecifications for Mollie {fn should_call_connector_customer(&self,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- matches!(+ ) -> api::ConnectorCustomerAction {+ if matches!(payment_attempt.setup_future_usage_applied,Some(enums::FutureUsage::OffSession)) && payment_attempt.customer_acceptance.is_some()@@ -1108,5 +1108,10 @@ impl ConnectorSpecifications for Mollie {payment_attempt.payment_method,Some(enums::PaymentMethod::Card))+ {+ api::ConnectorCustomerAction::CallConnectorCustomer+ } else {+ api::ConnectorCustomerAction::NoAction+ }}}diff --git a/crates/hyperswitch_connectors/src/connectors/payload.rs b/crates/hyperswitch_connectors/src/connectors/payload.rsindex 8b9552dd6c..af85d18756 100644--- a/crates/hyperswitch_connectors/src/connectors/payload.rs+++ b/crates/hyperswitch_connectors/src/connectors/payload.rs@@ -46,8 +46,8 @@ use hyperswitch_domain_models::{};use hyperswitch_interfaces::{api::{- self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,- ConnectorValidation,+ self, ConnectorCommon, ConnectorCommonExt, ConnectorCustomerAction, ConnectorIntegration,+ ConnectorSpecifications, ConnectorValidation,},configs::Connectors,disputes::DisputePayload,@@ -1261,11 +1261,19 @@ impl ConnectorSpecifications for Payload {&self,#[cfg(feature = "v1")]payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {+ ) -> ConnectorCustomerAction {#[cfg(feature = "v1")]- return payment_attempt.customer_acceptance.is_some()- && payment_attempt.setup_future_usage_applied == Some(enums::FutureUsage::OffSession);+ {+ if payment_attempt.customer_acceptance.is_some()+ && payment_attempt.setup_future_usage_applied+ == Some(enums::FutureUsage::OffSession)+ {+ ConnectorCustomerAction::CallConnectorCustomer+ } else {+ ConnectorCustomerAction::NoAction+ }+ }#[cfg(feature = "v2")]- return false;+ ConnectorCustomerAction::NoAction}}diff --git a/crates/hyperswitch_connectors/src/connectors/paysafe.rs b/crates/hyperswitch_connectors/src/connectors/paysafe.rsindex a7bfda2e86..447d090c1c 100644--- a/crates/hyperswitch_connectors/src/connectors/paysafe.rs+++ b/crates/hyperswitch_connectors/src/connectors/paysafe.rs@@ -1340,8 +1340,8 @@ impl ConnectorSpecifications for Paysafe {fn should_call_connector_customer(&self,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- matches!(+ ) -> api::ConnectorCustomerAction {+ if matches!(payment_attempt.setup_future_usage_applied,Some(enums::FutureUsage::OffSession)) && payment_attempt.customer_acceptance.is_some()@@ -1353,5 +1353,10 @@ impl ConnectorSpecifications for Paysafe {payment_attempt.authentication_type,Some(enums::AuthenticationType::NoThreeDs) | None)+ {+ api::ConnectorCustomerAction::CallConnectorCustomer+ } else {+ api::ConnectorCustomerAction::NoAction+ }}}diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rsindex a7ef9706b4..a917b98907 100644--- a/crates/hyperswitch_connectors/src/connectors/stax.rs+++ b/crates/hyperswitch_connectors/src/connectors/stax.rs@@ -1039,7 +1039,7 @@ impl ConnectorSpecifications for Stax {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rsindex c90c47a364..8a17c9606a 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs@@ -3341,7 +3341,7 @@ impl ConnectorSpecifications for Stripe {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- true+ ) -> api::ConnectorCustomerAction {+ api::ConnectorCustomerAction::CallConnectorCustomer}}diff --git a/crates/hyperswitch_connectors/src/connectors/truelayer.rs b/crates/hyperswitch_connectors/src/connectors/truelayer.rsindex c4f260e51a..a8ab106f4d 100644--- a/crates/hyperswitch_connectors/src/connectors/truelayer.rs+++ b/crates/hyperswitch_connectors/src/connectors/truelayer.rs@@ -1105,13 +1105,12 @@ impl ConnectorSpecifications for Truelayer {Some(&TRUELAYER_SUPPORTED_WEBHOOK_FLOWS)}- #[cfg(feature = "v1")]- fn generate_connector_customer_id(+ fn should_call_connector_customer(&self,- _customer_id: &Option<common_utils::id_type::CustomerId>,- _merchant_id: &common_utils::id_type::MerchantId,- ) -> Option<String> {+ #[cfg(feature = "v1")]+ _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ ) -> api::ConnectorCustomerAction {let connector_customer_id = uuid::Uuid::new_v4().to_string();- Some(connector_customer_id)+ api::ConnectorCustomerAction::GeneratedCustomerId(connector_customer_id)}}diff --git a/crates/hyperswitch_connectors/src/connectors/truelayer/transformers.rs b/crates/hyperswitch_connectors/src/connectors/truelayer/transformers.rsindex 098c4dc91f..61d80ae2d4 100644--- a/crates/hyperswitch_connectors/src/connectors/truelayer/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/truelayer/transformers.rs@@ -336,7 +336,7 @@ pub struct TruelayerErrorResponse {pub detail: String,}-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+#[derive(Debug, Serialize, Deserialize, PartialEq)]pub struct TruelayerPayoutRequest {merchant_account_id: Secret<String>,amount_in_minor: MinorUnit,@@ -344,13 +344,23 @@ pub struct TruelayerPayoutRequest {beneficiary: TruelayerBeneficiary,}-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+#[derive(Debug, Serialize, Deserialize, PartialEq)]+#[serde_with::skip_serializing_none]pub struct TruelayerBeneficiary {#[serde(rename = "type")]- _type: String,+ _type: TruelayerBeneficiaryType,reference: String,- account_holder_name: Secret<String>,- account_identifier: TruelayerAccountIdentifier,+ account_holder_name: Option<Secret<String>>,+ account_identifier: Option<TruelayerAccountIdentifier>,+ payment_source_id: Option<Secret<String>>,+ user_id: Option<Secret<String>>,+}++#[derive(Debug, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "snake_case")]+pub enum TruelayerBeneficiaryType {+ ExternalAccount,+ PaymentSource,}#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]@@ -374,15 +384,35 @@ impl TryFrom<&TruelayerRouterData<&PayoutsRouterData<PoFulfill>>> for TruelayerPamount_in_minor: item.amount,currency: item.router_data.request.destination_currency,beneficiary: TruelayerBeneficiary {- _type: "external_account".to_string(),+ _type: TruelayerBeneficiaryType::ExternalAccount,reference: normalize_payment_id(item.router_data.request.payout_id.get_string_repr(),),- account_holder_name: open_banking_data.account_holder_name,- account_identifier: TruelayerAccountIdentifier {+ account_holder_name: Some(open_banking_data.account_holder_name),+ account_identifier: Some(TruelayerAccountIdentifier {_type: "iban".to_string(),iban: open_banking_data.iban,- },+ }),+ user_id: None,+ payment_source_id: None,+ },+ })+ }+ PayoutMethodData::Passthrough(passthrough_data) => {+ let metadata = TruelayerMetadata::try_from(&item.router_data.connector_meta_data)?;+ Ok(Self {+ merchant_account_id: metadata.merchant_account_id,+ amount_in_minor: item.amount,+ currency: item.router_data.request.destination_currency,+ beneficiary: TruelayerBeneficiary {+ _type: TruelayerBeneficiaryType::PaymentSource,+ reference: normalize_payment_id(+ item.router_data.request.payout_id.get_string_repr(),+ ),+ account_holder_name: None,+ account_identifier: None,+ user_id: passthrough_data.psp_customer_id,+ payment_source_id: Some(passthrough_data.psp_token),},})}diff --git a/crates/hyperswitch_connectors/src/connectors/trustly.rs b/crates/hyperswitch_connectors/src/connectors/trustly.rsindex 4d6209268e..b30f983657 100644--- a/crates/hyperswitch_connectors/src/connectors/trustly.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustly.rs@@ -947,4 +947,13 @@ impl ConnectorSpecifications for Trustly {fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {Some(&TRUSTLY_SUPPORTED_WEBHOOK_FLOWS)}++ fn should_call_connector_customer(+ &self,+ #[cfg(feature = "v1")]+ _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ ) -> api::ConnectorCustomerAction {+ let connector_customer_id = uuid::Uuid::new_v4().to_string();+ api::ConnectorCustomerAction::GeneratedCustomerId(connector_customer_id)+ }}diff --git a/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs b/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rsindex 93db607cfe..a634c92cca 100644--- a/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs@@ -1087,15 +1087,15 @@ pub struct TrustlyWebhookData {#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]pub struct TrustlyWebhookAttributes {- pub bank: Secret<String>,- pub city: Secret<String>,- pub name: Secret<String>,- pub address: Secret<String>,- pub zipcode: Secret<String>,- pub personid: Secret<String>,- pub descriptor: String,- pub lastdigits: String,- pub clearinghouse: String,+ pub bank: Option<Secret<String>>,+ pub city: Option<Secret<String>>,+ pub name: Option<Secret<String>>,+ pub address: Option<Secret<String>>,+ pub zipcode: Option<Secret<String>>,+ pub personid: Option<Secret<String>>,+ pub descriptor: Option<String>,+ pub lastdigits: Option<String>,+ pub clearinghouse: Option<String>,}pub fn is_payment_webhook_event(webhook_method: TrustlyWebhookMethod, message_id: String) -> bool {diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rsindex e7fc245112..3c7b1236f3 100644--- a/crates/hyperswitch_connectors/src/utils.rs+++ b/crates/hyperswitch_connectors/src/utils.rs@@ -7665,6 +7665,7 @@ pub(crate) fn convert_payment_authorize_router_response<F1, F2, T1, T2>(authorized_amount: data.authorized_amount,customer_document_details: data.customer_document_details.clone(),feature_data: data.feature_data.clone(),+ sender_payment_instrument_id: None,}}diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 7885eeb1a3..96c26c0a6e 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -1440,6 +1440,8 @@ pub struct PaymentAttempt {pub installment_data: Option<common_types::payments::InstallmentData>,/// External surcharge details from InterPayments (stored as JSONB)pub external_surcharge_details: Option<common_types::payments::ExternalSurchargeDetails>,+ /// Sender payment instrument ID+ pub sender_payment_instrument_id: Option<String>,}#[cfg(feature = "v1")]@@ -2049,6 +2051,7 @@ pub enum PaymentAttemptUpdate {advice_message: Option<Option<String>>,recommended_action: Option<Option<storage_enums::RecommendedAction>>,card_network: Option<storage_enums::CardNetwork>,+ sender_payment_instrument_id: Option<String>,},UnresolvedResponseUpdate {status: storage_enums::AttemptStatus,@@ -2405,6 +2408,7 @@ impl PaymentAttemptUpdate {advice_message,recommended_action,card_network,+ sender_payment_instrument_id,} => {let connector_details = ConnectorErrorDetails::new(error_code.clone(),@@ -2470,6 +2474,7 @@ impl PaymentAttemptUpdate {encrypted_payment_method_data: encrypted_payment_method_data.map(Encryption::from),error_details,+ sender_payment_instrument_id,}}Self::UnresolvedResponseUpdate {@@ -2964,6 +2969,7 @@ impl behaviour::Conversion for PaymentAttempt {encrypted_payment_method_data: self.encrypted_payment_method_data.map(Encryption::from),retry_type: self.retry_type,external_surcharge_details: self.external_surcharge_details,+ sender_payment_instrument_id: self.sender_payment_instrument_id,})}@@ -3099,6 +3105,7 @@ impl behaviour::Conversion for PaymentAttempt {retry_type: storage_model.retry_type,installment_data: storage_model.installment_data,external_surcharge_details: storage_model.external_surcharge_details,+ sender_payment_instrument_id: storage_model.sender_payment_instrument_id,})}.await@@ -3201,6 +3208,7 @@ impl behaviour::Conversion for PaymentAttempt {retry_type: self.retry_type,installment_data: self.installment_data,external_surcharge_details: self.external_surcharge_details,+ sender_payment_instrument_id: self.sender_payment_instrument_id,})}}@@ -3389,6 +3397,7 @@ impl behaviour::Conversion for PaymentAttempt {retry_type: None,installment_data: None,external_surcharge_details: None,+ sender_payment_instrument_id: None,})}diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rsindex 4452e9d738..9cabfb2003 100644--- a/crates/hyperswitch_domain_models/src/router_data.rs+++ b/crates/hyperswitch_domain_models/src/router_data.rs@@ -125,6 +125,8 @@ pub struct RouterData<Flow, Request, Response> {pub customer_document_details: Option<CustomerDocumentDetails>,// feature related datapub feature_data: Option<FeatureData>,+ /// A connector-specific identifier representing the stored payment instrument+ pub sender_payment_instrument_id: Option<String>,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.tomlindex 73a0f15098..45d0321923 100644--- a/crates/hyperswitch_interfaces/Cargo.toml+++ b/crates/hyperswitch_interfaces/Cargo.toml@@ -30,8 +30,7 @@ strum = { version = "0.26", features = ["derive"] }thiserror = "1.0.69"time = "0.3.41"url = { version = "2.5.4", features = ["serde"] }--unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "1ef876126c42e1ed216f61845cff508a90badcf5", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.05.15.1", package = "rust-grpc-client" }tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }# First party cratesdiff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rsindex facbd7384f..69cb4e5e1a 100644--- a/crates/hyperswitch_interfaces/src/api.rs+++ b/crates/hyperswitch_interfaces/src/api.rs@@ -428,6 +428,18 @@ pub struct PreProcessingFlowResponse<'a> {pub attempt_status: enums::AttemptStatus,}+/// Action to be taken for connector customer creation+#[derive(Debug, Clone, Default)]+pub enum ConnectorCustomerAction {+ /// Call the connector to create a customer+ CallConnectorCustomer,+ /// Use a customer ID generated at connector layer+ GeneratedCustomerId(String),+ /// No action required+ #[default]+ NoAction,+}+/// The trait that provides specifications about the connectorpub trait ConnectorSpecifications {/// Check if pre-authentication flow is required@@ -503,8 +515,8 @@ pub trait ConnectorSpecifications {&self,#[cfg(feature = "v1")]_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {- false+ ) -> ConnectorCustomerAction {+ ConnectorCustomerAction::NoAction}/// Validate if another operation is requireddiff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rsindex 420362b187..0b3a3a10c7 100644--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs@@ -16,8 +16,8 @@ use crate::{api,api::{BoxedConnectorIntegration, CaptureSyncMethod, Connector, ConnectorCommon,- ConnectorIntegration, ConnectorRedirectResponse, ConnectorSpecifications,- ConnectorValidation, CurrencyUnit,+ ConnectorCustomerAction, ConnectorIntegration, ConnectorRedirectResponse,+ ConnectorSpecifications, ConnectorValidation, CurrencyUnit,},authentication::ExternalAuthenticationPayload,connector_integration_v2::{BoxedConnectorIntegrationV2, ConnectorIntegrationV2, ConnectorV2},@@ -792,7 +792,7 @@ impl ConnectorSpecifications for ConnectorEnum {&self,#[cfg(feature = "v1")]payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,- ) -> bool {+ ) -> ConnectorCustomerAction {#[cfg(feature = "v1")]match self {Self::Old(connector) => connector.should_call_connector_customer(payment_attempt),diff --git a/crates/hyperswitch_interfaces/src/conversion_impls.rs b/crates/hyperswitch_interfaces/src/conversion_impls.rsindex 8a1430d406..6b702baf85 100644--- a/crates/hyperswitch_interfaces/src/conversion_impls.rs+++ b/crates/hyperswitch_interfaces/src/conversion_impls.rs@@ -98,6 +98,7 @@ fn get_default_router_data<F, Req, Resp>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,}}diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex bfe256794d..e65afdd0ac 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -90,9 +90,8 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "multring = "0.17.14"rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }--unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "1ef876126c42e1ed216f61845cff508a90badcf5", package = "rust-grpc-client" }-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "1ef876126c42e1ed216f61845cff508a90badcf5", package = "ucs_cards" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.05.15.1", package = "rust-grpc-client" }+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.05.15.1", package = "ucs_cards" }rustc-hash = "1.1.0"rustls = "0.22"rustls-pemfile = "2"diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rsindex a61e714d13..260a012391 100644--- a/crates/router/src/core/authentication/transformers.rs+++ b/crates/router/src/core/authentication/transformers.rs@@ -216,6 +216,7 @@ pub fn construct_router_data<F: Clone, Req, Res>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,})}diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rsindex 06f681e066..af5ed50a57 100644--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs@@ -182,6 +182,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC"Failed to extract customer document details from payment_intent",)?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rsindex d4d71930e3..14f76c6fec 100644--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs@@ -142,6 +142,7 @@ pub async fn construct_fulfillment_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rsindex 62abf60c24..5b05aca25b 100644--- a/crates/router/src/core/fraud_check/flows/record_return.rs+++ b/crates/router/src/core/fraud_check/flows/record_return.rs@@ -145,6 +145,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh"Failed to extract customer document details from payment_intent",)?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/fraud_check/flows/sale_flow.rs b/crates/router/src/core/fraud_check/flows/sale_flow.rsindex 6993aeb489..506fe09102 100644--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs@@ -161,6 +161,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp"Failed to extract customer document details from payment_intent",)?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/fraud_check/flows/transaction_flow.rs b/crates/router/src/core/fraud_check/flows/transaction_flow.rsindex d3cd4b520e..d171b1f330 100644--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs@@ -164,6 +164,7 @@ impl"Failed to extract customer document details from payment_intent",)?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/mandate/utils.rs b/crates/router/src/core/mandate/utils.rsindex 3e961e816d..7b5c7730aa 100644--- a/crates/router/src/core/mandate/utils.rs+++ b/crates/router/src/core/mandate/utils.rs@@ -94,6 +94,7 @@ pub async fn construct_mandate_revoke_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/merchant_connector_webhook_management/transformers.rs b/crates/router/src/core/merchant_connector_webhook_management/transformers.rsindex 34798f1d2e..b41ae1975b 100644--- a/crates/router/src/core/merchant_connector_webhook_management/transformers.rs+++ b/crates/router/src/core/merchant_connector_webhook_management/transformers.rs@@ -110,6 +110,7 @@ pub async fn construct_webhook_register_router_data<'a>(payout_id: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,})}diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 25d9a26fa4..cd2402a154 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -6855,6 +6855,7 @@ async fn create_single_use_tokenization_flow(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};let payment_method_token_response = Box::pin(tokenization::add_token_for_payment_method(diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rsindex 144c58d0f7..20e34de188 100644--- a/crates/router/src/core/payment_methods/vault.rs+++ b/crates/router/src/core/payment_methods/vault.rs@@ -1459,6 +1459,7 @@ impl Vaultable for api::PassthroughPayout {) -> CustomResult<String, errors::VaultError> {let value1 = TokenizedPassthroughSensitiveValues {psp_token: self.psp_token.clone(),+ psp_customer_id: self.psp_customer_id.clone(),};value1@@ -1500,6 +1501,7 @@ impl Vaultable for api::PassthroughPayout {let passthrough = Self {psp_token: value1.psp_token,+ psp_customer_id: value1.psp_customer_id,token_type: value2.token_type,};@@ -1528,6 +1530,7 @@ pub struct TokenizedBankRedirectInsensitiveValues {#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct TokenizedPassthroughSensitiveValues {pub psp_token: hyperswitch_masking::Secret<String>,+ pub psp_customer_id: Option<hyperswitch_masking::Secret<String>>,}#[derive(Debug, serde::Serialize, serde::Deserialize)]diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex bb52ce2a55..c60d51bd99 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -746,6 +746,22 @@ where.as_ref().and_then(|customer| customer.connector_customer.as_ref());+ let merchant_connector_id = payment_data+ .get_payment_attempt()+ .merchant_connector_id+ .clone();++ let connector_customer_id = connector_customer_map.and_then(|cc| {+ merchant_connector_id.and_then(|mca_id| {+ cc.clone()+ .expose()+ .get(mca_id.get_string_repr())+ .and_then(|val| val.as_str().map(String::from))+ })+ });++ payment_data.set_connector_customer_id(connector_customer_id);+let authentication_type = call_decision_manager(state,platform.get_processor(),@@ -7494,51 +7510,72 @@ where}};- let (should_call_connector, existing_connector_customer_id) =- customers::should_call_connector_create_customer(- &connector,- connector_customer_map,- payment_data.get_payment_attempt(),- &label,- );- logger::debug!(should_call_connector_customer = should_call_connector);- if should_call_connector {- // Create customer at connector and update the customer table to store this data- let mut customer_router_data = payment_data- .construct_router_data(- state,- connector.connector.id(),- processor,- merchant_connector_account,- None,- None,- payment_data.get_payment_attempt().payment_method,- payment_data.get_payment_attempt().payment_method_type,- )- .await?;+ match customers::should_call_connector_create_customer(+ &connector,+ connector_customer_map,+ payment_data.get_payment_attempt(),+ &label,+ ) {+ customers::ConnectorCustomerAction::CreateCustomer => {+ // Create customer at connector and update the customer table to store this data+ let mut customer_router_data = payment_data+ .construct_router_data(+ state,+ connector.connector.id(),+ processor,+ merchant_connector_account,+ None,+ None,+ payment_data.get_payment_attempt().payment_method,+ payment_data.get_payment_attempt().payment_method_type,+ )+ .await?;- customer_router_data.access_token = access_token.cloned();+ customer_router_data.access_token = access_token.cloned();- let connector_customer_id = customer_router_data- .create_connector_customer(state, &connector, gateway_context)- .await?;+ let connector_customer_id = customer_router_data+ .create_connector_customer(state, &connector, gateway_context)+ .await?;- let customer_update = customers::update_connector_customer_in_customers(- &label,- connector_customer_map,- connector_customer_id.clone(),- initiator,- )- .await;+ let customer_update: Option<+ hyperswitch_domain_models::customer::CustomerUpdate,+ > = customers::update_connector_customer_in_customers(+ &label,+ connector_customer_map,+ connector_customer_id.clone(),+ initiator,+ )+ .await;- payment_data.set_connector_customer_id(connector_customer_id);- Ok(customer_update)- } else {- // Customer already created in previous calls use the same value, no need to update- payment_data.set_connector_customer_id(- existing_connector_customer_id.map(ToOwned::to_owned),- );- Ok(None)+ payment_data.set_connector_customer_id(connector_customer_id);+ Ok(customer_update)+ }+ customers::ConnectorCustomerAction::StoreGeneratedCustomerId(+ generated_customer_id,+ ) => {+ // Only update with generated customer ID if there's no existing connector customer+ let customer_update: Option<+ hyperswitch_domain_models::customer::CustomerUpdate,+ > = customers::update_connector_customer_in_customers(+ &label,+ connector_customer_map,+ Some(generated_customer_id.clone()),+ initiator,+ )+ .await;++ payment_data.set_connector_customer_id(Some(generated_customer_id));+ Ok(customer_update)+ }+ customers::ConnectorCustomerAction::UseExistingCustomer(+ existing_connector_customer_id,+ ) => {+ // Customer already created in previous calls use the same value, no need to update+ payment_data.set_connector_customer_id(+ existing_connector_customer_id.map(ToOwned::to_owned),+ );+ Ok(None)+ }}}None => Ok(None),diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rsindex bf05b0b691..911e76fb1e 100644--- a/crates/router/src/core/payments/customers.rs+++ b/crates/router/src/core/payments/customers.rs@@ -79,29 +79,56 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(Ok(connector_customer_id)}+#[cfg(feature = "v1")]+#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]+pub enum ConnectorCustomerAction<'a> {+ CreateCustomer,+ StoreGeneratedCustomerId(String),+ UseExistingCustomer(Option<&'a str>),+}+#[cfg(feature = "v1")]pub fn should_call_connector_create_customer<'a>(connector: &api::ConnectorData,connector_customer_map: Option<&'a common_utils::pii::SecretSerdeValue>,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,connector_label: &str,-) -> (bool, Option<&'a str>) {+) -> ConnectorCustomerAction<'a> {// Check if create customer is required for the connector+ let mca_string = payment_attempt+ .merchant_connector_id+ .clone()+ .map(|mca_id| mca_id.get_string_repr().to_string())+ .unwrap_or_else(|| connector_label.to_string());let connector_needs_customer = connector.connector.should_call_connector_customer(payment_attempt);+let connector_customer_details = connector_customer_map- .and_then(|connector_customer_map| connector_customer_map.peek().get(connector_label))+ .and_then(|connector_customer_map| connector_customer_map.peek().get(mca_string.as_str())).and_then(|connector_customer| connector_customer.as_str());- if connector_needs_customer {- let should_call_connector = connector_customer_details.is_none();- (should_call_connector, connector_customer_details)- } else {- // Populates connector_customer_id if it is present after data migration- // For connector which does not have create connector customer flow- (false, connector_customer_details)+ match connector_needs_customer {+ hyperswitch_interfaces::api::ConnectorCustomerAction::CallConnectorCustomer => {+ match connector_customer_details {+ Some(existing_customer_id) => {+ ConnectorCustomerAction::UseExistingCustomer(Some(existing_customer_id))+ }+ None => ConnectorCustomerAction::CreateCustomer,+ }+ }+ hyperswitch_interfaces::api::ConnectorCustomerAction::NoAction => {+ ConnectorCustomerAction::UseExistingCustomer(connector_customer_details)+ }+ hyperswitch_interfaces::api::ConnectorCustomerAction::GeneratedCustomerId(customer_id) => {+ match connector_customer_details {+ Some(existing_customer_id) => {+ ConnectorCustomerAction::UseExistingCustomer(Some(existing_customer_id))+ }+ None => ConnectorCustomerAction::StoreGeneratedCustomerId(customer_id),+ }+ }}}@@ -116,14 +143,15 @@ pub fn should_call_connector_create_customer<'a>(domain::MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(_) => {let connector_needs_customer = connector.connector.should_call_connector_customer();- if connector_needs_customer {- let connector_customer_details = customer- .as_ref()- .and_then(|cust| cust.get_connector_customer_id(merchant_connector_account));- let should_call_connector = connector_customer_details.is_none();- (should_call_connector, connector_customer_details)- } else {- (false, None)+ match connector_needs_customer {+ hyperswitch_interfaces::api::ConnectorCustomerAction::CallConnectorCustomer => {+ let connector_customer_details = customer.as_ref().and_then(|cust| {+ cust.get_connector_customer_id(merchant_connector_account)+ });+ let should_call_connector = connector_customer_details.is_none();+ (should_call_connector, connector_customer_details)+ }+ _ => (false, None),}}diff --git a/crates/router/src/core/payments/gateway/psync_gateway.rs b/crates/router/src/core/payments/gateway/psync_gateway.rsindex 9843115e40..cfcc2574e2 100644--- a/crates/router/src/core/payments/gateway/psync_gateway.rs+++ b/crates/router/src/core/payments/gateway/psync_gateway.rs@@ -112,7 +112,8 @@ where.clone().map(|raw_connector_response| raw_connector_response.expose().into());router_data.connector_http_status_code = Some(status_code);-+ router_data.sender_payment_instrument_id =+ payment_get_response.sender_payment_instrument_id.clone();Ok(router_data.clone())}CallConnectorAction::Trigger => {@@ -235,7 +236,8 @@ where.clone().map(|raw_connector_response| raw_connector_response.expose().into());router_data.connector_http_status_code = Some(status_code);-+ router_data.sender_payment_instrument_id =+ payment_get_response.sender_payment_instrument_id.clone();Ok((router_data, (), payment_get_response))},))diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex d03f8f8095..6167210a4f 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -5107,6 +5107,7 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(authorized_amount: router_data.authorized_amount,customer_document_details: router_data.customer_document_details,feature_data: router_data.feature_data,+ sender_payment_instrument_id: router_data.sender_payment_instrument_id,}}@@ -5386,6 +5387,7 @@ impl AttemptType {retry_type: Some(enums::RetryType::ManualRetry),installment_data: None,external_surcharge_details: None,+ sender_payment_instrument_id: None,}}diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 45471510ea..d395aefe5a 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -69,6 +69,8 @@ use api_models::enums::FrmSuggestion;#[cfg(all(feature = "v1", feature = "dynamic_routing"))]use api_models::routing::RoutableConnectorChoice;use async_trait::async_trait;+#[cfg(feature = "v1")]+use common_utils::ext_traits::AsyncExt;use error_stack::{report, ResultExt};use router_env::{instrument, tracing};@@ -670,10 +672,10 @@ where#[cfg(feature = "v1")]async fn get_or_create_customer_details<'a>(&'a self,- _state: &SessionState,- _payment_data: &mut D,+ state: &SessionState,+ payment_data: &mut D,_request: Option<CustomerDetails>,- _provider: &domain::Provider,+ provider: &domain::Provider,_initiator: Option<&domain::Initiator>,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,_mandate_type: Option<api::MandateTransactionType>,@@ -684,11 +686,27 @@ where),errors::StorageError,> {- // We don't need to fetch customer here.- // Customer details have already been populated in the payment_intent during Confirm- // The customer returned from this method is only used for updating connector_customer_id- // which does not happen in case of Retrieve- Ok((Box::new(self), None))+ let db = &*state.store;+ let merchant_key_store = provider.get_key_store();+ let storage_scheme = provider.get_account().storage_scheme;+ let customer = payment_data+ .get_payment_intent()+ .customer_id+ .as_ref()+ .async_map(|customer_id| async {+ db.find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(+ customer_id,+ &merchant_key_store.merchant_id,+ merchant_key_store,+ storage_scheme,+ )+ .await+ })+ .await+ .transpose()?+ .flatten();++ Ok((Box::new(self), customer))}async fn get_connector<'a>(diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 4ff5adf539..cadaa355e9 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -357,15 +357,15 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>)?;// 3- (payment_intent, payment_attempt) = attempt_type- .modify_payment_intent_and_payment_attempt(+ (payment_intent, payment_attempt) =+ Box::pin(attempt_type.modify_payment_intent_and_payment_attempt(request,payment_intent,payment_attempt,state,platform.get_processor().get_key_store(),storage_scheme,- )+ )).await?;(diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex cf487dcf31..9d58f3cd32 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -1709,6 +1709,7 @@ impl PaymentCreate {retry_type: None,installment_data: None,external_surcharge_details: None,+ sender_payment_instrument_id: None,},additional_pm_data,diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 41f407a817..c7081742cf 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -2557,6 +2557,9 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(card_network: payment_data.payment_attempt.extract_card_network(),+ sender_payment_instrument_id: router_data+ .sender_payment_instrument_id+ .clone(),}),),};diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rsindex da2a2d8f14..b68b658fec 100644--- a/crates/router/src/core/payments/retry.rs+++ b/crates/router/src/core/payments/retry.rs@@ -638,6 +638,10 @@ whereadvice_message: None,recommended_action: None,card_network: payment_data.get_payment_attempt().extract_card_network(),+ sender_payment_instrument_id: payment_data+ .get_payment_attempt()+ .sender_payment_instrument_id+ .clone(),};#[cfg(feature = "v1")]@@ -871,6 +875,7 @@ pub fn make_new_auto_retry_payment_attempt(retry_type: Some(storage_enums::RetryType::AutoRetry),installment_data: Default::default(),external_surcharge_details: Default::default(),+ sender_payment_instrument_id: Default::default(),}}diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex af58da0700..165ebf3783 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -223,6 +223,7 @@ whereauthorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -584,6 +585,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -932,6 +934,7 @@ pub async fn construct_payment_router_data_for_capture<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -1070,6 +1073,7 @@ pub async fn construct_router_data_for_psync<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -1438,6 +1442,7 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -1670,6 +1675,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -2002,6 +2008,7 @@ whereauthorized_amount: None,customer_document_details,feature_data,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -2223,6 +2230,7 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -4038,6 +4046,7 @@ wherepayment_id: payment_intent.payment_id,merchant_id: payment_intent.merchant_id,status: payment_intent.status,+ connector_customer_id: payment_data.get_connector_customer_id(),amount: payment_attempt.net_amount.get_order_amount(),net_amount: payment_attempt.get_total_amount(),amount_capturable: payment_attempt.amount_capturable,@@ -4178,6 +4187,7 @@ whereinstallment_options: payment_intent.installment_options,installment_data: payment_data.get_installment_details().cloned(),connector_response_metadata,+ sender_payment_instrument_id: payment_attempt.sender_payment_instrument_id.clone(),};services::ApplicationResponse::JsonWithHeaders((payments_response, headers))@@ -4449,6 +4459,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Payprocessor_merchant_id: pi.processor_merchant_id,initiator: None,sdk_authorization: None,+ connector_customer_id: None,refunds: None,disputes: None,attempts: None,@@ -4523,6 +4534,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paypayment_method_tokenization_details: None,installment_options: pi.installment_options,installment_data: pa.installment_data,+ sender_payment_instrument_id: pa.sender_payment_instrument_id.clone(),}}}diff --git a/crates/router/src/core/relay/utils.rs b/crates/router/src/core/relay/utils.rsindex 1c38eff689..cfbbf2d887 100644--- a/crates/router/src/core/relay/utils.rs+++ b/crates/router/src/core/relay/utils.rs@@ -149,6 +149,7 @@ pub async fn construct_relay_refund_router_data<F>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -287,6 +288,7 @@ pub async fn construct_relay_capture_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -410,6 +412,7 @@ pub async fn construct_relay_incremental_authorization_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -542,6 +545,7 @@ pub async fn construct_relay_void_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -688,6 +692,7 @@ pub async fn construct_relay_payments_retrieve_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rsindex e116912bc0..7520efff90 100644--- a/crates/router/src/core/unified_authentication_service/utils.rs+++ b/crates/router/src/core/unified_authentication_service/utils.rs@@ -150,6 +150,7 @@ pub fn construct_uas_router_data<F: Clone, Req, Res>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,})}@@ -703,6 +704,7 @@ pub fn construct_uas_webhook_router_data<F: Clone, Req, Res>(is_payment_id_from_merchant: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,})}diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex e5a9bf1c72..fdaac33ea8 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -354,6 +354,7 @@ impl.map(payments_grpc::Tokenization::foreign_from).map(Into::into),l2_l3_data: None,+ merchant_request_id: None,})}}@@ -545,6 +546,7 @@ impl.map(Into::into),l2_l3_data: None,connector_order_id: None,+ merchant_request_id: None,})}}@@ -720,6 +722,7 @@ impl transformers::ForeignTryFrom<&RouterData<PSync, PaymentsSyncData, PaymentsR.payment_experience.map(payments_grpc::PaymentExperience::foreign_from).map(Into::into),+ merchant_request_id: None,})}}@@ -1126,6 +1129,7 @@ impl transformers::ForeignTryFrom<&RouterData<Capture, PaymentsCaptureData, Paym.map(|s| s.into()),test_mode: router_data.test_mode,merchant_order_id: router_data.request.merchant_order_reference_id.clone(),+ merchant_request_id: None,})}}@@ -1268,6 +1272,7 @@ implcontinue_redirection_url: None,connector_order_id: None,l2_l3_data: None,+ merchant_request_id: None,})}}@@ -1447,6 +1452,7 @@ implcontinue_redirection_url: None,connector_order_id: None,l2_l3_data: None,+ merchant_request_id: None,})}}@@ -1606,6 +1612,7 @@ implcontinue_redirection_url: None,connector_order_id: None,l2_l3_data: None,+ merchant_request_id: None,})}}@@ -5773,6 +5780,7 @@ impl transformers::ForeignTryFrom<&RouterData<Execute, RefundsData, RefundsRespo.customer_id.as_ref().map(|id| id.get_string_repr().to_string()),+ merchant_request_id: None,})}}@@ -5840,6 +5848,7 @@ impl transformers::ForeignTryFrom<&RouterData<RSync, RefundsData, RefundsResponstest_mode: router_data.test_mode,payment_method_type,connector_feature_data: None,+ merchant_request_id: None,})}}@@ -5965,6 +5974,7 @@ impl transformers::ForeignTryFrom<&RouterData<api::Void, PaymentsCancelData, Pay.map(|s| s.into()),test_mode: router_data.test_mode,merchant_order_id: router_data.request.merchant_order_reference_id.clone(),+ merchant_request_id: None,})}}diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 1ba0b5660b..b007678b55 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -325,6 +325,7 @@ pub async fn construct_payout_router_data<'a, F>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -503,6 +504,7 @@ pub async fn construct_refund_router_data<'a, F>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -700,6 +702,7 @@ pub async fn construct_refund_router_data<'a, F>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)@@ -1217,6 +1220,7 @@ pub async fn construct_accept_dispute_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1328,6 +1332,7 @@ pub async fn construct_submit_evidence_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1445,6 +1450,7 @@ pub async fn construct_upload_file_router_data<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1523,6 +1529,7 @@ pub async fn construct_dispute_list_router_data<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,})}@@ -1636,6 +1643,7 @@ pub async fn construct_dispute_sync_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1772,6 +1780,7 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<F: Clone>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1886,6 +1895,7 @@ pub async fn construct_defend_dispute_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to extract customer document details from payment_intent")?,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}@@ -1990,6 +2000,7 @@ pub async fn construct_retrieve_file_router_data<'a>(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rsindex a7764f1486..ee3a4fba20 100644--- a/crates/router/src/core/webhooks/utils.rs+++ b/crates/router/src/core/webhooks/utils.rs@@ -142,6 +142,7 @@ pub async fn construct_webhook_router_data(authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,};Ok(router_data)}diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 5545044ba1..e15a1a8b63 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -2155,6 +2155,8 @@ mod tests {installment_data: None,state_metadata: None,connector_response_metadata: None,+ connector_customer_id: None,+ sender_payment_instrument_id: None,};let content =api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response));diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex d318ef23ad..12b6036f22 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -1475,6 +1475,7 @@ impl<F1, F2, T1, T2> ForeignFrom<(&RouterData<F1, T1, PaymentsResponseData>, T2)authorized_amount: data.authorized_amount,customer_document_details: data.customer_document_details.clone(),feature_data: data.feature_data.clone(),+ sender_payment_instrument_id: None,}}}@@ -1550,6 +1551,7 @@ impl<F1, F2>authorized_amount: None,customer_document_details: None,feature_data: data.feature_data.clone(),+ sender_payment_instrument_id: None,}}}diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rsindex 9739504178..9b96b3957c 100644--- a/crates/router/src/types/api/verify_connector.rs+++ b/crates/router/src/types/api/verify_connector.rs@@ -149,6 +149,7 @@ impl VerifyConnectorData {authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,}}}diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rsindex e3ce3dcbcf..23288159c0 100644--- a/crates/router/src/types/storage/payment_attempt.rs+++ b/crates/router/src/types/storage/payment_attempt.rs@@ -247,6 +247,7 @@ mod tests {retry_type: Default::default(),installment_data: Default::default(),external_surcharge_details: Default::default(),+ sender_payment_instrument_id: Default::default(),};let store = state@@ -369,6 +370,7 @@ mod tests {retry_type: Default::default(),installment_data: Default::default(),external_surcharge_details: Default::default(),+ sender_payment_instrument_id: Default::default(),};let store = state.stores@@ -505,6 +507,7 @@ mod tests {retry_type: Default::default(),installment_data: Default::default(),external_surcharge_details: Default::default(),+ sender_payment_instrument_id: Default::default(),};let store = state.storesdiff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex ef72f0e227..870733f622 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -402,6 +402,7 @@ pub async fn generate_sample_data(authorized_amount: None,tokenization: None,encrypted_payment_method_data: None,+ sender_payment_instrument_id: None,};let refund = if refunds_count < number_of_refunds && !is_failed_payment {diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex 610c3f72f9..ae35bf5e0e 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -571,6 +571,7 @@ pub trait ConnectorActions: Connector {authorized_amount: None,customer_document_details: None,feature_data: None,+ sender_payment_instrument_id: None,}}diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex e9d7ae523f..223ff3c628 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -485,6 +485,8 @@ async fn payments_create_core() {installment_data: None,state_metadata: None,connector_response_metadata: None,+ connector_customer_id: None,+ sender_payment_instrument_id: None,};let expected_response =services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));@@ -788,6 +790,8 @@ async fn payments_create_core_adyen_no_redirect() {installment_data: None,state_metadata: None,connector_response_metadata: None,+ connector_customer_id: None,+ sender_payment_instrument_id: None,},vec![],));diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 526cfc00d7..e2e1238ccc 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -245,6 +245,8 @@ async fn payments_create_core() {installment_data: None,state_metadata: None,connector_response_metadata: None,+ connector_customer_id: None,+ sender_payment_instrument_id: None,};let expected_response =@@ -557,6 +559,8 @@ async fn payments_create_core_adyen_no_redirect() {installment_data: None,state_metadata: None,connector_response_metadata: None,+ connector_customer_id: None,+ sender_payment_instrument_id: None,},vec![],));diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rsindex 54e8df65f4..484383e88a 100644--- a/crates/storage_impl/src/mock_db/payment_attempt.rs+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs@@ -252,6 +252,7 @@ impl PaymentAttemptInterface for MockDb {retry_type: payment_attempt.retry_type,installment_data: payment_attempt.installment_data,external_surcharge_details: payment_attempt.external_surcharge_details,+ sender_payment_instrument_id: payment_attempt.sender_payment_instrument_id,};payment_attempts.push(payment_attempt.clone());Ok(payment_attempt)diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex c063242c91..1d605684c8 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -852,6 +852,9 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {retry_type: payment_attempt.retry_type,installment_data: payment_attempt.installment_data.clone(),external_surcharge_details: payment_attempt.external_surcharge_details.clone(),+ sender_payment_instrument_id: payment_attempt+ .sender_payment_instrument_id+ .clone(),};let field = format!("pa_{}", created_attempt.attempt_id);diff --git a/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/down.sql b/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/down.sqlnew file mode 100644index 0000000000..daae95dd38--- /dev/null+++ b/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/down.sql@@ -0,0 +1,2 @@+-- This file should undo anything in `up.sql`+ALTER TABLE payment_attempt DROP COLUMN sender_payment_instrument_id;\ No newline at end of filediff --git a/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/up.sql b/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/up.sqlnew file mode 100644index 0000000000..7c05505b29--- /dev/null+++ b/migrations/2026-05-14-111859_add_sender_payment_instrument_id_payment_attempt/up.sql@@ -0,0 +1,2 @@+-- Your SQL goes here+ALTER TABLE payment_attempt ADD COLUMN IF NOT EXISTS sender_payment_instrument_id VARCHAR(255);\ No newline at end of file