Skip to content

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

feat(payments): [checkout][worldpay wpg] add sender_details for AFT with individual and corporate senders (#14928)

Akshaya Shankar74a8921f3ce2
diff --git a/Cargo.lock b/Cargo.lock
index a86ece0291..3609ef4e53 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2290,7 +2290,7 @@ dependencies = [
[[package]]
name = "config_patch_derive"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"proc-macro2",
"quote",
@@ -4205,7 +4205,7 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"axum 0.8.4",
"bytes",
@@ -6945,7 +6945,7 @@ dependencies = [
"regex-cache",
"serde",
"serde_derive",
- "strum 0.26.3",
+ "strum 0.25.0",
"thiserror 1.0.69",
]
@@ -8212,7 +8212,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"grpc-api-types",
]
@@ -10846,7 +10846,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"bytes",
"error-stack 0.4.1",
@@ -10862,7 +10862,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"serde",
"strum 0.26.3",
@@ -10873,7 +10873,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?tag=2026.11.17.1#484b523b78f7349adfcbd751e2854ae29f111e0f"
+source = "git+https://github.com/juspay/connector-service?tag=2026.11.18.1#26c60287b5a3dcd78862bbcedab9d41e4510237f"
dependencies = [
"anyhow",
"base64 0.21.7",
@@ -11674,7 +11674,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.48.0",
]
[[package]]
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index e3ecec9802..bce333f166 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -20466,6 +20466,42 @@
}
}
},
+ "CorporateSenderDetailsResponse": {
+ "type": "object",
+ "description": "A partially masked view of `CorporateSenderDetails`, safe to return in API responses.",
+ "required": [
+ "company_name"
+ ],
+ "properties": {
+ "company_name": {
+ "type": "string",
+ "description": "The sender's legal company name.",
+ "example": "Acme Ltd"
+ },
+ "address": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/AddressDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "phone": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MaskedSenderPhoneDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "The sender's masked email address.",
+ "example": "tr******@acme.com",
+ "nullable": true
+ }
+ }
+ },
"Country": {
"type": "string",
"enum": [
@@ -26942,6 +26978,46 @@
}
}
},
+ "IndividualSenderDetailsResponse": {
+ "type": "object",
+ "description": "A partially masked view of `IndividualSenderDetails`, safe to return in API responses.",
+ "properties": {
+ "first_name": {
+ "type": "string",
+ "description": "The sender's first name.",
+ "example": "John",
+ "nullable": true
+ },
+ "last_name": {
+ "type": "string",
+ "description": "The sender's last name.",
+ "example": "Doe",
+ "nullable": true
+ },
+ "address": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/AddressDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "phone": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MaskedSenderPhoneDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "The sender's masked email address.",
+ "example": "jo******@example.com",
+ "nullable": true
+ }
+ }
+ },
"IndomaretVoucherData": {
"type": "object",
"properties": {
@@ -28066,6 +28142,24 @@
}
}
},
+ "MaskedSenderPhoneDetails": {
+ "type": "object",
+ "description": "A partially masked view of [`PhoneDetails`], safe to return in API responses.",
+ "properties": {
+ "number": {
+ "type": "string",
+ "description": "The sender's partially masked phone number.",
+ "example": "********89",
+ "nullable": true
+ },
+ "country_code": {
+ "type": "string",
+ "description": "The country code of the sender's phone number.",
+ "example": "+44",
+ "nullable": true
+ }
+ }
+ },
"MasterCardEligibilityCheckData": {
"type": "object",
"required": [
@@ -36594,6 +36688,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"tokenization": {
"allOf": [
{
@@ -37440,6 +37542,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetailsResponse"
+ }
+ ],
+ "nullable": true
+ },
"tokenization": {
"allOf": [
{
@@ -38522,6 +38632,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"tokenization": {
"allOf": [
{
@@ -39394,6 +39512,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetailsResponse"
+ }
+ ],
+ "nullable": true
+ },
"tokenization": {
"allOf": [
{
@@ -40179,6 +40305,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"tokenization": {
"allOf": [
{
@@ -47725,6 +47859,56 @@
"propertyName": "type"
}
},
+ "SenderDetailsResponse": {
+ "oneOf": [
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/IndividualSenderDetailsResponse"
+ },
+ {
+ "type": "object",
+ "required": [
+ "type"
+ ],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "individual"
+ ]
+ }
+ }
+ }
+ ]
+ },
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CorporateSenderDetailsResponse"
+ },
+ {
+ "type": "object",
+ "required": [
+ "type"
+ ],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "corporate"
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "description": "A partially masked view of `SenderDetails`, safe to return in API responses. The sender's\ndate of birth is never returned.",
+ "discriminator": {
+ "propertyName": "type"
+ }
+ },
"SepaAndBacsBillingDetails": {
"type": "object",
"properties": {
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index a30ce9db31..95be82e115 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -13440,6 +13440,42 @@
}
}
},
+ "CorporateSenderDetailsResponse": {
+ "type": "object",
+ "description": "A partially masked view of `CorporateSenderDetails`, safe to return in API responses.",
+ "required": [
+ "company_name"
+ ],
+ "properties": {
+ "company_name": {
+ "type": "string",
+ "description": "The sender's legal company name.",
+ "example": "Acme Ltd"
+ },
+ "address": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/AddressDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "phone": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MaskedSenderPhoneDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "The sender's masked email address.",
+ "example": "tr******@acme.com",
+ "nullable": true
+ }
+ }
+ },
"CountryAlpha2": {
"type": "string",
"enum": [
@@ -18567,6 +18603,46 @@
}
}
},
+ "IndividualSenderDetailsResponse": {
+ "type": "object",
+ "description": "A partially masked view of `IndividualSenderDetails`, safe to return in API responses.",
+ "properties": {
+ "first_name": {
+ "type": "string",
+ "description": "The sender's first name.",
+ "example": "John",
+ "nullable": true
+ },
+ "last_name": {
+ "type": "string",
+ "description": "The sender's last name.",
+ "example": "Doe",
+ "nullable": true
+ },
+ "address": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/AddressDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "phone": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MaskedSenderPhoneDetails"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "The sender's masked email address.",
+ "example": "jo******@example.com",
+ "nullable": true
+ }
+ }
+ },
"IndomaretVoucherData": {
"type": "object",
"properties": {
@@ -19533,6 +19609,24 @@
}
}
},
+ "MaskedSenderPhoneDetails": {
+ "type": "object",
+ "description": "A partially masked view of [`PhoneDetails`], safe to return in API responses.",
+ "properties": {
+ "number": {
+ "type": "string",
+ "description": "The sender's partially masked phone number.",
+ "example": "********89",
+ "nullable": true
+ },
+ "country_code": {
+ "type": "string",
+ "description": "The country code of the sender's phone number.",
+ "example": "+44",
+ "nullable": true
+ }
+ }
+ },
"MbWayRedirection": {
"type": "object",
"required": [
@@ -26787,6 +26881,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"enable_avs_check": {
"type": "boolean",
"description": "Request address verification using the billing address for supported card payments.",
@@ -27200,6 +27302,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetailsResponse"
+ }
+ ],
+ "nullable": true
+ },
"enable_avs_check": {
"type": "boolean",
"description": "Whether address verification was requested for this payment.",
@@ -27714,6 +27824,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"enable_avs_check": {
"type": "boolean",
"description": "Request address verification using the billing address for supported card payments.\nOmit this field on updates or confirmation to preserve the existing setting.",
@@ -28248,6 +28366,14 @@
],
"nullable": true
},
+ "sender_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SenderDetails"
+ }
+ ],
+ "nullable": true
+ },
"enable_avs_check": {
"type": "boolean",
"description": "Request address verification using the billing address for supported card payments.\nOmit this field on updates or confirmation to preserve the existing setting.",
@@ -34962,6 +35088,56 @@
"propertyName": "type"
}
},
+ "SenderDetailsResponse": {
+ "oneOf": [
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/IndividualSenderDetailsResponse"
+ },
+ {
+ "type": "object",
+ "required": [
+ "type"
+ ],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "individual"
+ ]
+ }
+ }
+ }
+ ]
+ },
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CorporateSenderDetailsResponse"
+ },
+ {
+ "type": "object",
+ "required": [
+ "type"
+ ],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "corporate"
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "description": "A partially masked view of `SenderDetails`, safe to return in API responses. The sender's\ndate of birth is never returned.",
+ "discriminator": {
+ "propertyName": "type"
+ }
+ },
"SepaAndBacsBillingDetails": {
"type": "object",
"properties": {
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index dca69239ef..adbefc67da 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -25,7 +25,7 @@ use common_utils::{
consts::DISCOUNT_PERCENTAGE_PRECISION_LENGTH,
crypto,
errors::ValidationError,
- ext_traits::{ConfigExt, Encode, ValueExt},
+ ext_traits::{ConfigExt, Encode, SecretStringExt, ValueExt},
hashing::HashedString,
id_type,
new_type::MaskedBankAccount,
@@ -41,7 +41,10 @@ pub use self::recipient::{
MaskedRecipientAccount, MaskedRecipientBankAccount, MaskedRecipientDetails, RecipientAccount,
RecipientBankAccount, RecipientDetails,
};
-use crate::customers::CustomerDocumentDetails;
+use crate::{
+ customers::CustomerDocumentDetails,
+ sender::{SenderDetails, SenderDetailsResponse},
+};
#[cfg(any(feature = "v1", feature = "v2"))]
pub(crate) fn parse_comma_separated<'de, D, T>(v: D) -> Result<Option<Vec<T>>, D::Error>
@@ -394,6 +397,10 @@ pub struct PaymentsCreateIntentRequest {
#[schema(value_type = Option<RecipientDetails>)]
pub recipient_details: Option<RecipientDetails>,
+ /// Details of the party providing the funds in an account funded transaction.
+ #[schema(value_type = Option<SenderDetails>)]
+ pub sender_details: Option<SenderDetails>,
+
/// Request address verification using the billing address for supported card payments.
#[schema(default = false, example = true)]
pub enable_avs_check: Option<bool>,
@@ -593,6 +600,10 @@ pub struct PaymentsUpdateIntentRequest {
#[schema(value_type = Option<RecipientDetails>)]
pub recipient_details: Option<RecipientDetails>,
+ /// Details of the party providing the funds in an account funded transaction.
+ #[schema(value_type = Option<SenderDetails>)]
+ pub sender_details: Option<SenderDetails>,
+
/// Request address verification using the billing address for supported card payments.
/// Omit this field on updates or confirmation to preserve the existing setting.
#[schema(default = false, example = true)]
@@ -635,6 +646,7 @@ impl PaymentsUpdateIntentRequest {
enable_partial_authorization: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
}
@@ -794,6 +806,11 @@ pub struct PaymentsIntentResponse {
#[schema(value_type = Option<MaskedRecipientDetails>)]
pub recipient_details: Option<MaskedRecipientDetails>,
+ /// Partially masked details of the party providing the funds in an account funded
+ /// transaction. The sender's date of birth is never returned.
+ #[schema(value_type = Option<SenderDetailsResponse>)]
+ pub sender_details: Option<SenderDetailsResponse>,
+
/// Whether address verification was requested for this payment.
#[schema(example = true)]
pub enable_avs_check: Option<bool>,
@@ -1702,6 +1719,11 @@ pub struct PaymentsRequest {
#[remove_in(PaymentsConfirmRequest)]
pub recipient_details: Option<RecipientDetails>,
+ /// Details of the party providing the funds in an account funded transaction.
+ #[schema(value_type = Option<SenderDetails>)]
+ #[remove_in(PaymentsConfirmRequest)]
+ pub sender_details: Option<SenderDetails>,
+
/// The tokenization preference for the payment method. This is used to control whether a PSP token is created or not.
#[schema(value_type = Option<Tokenization>, example = "tokenize_at_psp")]
pub tokenization: Option<enums::Tokenization>,
@@ -6887,6 +6909,15 @@ pub struct AddressDetails {
}
impl AddressDetails {
+ /// The address with surrounding whitespace removed from the first and last names.
+ pub fn with_trimmed_names(self) -> Self {
+ Self {
+ first_name: self.first_name.and_then(SecretStringExt::trim_to_non_empty),
+ last_name: self.last_name.and_then(SecretStringExt::trim_to_non_empty),
+ ..self
+ }
+ }
+
pub fn get_optional_full_name(&self) -> Option<Secret<String>> {
match (self.first_name.as_ref(), self.last_name.as_ref()) {
(Some(first_name), Some(last_name)) => Some(Secret::new(format!(
@@ -8290,6 +8321,11 @@ pub struct PaymentsResponse {
#[schema(value_type = Option<MaskedRecipientDetails>)]
pub recipient_details: Option<MaskedRecipientDetails>,
+ /// Partially masked details of the party providing the funds in an account funded
+ /// transaction. The sender's date of birth is never returned.
+ #[schema(value_type = Option<SenderDetailsResponse>)]
+ pub sender_details: Option<SenderDetailsResponse>,
+
/// The tokenization preference for the payment method. This is used to control whether a PSP token is created or not.
#[schema(value_type = Option<Tokenization>,example="skip_psp")]
pub tokenization: Option<enums::Tokenization>,
@@ -8881,6 +8917,10 @@ pub struct PaymentsRequest {
#[schema(value_type = Option<RecipientDetails>)]
pub recipient_details: Option<RecipientDetails>,
+ /// Details of the party providing the funds in an account funded transaction.
+ #[schema(value_type = Option<SenderDetails>)]
+ pub sender_details: Option<SenderDetails>,
+
/// Request address verification using the billing address for supported card payments.
/// Omit this field on updates or confirmation to preserve the existing setting.
#[schema(default = false, example = true)]
@@ -8926,6 +8966,7 @@ impl From<&PaymentsRequest> for PaymentsCreateIntentRequest {
enable_partial_authorization: request.enable_partial_authorization,
is_account_funded_transaction: request.is_account_funded_transaction,
recipient_details: request.recipient_details.clone(),
+ sender_details: request.sender_details.clone(),
enable_avs_check: request.enable_avs_check,
enable_account_name_verification: request.enable_account_name_verification,
mit_category: None,
diff --git a/crates/api_models/src/sender.rs b/crates/api_models/src/sender.rs
index 57412f6008..cc072e0bf4 100644
--- a/crates/api_models/src/sender.rs
+++ b/crates/api_models/src/sender.rs
@@ -8,6 +8,7 @@
use common_types::payments::PhoneDetails;
use common_utils::{
+ ext_traits::SecretStringExt,
new_type::{MaskedEmail, MaskedPhoneNumber},
pii::Email,
transformers::ForeignFrom,
@@ -114,18 +115,68 @@ pub enum SenderDetails {
}
impl SenderDetails {
- /// The individual sender's first name, if provided.
+ /// The sender with surrounding whitespace removed from every name, as connectors reject
+ /// names that are padded.
+ pub fn with_trimmed_names(self) -> Self {
+ match self {
+ Self::Individual(individual) => Self::Individual(IndividualSenderDetails {
+ first_name: individual
+ .first_name
+ .and_then(SecretStringExt::trim_to_non_empty),
+ last_name: individual
+ .last_name
+ .and_then(SecretStringExt::trim_to_non_empty),
+ address: individual.address.map(AddressDetails::with_trimmed_names),
+ ..individual
+ }),
+ Self::Corporate(corporate) => Self::Corporate(CorporateSenderDetails {
+ company_name: corporate.company_name.map(|name| name.trim().to_owned()),
+ address: corporate.address.map(AddressDetails::with_trimmed_names),
+ ..corporate
+ }),
+ }
+ }
+
+ /// The names identifying the sender that are provided, keyed by their field path, for validation.
+ pub fn get_name_fields(&self) -> Vec<(&'static str, &Secret<String>)> {
+ match self {
+ Self::Individual(individual) => [
+ ("sender_details.first_name", individual.first_name.as_ref()),
+ ("sender_details.last_name", individual.last_name.as_ref()),
+ ]
+ .into_iter()
+ .filter_map(|(field_name, value)| value.map(|value| (field_name, value)))
+ .collect(),
+ Self::Corporate(corporate) => {
+ vec![("sender_details.company_name", &corporate.company_name)]
+ }
+ }
+ }
+
+ /// The individual sender's first name, falling back to the first name on the sender's
+ /// address when not provided.
pub fn get_individual_first_name(&self) -> Option<&Secret<String>> {
match self {
- Self::Individual(individual) => individual.first_name.as_ref(),
+ Self::Individual(individual) => individual.first_name.as_ref().or_else(|| {
+ individual
+ .address
+ .as_ref()
+ .and_then(|address| address.first_name.as_ref())
+ }),
Self::Corporate(_) => None,
}
}
- /// The individual sender's last name, if provided.
+ /// The individual sender's last name, falling back to the last name on the sender's
+ /// address when not provided.
pub fn get_individual_last_name(&self) -> Option<&Secret<String>> {
match self {
- Self::Individual(individual) => individual.last_name.as_ref(),
+ Self::Individual(individual) => individual.last_name.as_ref().or_else(|| {
+ individual
+ .address
+ .as_ref()
+ .and_then(|address| address.last_name.as_ref())
+ }),
Self::Corporate(_) => None,
}
}
diff --git a/crates/common_utils/src/ext_traits.rs b/crates/common_utils/src/ext_traits.rs
index 08f4367455..a660ca1cbc 100644
--- a/crates/common_utils/src/ext_traits.rs
+++ b/crates/common_utils/src/ext_traits.rs
@@ -541,6 +541,18 @@ where
}
}
+/// Extension trait for whitespace handling on masked strings, without exposing the value
+pub trait SecretStringExt: Sized {
+ /// Returns the value with surrounding whitespace removed, or `None` when nothing is left
+ fn trim_to_non_empty(self) -> Option<Self>;
+}
+
+impl<S: Strategy<String>> SecretStringExt for Secret<String, S> {
+ fn trim_to_non_empty(self) -> Option<Self> {
+ Some(self.map(|value| value.trim().to_owned())).filter(|value| !value.peek().is_empty())
+ }
+}
+
/// Extension trait for deserializing XML strings using `quick-xml` crate
pub trait XmlExt {
/// Deserialize an XML string into the specified type `<T>`.
diff --git a/crates/common_utils/src/new_type.rs b/crates/common_utils/src/new_type.rs
index 8973f02202..acb6cb8c40 100644
--- a/crates/common_utils/src/new_type.rs
+++ b/crates/common_utils/src/new_type.rs
@@ -258,11 +258,15 @@ impl From<String> for MaskedUpiVpaId {
let unmasked_char_count = 2;
let masked_value = if let Some((user_identifier, bank_or_psp)) = src.split_once('@') {
let masked_user_identifier = user_identifier
- .to_string()
.chars()
.take(unmasked_char_count)
.collect::<String>()
- + &"*".repeat(user_identifier.len() - unmasked_char_count);
+ + &"*".repeat(
+ user_identifier
+ .chars()
+ .count()
+ .saturating_sub(unmasked_char_count),
+ );
format!("{masked_user_identifier}@{bank_or_psp}")
} else {
let masked_value = apply_mask(src.as_ref(), unmasked_char_count, 8);
@@ -285,12 +289,18 @@ impl From<String> for MaskedEmail {
fn from(src: String) -> Self {
let unmasked_char_count = 2;
let masked_value = if let Some((user_identifier, domain)) = src.split_once('@') {
+ // A local part shorter than the unmasked prefix (e.g. "[email protected]") has nothing
+ // left to mask, so the mask length saturates at zero instead of underflowing.
let masked_user_identifier = user_identifier
- .to_string()
.chars()
.take(unmasked_char_count)
.collect::<String>()
- + &"*".repeat(user_identifier.len() - unmasked_char_count);
+ + &"*".repeat(
+ user_identifier
+ .chars()
+ .count()
+ .saturating_sub(unmasked_char_count),
+ );
format!("{masked_user_identifier}@{domain}")
} else {
let masked_value = apply_mask(src.as_ref(), unmasked_char_count, 8);
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index 1c20be84fe..688a704920 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -97,6 +97,7 @@ pub struct PaymentIntent {
pub order_commodity_code: Option<String>,
pub settlement_conclusion_applied: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub merchant_reference_id: Option<common_utils::id_type::PaymentReferenceId>,
pub billing_address: Option<Encryption>,
pub shipping_address: Option<Encryption>,
@@ -228,6 +229,7 @@ pub struct PaymentIntent {
pub order_commodity_code: Option<String>,
pub settlement_conclusion_applied: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression, PartialEq)]
@@ -468,6 +470,7 @@ pub struct PaymentIntentNew {
pub enable_avs_check: Option<bool>,
pub value_added_tax_details: Option<ValueAddedTaxDetails>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub settlement_conclusion_applied: Option<bool>,
}
@@ -569,6 +572,7 @@ pub struct PaymentIntentNew {
pub recipient_details: Option<Encryption>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub settlement_conclusion_applied: Option<bool>,
}
@@ -774,6 +778,7 @@ pub struct PaymentIntentUpdateFields {
pub recipient_details: Option<Encryption>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub settlement_conclusion_applied: Option<bool>,
}
@@ -829,6 +834,7 @@ pub struct PaymentIntentUpdateInternal {
pub external_surcharge_applicable: Option<bool>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub settlement_conclusion_applied: Option<bool>,
}
@@ -900,6 +906,7 @@ pub struct PaymentIntentUpdateInternal {
pub recipient_details: Option<Encryption>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
+ pub sender_details: Option<Encryption>,
pub settlement_conclusion_applied: Option<bool>,
}
@@ -978,6 +985,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1046,6 +1054,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1112,6 +1121,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: value.external_surcharge_applicable,
is_account_funded_transaction: value.is_account_funded_transaction,
recipient_details: value.recipient_details,
+ sender_details: value.sender_details,
enable_avs_check: value.enable_avs_check,
enable_account_name_verification: value.enable_account_name_verification,
settlement_conclusion_applied: value.settlement_conclusion_applied,
@@ -1185,6 +1195,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1255,6 +1266,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1325,6 +1337,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1403,6 +1416,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1472,6 +1486,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1542,6 +1557,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1611,6 +1627,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1680,6 +1697,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1748,6 +1766,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1816,6 +1835,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_strategy: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1881,6 +1901,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1948,6 +1969,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -2015,6 +2037,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -2084,6 +2107,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -2154,6 +2178,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -2219,6 +2244,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index da22c1de5b..6aab3bb50b 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -1379,6 +1379,7 @@ diesel::table! {
order_commodity_code -> Nullable<Varchar>,
settlement_conclusion_applied -> Nullable<Bool>,
enable_account_name_verification -> Nullable<Bool>,
+ sender_details -> Nullable<Bytea>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index e6fe793734..a2513d2218 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -1294,6 +1294,7 @@ diesel::table! {
order_commodity_code -> Nullable<Varchar>,
settlement_conclusion_applied -> Nullable<Bool>,
enable_account_name_verification -> Nullable<Bool>,
+ sender_details -> Nullable<Bytea>,
#[max_length = 64]
merchant_reference_id -> Nullable<Varchar>,
billing_address -> Nullable<Bytea>,
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 6489763034..5be71bcb33 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -93,7 +93,7 @@ http = "1.3.1"
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", tag = "2026.11.17.1", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.18.1", package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
bytes = { version = "1.10.1", optional = true }
futures = { version = "0.3.31", optional = true }
diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
index f15aadbaa3..bf8f1f66b3 100644
--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
@@ -1,3 +1,4 @@
+use api_models::sender::SenderDetails;
use common_enums::{
enums::{self, AttemptStatus, PaymentChannel},
CountryAlpha2,
@@ -42,8 +43,9 @@ use crate::{
},
unimplemented_payment_method,
utils::{
- self, CardData, PaymentsAuthorizeRequestData, PaymentsCaptureRequestData,
- PaymentsSyncRequestData, RouterData as OtherRouterData, WalletData as OtherWalletData,
+ self, CardData, IndividualSenderDetailsData, PaymentsAuthorizeRequestData,
+ PaymentsCaptureRequestData, PaymentsSyncRequestData, RouterData as OtherRouterData,
+ SenderAddressDetailsData, SenderDetailsData, WalletData as OtherWalletData,
},
};
@@ -446,20 +448,19 @@ pub struct CheckoutBillingDescriptor {
}
#[derive(Debug, Serialize)]
-#[serde(rename_all = "lowercase")]
-pub enum CheckoutSenderType {
- Individual,
-}
-
-#[skip_serializing_none]
-#[derive(Debug, Serialize)]
-pub struct CheckoutSender {
- #[serde(rename = "type")]
- pub sender_type: CheckoutSenderType,
- pub first_name: Secret<String>,
- pub last_name: Secret<String>,
- pub address: CheckoutAddress,
- pub date_of_birth: Secret<time::Date>,
+#[serde(tag = "type", rename_all = "lowercase")]
+pub enum CheckoutSender {
+ Individual {
+ first_name: Secret<String>,
+ last_name: Secret<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ date_of_birth: Option<Secret<time::Date>>,
+ address: CheckoutAddress,
+ },
+ Corporate {
+ company_name: Secret<String>,
+ address: CheckoutAddress,
+ },
}
#[skip_serializing_none]
@@ -593,29 +594,59 @@ fn build_checkout_recipient(
})
}
+fn build_checkout_sender_address(
+ address: &api_models::payments::AddressDetails,
+) -> Result<CheckoutAddress, error_stack::Report<errors::ConnectorError>> {
+ let country = address.get_sender_country()?;
+
+ Ok(CheckoutAddress {
+ address_line1: Some(address.get_sender_line1()?),
+ address_line2: address.line2.clone(),
+ city: Some(address.get_sender_city()?),
+ state: get_checkout_aft_state(
+ address.state.clone(),
+ country,
+ "sender_details.address.state",
+ )?,
+ zip: Some(address.get_sender_zip()?),
+ country: Some(country),
+ })
+}
+
fn build_checkout_sender(
router_data: &PaymentsAuthorizeRouterData,
) -> Result<CheckoutSender, error_stack::Report<errors::ConnectorError>> {
- let country = router_data.get_billing_country()?;
-
- Ok(CheckoutSender {
- sender_type: CheckoutSenderType::Individual,
- first_name: router_data.get_billing_first_name()?,
- last_name: router_data.get_billing_last_name()?,
- date_of_birth: router_data.get_customer_date_of_birth()?,
- address: CheckoutAddress {
- address_line1: Some(router_data.get_billing_line1()?),
- address_line2: router_data.get_optional_billing_line2(),
- city: Some(router_data.get_billing_city()?),
- state: get_checkout_aft_state(
- router_data.get_optional_billing_state(),
- country,
- "payment_method_data.billing.address.state",
- )?,
- zip: Some(router_data.get_billing_zip()?),
- country: Some(country),
- },
- })
+ // The sender details are filled in from the billing address of the payment method in core,
+ // so any field missing here is missing from both.
+ let sender_details = router_data
+ .request
+ .sender_details
+ .as_ref()
+ .ok_or_else(utils::missing_field_err("sender_details"))?;
+
+ let address = build_checkout_sender_address(sender_details.get_sender_address()?)?;
+
+ match sender_details {
+ SenderDetails::Individual(individual) => Ok(CheckoutSender::Individual {
+ first_name: individual.get_sender_first_name()?,
+ last_name: individual.get_sender_last_name()?,
+ // For backward compatibility, fall back to the customer's date of birth, which was
+ // the only source of the sender's date of birth before sender details were added.
+ // The error names the sender field, since that is where the merchant should send it.
+ date_of_birth: Some(
+ individual
+ .date_of_birth
+ .clone()
+ .or_else(|| router_data.get_optional_customer_date_of_birth())
+ .ok_or_else(utils::missing_field_err("sender_details.date_of_birth"))?,
+ ),
+ address,
+ }),
+ SenderDetails::Corporate(corporate) => Ok(CheckoutSender::Corporate {
+ company_name: corporate.company_name.clone(),
+ address,
+ }),
+ }
}
#[skip_serializing_none]
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs
index efe4ffac63..eb0d39a532 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs
@@ -1,6 +1,6 @@
-use api_models::payments::PaymentConnectorInvokeDDCMetadata;
#[cfg(feature = "payouts")]
use api_models::payouts::{ApplePayDecrypt, CardPayout, GooglePayDecrypt};
+use api_models::{payments::PaymentConnectorInvokeDDCMetadata, sender::SenderDetails};
use base64::Engine;
use common_enums::enums;
use common_types::payments::GpayTokenizationData;
@@ -54,8 +54,9 @@ use crate::{
},
utils::{
self as connector_utils, AddressDetailsData, BrowserInformationData, CardData,
- ForeignTryFrom, PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
- PaymentsSyncRequestData, PhoneDetailsData, RouterData as _,
+ ForeignTryFrom, IndividualSenderDetailsData, PaymentsAuthorizeRequestData,
+ PaymentsCompleteAuthorizeRequestData, PaymentsSyncRequestData, PhoneDetailsData,
+ RouterData as _, SenderAddressDetailsData, SenderDetailsData,
},
};
@@ -676,6 +677,8 @@ struct AccountReference {
#[serde(rename_all = "camelCase")]
struct FullName {
first: Secret<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ middle: Option<Secret<String>>,
last: Secret<String>,
}
@@ -686,6 +689,8 @@ struct FundingAddress {
#[serde(skip_serializing_if = "Option::is_none")]
address2: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
+ address3: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
postal_code: Option<Secret<String>>,
city: String,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -1533,7 +1538,7 @@ fn get_address_details(data: &Address) -> Option<WorldpayxmlPayinAddress> {
last_name: address_data.get_optional_last_name(),
address1,
address2: address_data.get_optional_line2(),
- address3: address_data.get_optional_line2(),
+ address3: address_data.get_optional_line3(),
postal_code,
city,
state: address_data.get_optional_state(),
@@ -1546,12 +1551,27 @@ fn get_address_details(data: &Address) -> Option<WorldpayxmlPayinAddress> {
}
}
+/// In an account funded transaction, the sender's email takes precedence as the shopper's email.
+fn get_aft_sender_email(
+ is_account_funded_transaction: Option<bool>,
+ sender_details: Option<&SenderDetails>,
+) -> Option<pii::Email> {
+ is_account_funded_transaction
+ .unwrap_or(false)
+ .then(|| sender_details.and_then(|sender| sender.get_email().cloned()))
+ .flatten()
+}
+
fn get_shopper_details(
item: &PaymentsAuthorizeRouterData,
accept_header: Option<String>,
user_agent_header: Option<String>,
) -> Result<Option<WorldpayxmlShopper>, error_stack::Report<errors::ConnectorError>> {
- let shopper_email = item.request.email.clone();
+ let shopper_email = get_aft_sender_email(
+ item.request.is_account_funded_transaction,
+ item.request.sender_details.as_ref(),
+ )
+ .or_else(|| item.request.email.clone());
let browser_info = item
.request
.browser_info
@@ -1599,7 +1619,11 @@ fn get_shopper_details_cauth(
accept_header: Option<String>,
user_agent_header: Option<String>,
) -> Result<Option<WorldpayxmlShopper>, errors::ConnectorError> {
- let shopper_email = item.request.email.clone();
+ let shopper_email = get_aft_sender_email(
+ item.request.is_account_funded_transaction,
+ item.request.sender_details.as_ref(),
+ )
+ .or_else(|| item.request.email.clone());
let browser_info = item
.request
.browser_info
@@ -1731,6 +1755,7 @@ fn build_worldpayxml_recipient_party(
.ok_or_else(connector_utils::missing_field_err(
"recipient_details.address.first_name",
))?,
+ middle: None,
last: address
.last_name
.clone()
@@ -1746,6 +1771,7 @@ fn build_worldpayxml_recipient_party(
"recipient_details.address.line1",
))?,
address2: address.line2.clone(),
+ address3: address.line3.clone(),
postal_code: address.zip.clone(),
city: address
.city
@@ -1787,11 +1813,100 @@ fn build_worldpayxml_recipient_party(
})
}
+/// Worldpay has no company-name element, so a corporate sender's name is spread over the
+/// `fullName` parts: first word, middle words, last word. Worldpay requires both the first and
+/// the last name, so a company name of fewer than two words is rejected.
+fn get_worldpayxml_company_full_name(
+ company_name: &Secret<String>,
+) -> Result<FullName, error_stack::Report<errors::ConnectorError>> {
+ let words: Vec<&str> = company_name.peek().split_whitespace().collect();
+ match words.as_slice() {
+ [] => Err(connector_utils::missing_field_err(
+ "sender_details.company_name",
+ )()),
+ [_] => Err(errors::ConnectorError::InvalidDataFormat {
+ field_name: "sender_details.company_name".into(),
+ })
+ .attach_printable(
+ "WorldpayXML requires a first and a last name, so the company name must have at least two words",
+ ),
+ [first, middle @ .., last] => Ok(FullName {
+ first: Secret::new((*first).to_string()),
+ middle: (!middle.is_empty()).then(|| Secret::new(middle.join(" "))),
+ last: Secret::new((*last).to_string()),
+ }),
+ }
+}
+
+fn build_worldpayxml_sender_funding_address(
+ address: &api_models::payments::AddressDetails,
+) -> Result<FundingAddress, error_stack::Report<errors::ConnectorError>> {
+ let country_code = address.get_sender_country()?;
+
+ let state = match country_code {
+ common_enums::CountryAlpha2::US | common_enums::CountryAlpha2::CA => Some(
+ AddressDetails {
+ state: Some(address.get_sender_state()?),
+ country: Some(country_code),
+ ..Default::default()
+ }
+ .to_state_code()?,
+ ),
+ _ => address.state.clone(),
+ };
+
+ Ok(FundingAddress {
+ address1: address.get_sender_line1()?,
+ address2: address.line2.clone(),
+ address3: address.line3.clone(),
+ postal_code: address.zip.clone(),
+ city: address.get_sender_city()?,
+ state,
+ country_code,
+ })
+}
+
+/// Builds the sender `fundingParty` from `sender_details`, which core fills from the billing
+/// details of the payment method when the merchant does not send them.
fn build_worldpayxml_sender_party<F, Req, Res>(
router_data: &RouterData<F, Req, Res>,
+ sender_details: Option<&SenderDetails>,
card_number: Secret<String>,
) -> Result<FundingParty, error_stack::Report<errors::ConnectorError>> {
- let country_code = router_data.get_billing_country()?;
+ let sender_details =
+ sender_details.ok_or_else(connector_utils::missing_field_err("sender_details"))?;
+
+ let funding_address =
+ build_worldpayxml_sender_funding_address(sender_details.get_sender_address()?)?;
+ let telephone_number = sender_details.get_optional_sender_phone_number();
+
+ let (full_name, funding_data) = match sender_details {
+ SenderDetails::Individual(individual) => (
+ FullName {
+ first: individual.get_sender_first_name()?,
+ middle: None,
+ last: individual.get_sender_last_name()?,
+ },
+ Some(FundingData {
+ // For backward compatibility, fall back to the customer's date of birth, which was
+ // the only source of the sender's date of birth before sender details were added.
+ birth_date: individual
+ .date_of_birth
+ .clone()
+ .or_else(|| router_data.get_optional_customer_date_of_birth())
+ .map(BirthDate::from),
+ telephone_number: telephone_number
+ .or_else(|| router_data.get_optional_billing_phone_number()),
+ }),
+ ),
+ SenderDetails::Corporate(corporate) => (
+ get_worldpayxml_company_full_name(&corporate.company_name)?,
+ telephone_number.map(|telephone_number| FundingData {
+ birth_date: None,
+ telephone_number: Some(telephone_number),
+ }),
+ ),
+ };
Ok(FundingParty {
party_type: FundingPartyType::Sender,
@@ -1799,27 +1914,9 @@ fn build_worldpayxml_sender_party<F, Req, Res>(
account_type: "03".to_string(),
value: card_number,
},
- full_name: FullName {
- first: router_data.get_billing_first_name()?,
- last: router_data.get_billing_last_name()?,
- },
- funding_address: FundingAddress {
- address1: router_data.get_billing_line1()?,
- address2: router_data.get_optional_billing_line2(),
- postal_code: router_data.get_optional_billing_zip(),
- city: router_data.get_billing_city()?,
- state: match country_code {
- common_enums::CountryAlpha2::US | common_enums::CountryAlpha2::CA => {
- Some(router_data.get_billing_state_code()?)
- }
- _ => router_data.get_optional_billing_state_code(),
- },
- country_code,
- },
- funding_data: Some(FundingData {
- birth_date: Some(BirthDate::from(router_data.get_customer_date_of_birth()?)),
- telephone_number: router_data.get_optional_billing_phone_number(),
- }),
+ full_name,
+ funding_address,
+ funding_data,
tax_id: None,
})
}
@@ -1929,6 +2026,7 @@ fn get_worldpayxml_sender_account_number(
fn build_worldpayxml_funding_transfer<F, Req, Res>(
router_data: &RouterData<F, Req, Res>,
card_number: Secret<String>,
+ sender_details: Option<&SenderDetails>,
recipient_details: Option<&api_models::payments::RecipientDetails>,
business_country: Option<common_enums::CountryAlpha2>,
connector_intent_metadata: Option<&api_models::payments::ConnectorMetadata>,
@@ -1958,7 +2056,7 @@ fn build_worldpayxml_funding_transfer<F, Req, Res>(
category: worldpayxml_constants::WORLDPAYXML_FUNDING_CATEGORY.to_string(),
payment_purpose: payment_purpose.to_string(),
funding_party: vec![
- build_worldpayxml_sender_party(router_data, card_number)?,
+ build_worldpayxml_sender_party(router_data, sender_details, card_number)?,
build_worldpayxml_recipient_party(recipient_details, business_country)?,
],
})
@@ -2125,6 +2223,7 @@ impl TryFrom<&WorldpayxmlRouterData<&PaymentsAuthorizeRouterData>> for PaymentSe
build_worldpayxml_funding_transfer(
item.router_data,
card_number,
+ item.router_data.request.sender_details.as_ref(),
item.router_data.request.recipient_details.as_ref(),
item.router_data.request.business_country,
item.router_data.request.connector_intent_metadata.as_ref(),
@@ -3139,6 +3238,7 @@ impl TryFrom<WorldpayxmlRouterData<&PaymentsCompleteAuthorizeRouterData>> for Pa
build_worldpayxml_funding_transfer(
item.router_data,
card_number,
+ item.router_data.request.sender_details.as_ref(),
item.router_data.request.recipient_details.as_ref(),
item.router_data.request.business_country,
item.router_data.request.connector_intent_metadata.as_ref(),
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 83486f3665..0f145245cd 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -5,6 +5,7 @@ use api_models::payouts::PayoutVendorAccountDetails;
use api_models::{
payments,
payments::{additional_info::WalletAdditionalDataForCard, ApplepayPaymentMethod},
+ sender::{IndividualSenderDetails, SenderDetails},
};
use base64::Engine;
use cards::NetworkToken;
@@ -3386,6 +3387,80 @@ impl PaymentsAuthenticateRequestData for PaymentsAuthenticateData {
}
}
+pub trait SenderDetailsData {
+ fn get_sender_address(&self) -> Result<&payments::AddressDetails, Error>;
+ fn get_optional_sender_phone_number(&self) -> Option<Secret<String>>;
+}
+
+impl SenderDetailsData for SenderDetails {
+ fn get_sender_address(&self) -> Result<&payments::AddressDetails, Error> {
+ self.get_address()
+ .ok_or_else(missing_field_err("sender_details.address"))
+ }
+ fn get_optional_sender_phone_number(&self) -> Option<Secret<String>> {
+ let phone = match self {
+ Self::Individual(individual) => individual.phone.as_ref(),
+ Self::Corporate(corporate) => corporate.phone.as_ref(),
+ };
+ phone.and_then(|phone| phone.number.clone())
+ }
+}
+
+pub trait IndividualSenderDetailsData {
+ fn get_sender_first_name(&self) -> Result<Secret<String>, Error>;
+ fn get_sender_last_name(&self) -> Result<Secret<String>, Error>;
+}
+
+impl IndividualSenderDetailsData for IndividualSenderDetails {
+ fn get_sender_first_name(&self) -> Result<Secret<String>, Error> {
+ self.first_name
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.first_name"))
+ }
+ fn get_sender_last_name(&self) -> Result<Secret<String>, Error> {
+ self.last_name
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.last_name"))
+ }
+}
+
+/// Getters for the address of an account funded transaction sender, with errors naming the
+/// `sender_details.address` fields.
+pub trait SenderAddressDetailsData {
+ fn get_sender_country(&self) -> Result<enums::CountryAlpha2, Error>;
+ fn get_sender_line1(&self) -> Result<Secret<String>, Error>;
+ fn get_sender_city(&self) -> Result<String, Error>;
+ fn get_sender_zip(&self) -> Result<Secret<String>, Error>;
+ fn get_sender_state(&self) -> Result<Secret<String>, Error>;
+}
+
+impl SenderAddressDetailsData for payments::AddressDetails {
+ fn get_sender_country(&self) -> Result<enums::CountryAlpha2, Error> {
+ self.country
+ .ok_or_else(missing_field_err("sender_details.address.country"))
+ }
+ fn get_sender_line1(&self) -> Result<Secret<String>, Error> {
+ self.line1
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.address.line1"))
+ }
+ fn get_sender_city(&self) -> Result<String, Error> {
+ self.city
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.address.city"))
+ }
+ fn get_sender_zip(&self) -> Result<Secret<String>, Error> {
+ self.zip
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.address.zip"))
+ }
+ fn get_sender_state(&self) -> Result<Secret<String>, Error> {
+ self.state
+ .clone()
+ .ok_or_else(missing_field_err("sender_details.address.state"))
+ }
+}
+
pub trait BrowserInformationData {
fn get_accept_header(&self) -> Result<String, Error>;
fn get_language(&self) -> Result<String, Error>;
@@ -7764,6 +7839,7 @@ pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(
installment_details: None,
is_account_funded_transaction: data.request.is_account_funded_transaction,
recipient_details: data.request.recipient_details.clone(),
+ sender_details: data.request.sender_details.clone(),
business_country: data.request.business_country,
connector_intent_metadata: data.request.connector_intent_metadata.clone(),
enable_avs_check: data.request.enable_avs_check,
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 0014f4bfc1..863a0341f1 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -166,6 +166,8 @@ pub struct PaymentIntent {
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
pub settlement_conclusion_applied: Option<bool>,
+ #[encrypt(ty = Value)]
+ pub sender_details: Option<Encryptable<api_models::sender::SenderDetails>>,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -445,6 +447,12 @@ impl PaymentIntent {
.transpose()
}
+ pub fn get_sender_details(&self) -> Option<api_models::sender::SenderDetails> {
+ self.sender_details
+ .as_ref()
+ .map(|details| details.get_inner().clone())
+ }
+
#[cfg(feature = "v1")]
pub fn prevent_refund_after_post_capture_void(
&self,
@@ -1078,6 +1086,9 @@ pub struct PaymentIntent {
/// Denotes the category of the merchant initiated transactions made on this intent.
pub mit_category: Option<common_enums::MitCategory>,
pub settlement_conclusion_applied: Option<bool>,
+ /// The details of the party providing the funds in an account funded transaction.
+ #[encrypt(ty = Value)]
+ pub sender_details: Option<Encryptable<api_models::sender::SenderDetails>>,
}
#[cfg(feature = "v2")]
@@ -1290,6 +1301,14 @@ impl PaymentIntent {
external_surcharge_applicable: None,
is_account_funded_transaction: request.is_account_funded_transaction,
recipient_details: decrypted_payment_intent.recipient_details,
+ sender_details: decrypted_payment_intent
+ .sender_details
+ .map(|data| {
+ data.deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ })
+ .transpose()
+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to decode sender details")?,
enable_avs_check: request.enable_avs_check,
enable_account_name_verification: request.enable_account_name_verification,
mit_category: request.mit_category,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 7472a84174..80055ea3da 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -3,11 +3,12 @@ use common_types::primitive_wrappers;
#[cfg(feature = "v2")]
use common_utils::errors::ParsingError;
#[cfg(feature = "v2")]
-use common_utils::ext_traits::{Encode, ValueExt};
+use common_utils::ext_traits::Encode;
use common_utils::{
crypto::Encryptable,
encryption::Encryption,
errors::{CustomResult, ValidationError},
+ ext_traits::ValueExt,
id_type,
pii::{self, Email},
type_name,
@@ -279,6 +280,7 @@ pub struct PaymentIntentUpdateFields {
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
pub settlement_conclusion_applied: Option<bool>,
+ pub sender_details: Option<Encryptable<api_models::sender::SenderDetails>>,
}
#[cfg(feature = "v1")]
@@ -336,6 +338,7 @@ pub struct PaymentIntentUpdateFields {
pub external_surcharge_applicable: Option<bool>,
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub sender_details: Option<Encryptable<api_models::sender::SenderDetails>>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
pub settlement_conclusion_applied: Option<bool>,
@@ -578,6 +581,7 @@ pub struct PaymentIntentUpdateInternal {
pub external_surcharge_applicable: Option<bool>,
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub sender_details: Option<Encryptable<api_models::sender::SenderDetails>>,
pub enable_avs_check: Option<bool>,
pub enable_account_name_verification: Option<bool>,
pub settlement_conclusion_applied: Option<bool>,
@@ -641,6 +645,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::ConfirmIntentPostUpdate {
@@ -696,6 +701,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::SyncUpdate {
status,
@@ -749,6 +755,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::CaptureUpdate {
status,
@@ -802,6 +809,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::SessionIntentUpdate {
prerouting_algorithm,
@@ -858,6 +866,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::UpdateIntent(boxed_intent) => {
let PaymentIntentUpdateFields {
@@ -904,6 +913,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check,
enable_account_name_verification,
settlement_conclusion_applied,
+ sender_details,
} = *boxed_intent;
Ok(Self {
status: None,
@@ -959,6 +969,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check,
enable_account_name_verification,
settlement_conclusion_applied,
+ sender_details: sender_details.map(Encryption::from),
})
}
PaymentIntentUpdate::RecordUpdate {
@@ -1015,6 +1026,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::VoidUpdate { status, updated_by } => Ok(Self {
status: Some(status),
@@ -1065,6 +1077,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::AttemptGroupUpdate {
updated_by,
@@ -1118,6 +1131,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
PaymentIntentUpdate::SplitPaymentStatusUpdate { status, updated_by } => Ok(Self {
status: Some(status),
@@ -1167,6 +1181,7 @@ impl TryFrom<PaymentIntentUpdate> for diesel_models::PaymentIntentUpdateInternal
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
+ sender_details: None,
}),
}
}
@@ -1458,6 +1473,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1524,6 +1540,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
external_surcharge_applicable: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
enable_account_name_verification: None,
settlement_conclusion_applied: None,
@@ -1647,6 +1664,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
external_surcharge_applicable: None,
is_account_funded_transaction: value.is_account_funded_transaction,
recipient_details: value.recipient_details.map(Encryption::from),
+ sender_details: value.sender_details.map(Encryption::from),
enable_avs_check: value.enable_avs_check,
enable_account_name_verification: value.enable_account_name_verification,
settlement_conclusion_applied: value.settlement_conclusion_applied,
@@ -1849,6 +1867,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
external_surcharge_applicable,
is_account_funded_transaction,
recipient_details,
+ sender_details,
enable_avs_check,
enable_account_name_verification,
settlement_conclusion_applied,
@@ -1922,6 +1941,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
external_surcharge_applicable,
is_account_funded_transaction,
recipient_details: recipient_details.map(Encryption::from),
+ sender_details: sender_details.map(Encryption::from),
enable_avs_check,
enable_account_name_verification,
settlement_conclusion_applied,
@@ -2381,6 +2401,7 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable,
is_account_funded_transaction,
recipient_details,
+ sender_details,
enable_avs_check,
enable_account_name_verification,
mit_category,
@@ -2503,6 +2524,7 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable,
is_account_funded_transaction,
recipient_details: recipient_details.map(Encryption::from),
+ sender_details: sender_details.map(Encryption::from),
enable_avs_check,
enable_account_name_verification,
settlement_conclusion_applied,
@@ -2527,6 +2549,7 @@ impl behaviour::Conversion for PaymentIntent {
shipping_address: storage_model.shipping_address,
customer_details: storage_model.customer_details,
recipient_details: storage_model.recipient_details,
+ sender_details: storage_model.sender_details,
},
)),
key_manager_identifier,
@@ -2665,6 +2688,14 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable: storage_model.external_surcharge_applicable,
is_account_funded_transaction: storage_model.is_account_funded_transaction,
recipient_details: data.recipient_details,
+ sender_details: data
+ .sender_details
+ .map(|sender| {
+ sender.deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ })
+ .transpose()
+ .change_context(common_utils::errors::CryptoError::DecodingFailed)
+ .attach_printable("Error while deserializing SenderDetails")?,
enable_avs_check: storage_model.enable_avs_check,
enable_account_name_verification: storage_model.enable_account_name_verification,
mit_category: storage_model.mit_category,
@@ -2787,6 +2818,7 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable: self.external_surcharge_applicable,
is_account_funded_transaction: self.is_account_funded_transaction,
recipient_details: self.recipient_details.map(Encryption::from),
+ sender_details: self.sender_details.map(Encryption::from),
enable_avs_check: self.enable_avs_check,
enable_account_name_verification: self.enable_account_name_verification,
settlement_conclusion_applied: self.settlement_conclusion_applied,
@@ -2895,6 +2927,7 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable: self.external_surcharge_applicable,
is_account_funded_transaction: self.is_account_funded_transaction,
recipient_details: self.recipient_details.map(Encryption::from),
+ sender_details: self.sender_details.map(Encryption::from),
enable_avs_check: self.enable_avs_check,
enable_account_name_verification: self.enable_account_name_verification,
settlement_conclusion_applied: self.settlement_conclusion_applied,
@@ -2920,6 +2953,7 @@ impl behaviour::Conversion for PaymentIntent {
shipping_details: storage_model.shipping_details,
customer_details: storage_model.customer_details,
recipient_details: storage_model.recipient_details,
+ sender_details: storage_model.sender_details,
},
)),
key_manager_identifier,
@@ -3033,6 +3067,14 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable: storage_model.external_surcharge_applicable,
is_account_funded_transaction: storage_model.is_account_funded_transaction,
recipient_details: data.recipient_details,
+ sender_details: data
+ .sender_details
+ .map(|sender| {
+ sender.deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ })
+ .transpose()
+ .change_context(common_utils::errors::CryptoError::DecodingFailed)
+ .attach_printable("Error while deserializing SenderDetails")?,
enable_avs_check: storage_model.enable_avs_check,
enable_account_name_verification: storage_model.enable_account_name_verification,
settlement_conclusion_applied: storage_model.settlement_conclusion_applied,
@@ -3139,6 +3181,7 @@ impl behaviour::Conversion for PaymentIntent {
external_surcharge_applicable: self.external_surcharge_applicable,
is_account_funded_transaction: self.is_account_funded_transaction,
recipient_details: self.recipient_details.map(Encryption::from),
+ sender_details: self.sender_details.map(Encryption::from),
enable_avs_check: self.enable_avs_check,
enable_account_name_verification: self.enable_account_name_verification,
settlement_conclusion_applied: self.settlement_conclusion_applied,
diff --git a/crates/hyperswitch_domain_models/src/revenue_recovery.rs b/crates/hyperswitch_domain_models/src/revenue_recovery.rs
index 5f7f1c7ac4..2abf2b2794 100644
--- a/crates/hyperswitch_domain_models/src/revenue_recovery.rs
+++ b/crates/hyperswitch_domain_models/src/revenue_recovery.rs
@@ -203,6 +203,7 @@ impl From<&RevenueRecoveryInvoiceData> for api_payments::PaymentsCreateIntentReq
enable_partial_authorization: data.enable_partial_authorization,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
enable_avs_check: None,
mit_category: data.mit_category,
enable_account_name_verification: None,
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 954889569d..b104d9616c 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -190,6 +190,7 @@ pub struct PaymentsAuthorizeData {
/// Indicates whether this payment is an account funded transaction.
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<api_models::payments::RecipientDetails>,
+ pub sender_details: Option<api_models::sender::SenderDetails>,
/// The merchant's business country for this payment. Connectors use it for requirements that
/// apply only to merchants in particular countries.
pub business_country: Option<common_enums::CountryAlpha2>,
@@ -1075,6 +1076,7 @@ pub struct CompleteAuthorizeData {
pub merchant_order_reference_id: Option<String>,
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<api_models::payments::RecipientDetails>,
+ pub sender_details: Option<api_models::sender::SenderDetails>,
pub business_country: Option<common_enums::CountryAlpha2>,
pub connector_intent_metadata: Option<ConnectorMetadata>,
pub order_id: Option<String>,
@@ -1998,6 +2000,7 @@ pub struct SetupMandateRequestData {
pub mit_category: Option<common_enums::MitCategory>,
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<api_models::payments::RecipientDetails>,
+ pub sender_details: Option<api_models::sender::SenderDetails>,
/// The merchant's business country for this payment. Connectors use it for requirements that
/// apply only to merchants in particular countries.
pub business_country: Option<common_enums::CountryAlpha2>,
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 1620680f57..f139dc0851 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -37,7 +37,7 @@ time = "0.3.41"
tonic = "0.14"
url = { version = "2.5.4", features = ["serde"] }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.17.1", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.18.1", package = "rust-grpc-client" }
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
# First party crates
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 62a985c353..97b2094f4f 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -346,6 +346,10 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::MaskedRecipientDetails,
api_models::payments::MaskedRecipientAccount,
api_models::payments::MaskedRecipientBankAccount,
+ api_models::sender::SenderDetailsResponse,
+ api_models::sender::IndividualSenderDetailsResponse,
+ api_models::sender::CorporateSenderDetailsResponse,
+ api_models::sender::MaskedSenderPhoneDetails,
common_types::payments::PartnerMerchantIdentifierDetails,
common_types::payments::PartnerApplicationDetails,
common_types::payments::MerchantApplicationDetails,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 1f271409f0..6c8843b631 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -485,6 +485,10 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::MaskedRecipientDetails,
api_models::payments::MaskedRecipientAccount,
api_models::payments::MaskedRecipientBankAccount,
+ api_models::sender::SenderDetailsResponse,
+ api_models::sender::IndividualSenderDetailsResponse,
+ api_models::sender::CorporateSenderDetailsResponse,
+ api_models::sender::MaskedSenderPhoneDetails,
api_models::payments::EligibilityBalanceCheckResponseItem,
api_models::payments::PMBalanceCheckEligibilityResponse,
api_models::payments::PMBalanceCheckSuccessResponse,
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 7767162544..d287d5265a 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -259,8 +259,8 @@ rust_decimal = { version = "1.37.1", features = [
] }
rust-i18n = "3.1.5"
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.17.1", package = "rust-grpc-client" }
-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.11.17.1", package = "ucs_cards" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.18.1", package = "rust-grpc-client" }
+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.11.18.1", package = "ucs_cards" }
rustc-hash = "1.1.0"
rustls = { version = "0.23", default-features = false, features = [
"aws-lc-rs",
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index e487d0e74c..e8c8fc077d 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -10835,6 +10835,7 @@ pub struct PaymentDataUpdateRequestFields {
pub customer_document_details: Option<api_models::customers::CustomerDocumentDetails>,
pub is_account_funded_transaction: Option<bool>,
pub recipient_details: Option<api_models::payments::RecipientDetails>,
+ pub sender_details: Option<api_models::sender::SenderDetails>,
}
#[derive(Clone)]
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 6bb1992145..cfff669f6f 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -13,8 +13,9 @@ use api_models::{
mandates::RecurringDetails,
payments::{
additional_info::{self as payment_additional_types},
- InstallmentRequest, RequestSurchargeDetails,
+ AddressDetails, InstallmentRequest, RequestSurchargeDetails,
},
+ sender::{CorporateSenderDetails, IndividualSenderDetails, SenderDetails},
};
use base64::Engine;
use common_enums::{enums::ExecutionMode, ConnectorType, UcsAvailability, WalletDecryptedToken};
@@ -23,7 +24,7 @@ use common_types::payments::InstallmentOption;
use common_utils::id_type::GenerateId;
use common_utils::{
crypto::Encryptable,
- ext_traits::{AsyncExt, ByteSliceExt, Encode, ValueExt},
+ ext_traits::{AsyncExt, ByteSliceExt, ConfigExt, Encode, ValueExt},
fp_utils, generate_id,
id_type::{self},
new_type::{MaskedIban, MaskedSortCode},
@@ -8432,6 +8433,129 @@ pub fn validate_session_expiry(session_expiry: u32) -> Result<(), errors::ApiErr
}
}
+/// Validates that the names identifying an account funded transaction sender are not blank.
+pub fn validate_sender_details(
+ sender_details: Option<&SenderDetails>,
+) -> Result<(), errors::ApiErrorResponse> {
+ sender_details
+ .map(|sender_details| sender_details.get_name_fields())
+ .unwrap_or_default()
+ .into_iter()
+ .find(|(_, value)| value.is_empty_after_trim())
+ .map_or(Ok(()), |(field_name, _)| {
+ Err(errors::ApiErrorResponse::InvalidRequestData {
+ message: format!("{field_name} must not be empty"),
+ })
+ })
+}
+
+/// Fills in the sender of an account funded transaction from the billing address of the payment
+/// method.
+pub fn get_sender_details_with_billing_fallback(
+ sender_details: Option<SenderDetails>,
+ billing: Option<&hyperswitch_domain_models::address::Address>,
+) -> Option<SenderDetails> {
+ let billing_details = billing.and_then(|billing| billing.address.as_ref());
+ // Only the location is taken from billing; the sender's name is resolved separately below.
+ let billing_address = billing_details
+ .map(|details| AddressDetails {
+ line1: details.line1.clone(),
+ line2: details.line2.clone(),
+ line3: details.line3.clone(),
+ city: details.city.clone(),
+ state: details.state.clone(),
+ zip: details.zip.clone(),
+ country: details.country,
+ ..Default::default()
+ })
+ .filter(has_sender_address_location);
+ let billing_first_name = || billing_details.and_then(|details| details.first_name.clone());
+ let billing_last_name = || billing_details.and_then(|details| details.last_name.clone());
+ let resolve_address = |address: Option<AddressDetails>| {
+ address
+ .filter(has_sender_address_location)
+ .or_else(|| billing_address.clone())
+ };
+
+ let sender_details = match sender_details {
+ None => billing_details.map(|_| {
+ SenderDetails::Individual(IndividualSenderDetails {
+ first_name: billing_first_name(),
+ last_name: billing_last_name(),
+ date_of_birth: None,
+ address: billing_address.clone(),
+ phone: None,
+ email: None,
+ reference_id: None,
+ source_of_funds: None,
+ })
+ }),
+ Some(SenderDetails::Individual(individual)) => {
+ // The first and last name are taken together, from the sender when either is
+ // provided, otherwise from the billing name.
+ let is_sender_named = individual.first_name.is_some() || individual.last_name.is_some();
+ let (first_name, last_name) = if is_sender_named {
+ (individual.first_name, individual.last_name)
+ } else {
+ (billing_first_name(), billing_last_name())
+ };
+
+ // The billing address belongs to the cardholder, so it is not used for a sender
+ // named as someone else.
+ let is_billing_named_differently = is_sender_named
+ && (billing_first_name().is_some() || billing_last_name().is_some())
+ && !(is_same_name_part(first_name.as_ref(), billing_first_name().as_ref())
+ && is_same_name_part(last_name.as_ref(), billing_last_name().as_ref()));
+ let address = individual
+ .address
+ .filter(has_sender_address_location)
+ .or_else(|| {
+ billing_address
+ .clone()
+ .filter(|_| !is_billing_named_differently)
+ });
+
+ Some(SenderDetails::Individual(IndividualSenderDetails {
+ first_name,
+ last_name,
+ address,
+ ..individual
+ }))
+ }
+ Some(SenderDetails::Corporate(corporate)) => {
+ Some(SenderDetails::Corporate(CorporateSenderDetails {
+ address: resolve_address(corporate.address),
+ ..corporate
+ }))
+ }
+ };
+
+ // Names are compared with billing after trimming, so they are sent trimmed as well.
+ sender_details.map(SenderDetails::with_trimmed_names)
+}
+
+/// Whether a sender address carries any location field
+fn has_sender_address_location(address: &AddressDetails) -> bool {
+ address.line1.is_some()
+ || address.line2.is_some()
+ || address.line3.is_some()
+ || address.city.is_some()
+ || address.state.is_some()
+ || address.zip.is_some()
+ || address.country.is_some()
+}
+
+/// Compares a part of a name ignoring case and surrounding whitespace.
+fn is_same_name_part(
+ sender_name: Option<&hyperswitch_masking::Secret<String>>,
+ billing_name: Option<&hyperswitch_masking::Secret<String>>,
+) -> bool {
+ let normalize = |name: Option<&hyperswitch_masking::Secret<String>>| {
+ name.map(|name| name.peek().trim().to_lowercase())
+ };
+ normalize(sender_name) == normalize(billing_name)
+}
+
pub fn get_recipient_id_for_open_banking(
merchant_data: &AdditionalMerchantData,
) -> Result<Option<String>, errors::ApiErrorResponse> {
diff --git a/crates/router/src/core/payments/helpers/tests/client_secret_session.rs b/crates/router/src/core/payments/helpers/tests/client_secret_session.rs
index ebaa3d1a20..e2f334b520 100644
--- a/crates/router/src/core/payments/helpers/tests/client_secret_session.rs
+++ b/crates/router/src/core/payments/helpers/tests/client_secret_session.rs
@@ -87,6 +87,7 @@ fn test_authenticate_client_secret_session_not_expired() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
state_metadata: None,
installment_options: None,
@@ -189,6 +190,7 @@ fn test_authenticate_client_secret_session_expired() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
tokenization: None,
partner_merchant_identifier_details: None,
state_metadata: None,
@@ -291,6 +293,7 @@ fn test_authenticate_client_secret_expired() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
state_metadata: None,
installment_options: None,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index ab20d3d5e1..7b5660ec1b 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -3234,6 +3234,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
.payment_intent
.is_account_funded_transaction,
recipient_details: payment_data.payment_intent.recipient_details.clone(),
+ sender_details: payment_data.payment_intent.sender_details.clone(),
payment_channel: payment_data.payment_intent.payment_channel,
feature_metadata: payment_data.payment_intent.feature_metadata.clone(),
tax_status: payment_data.payment_intent.tax_status,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 59a0d1afd1..d2aef33769 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1248,6 +1248,7 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDat
processor: &'a domain::Processor,
) -> RouterResult<(PaymentCreateOperation<'b, F>, operations::ValidateResult)> {
helpers::validate_customer_information(request)?;
+ helpers::validate_sender_details(request.sender_details.as_ref())?;
if let Some(amount) = request.amount {
helpers::validate_max_amount(amount)?;
@@ -1930,6 +1931,14 @@ impl PaymentCreate {
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to encode recipient details to serde_json::Value")?;
+ let sender_details_encoded = request
+ .sender_details
+ .clone()
+ .map(|sender| Encode::encode_to_value(&sender).map(Secret::new))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encode sender details to serde_json::Value")?;
+
let encrypted_data = domain::types::crypto_operation(
&key_manager_state,
type_name!(storage::PaymentIntent),
@@ -1940,6 +1949,7 @@ impl PaymentCreate {
billing_details: billing_details_encoded,
customer_details: customer_details_encoded,
recipient_details: recipient_details_encoded,
+ sender_details: sender_details_encoded,
},
),
),
@@ -2064,6 +2074,14 @@ impl PaymentCreate {
billing_descriptor: request.billing_descriptor.clone(),
is_account_funded_transaction: request.is_account_funded_transaction,
recipient_details: encrypted_data.recipient_details,
+ sender_details: encrypted_data
+ .sender_details
+ .map(|sender| {
+ sender.deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ })
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to decode sender details")?,
tokenization: request.tokenization,
partner_merchant_identifier_details: request
.partner_merchant_identifier_details
diff --git a/crates/router/src/core/payments/operations/payment_create_intent.rs b/crates/router/src/core/payments/operations/payment_create_intent.rs
index 244df859a6..b4e3be3618 100644
--- a/crates/router/src/core/payments/operations/payment_create_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_create_intent.rs
@@ -130,6 +130,7 @@ impl<F: Send + Clone + Sync>
.attach_printable("Failed to encode customer details")?
.map(hyperswitch_masking::Secret::new),
recipient_details: request.recipient_details.clone().map(|recipient| recipient.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode recipient details")?.map(hyperswitch_masking::Secret::new),
+ sender_details: request.sender_details.clone().map(|sender| sender.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode sender details")?.map(hyperswitch_masking::Secret::new),
},
),
),
@@ -228,9 +229,11 @@ impl<F: Send + Clone>
#[instrument(skip_all)]
fn validate_request(
&self,
- _request: &PaymentsCreateIntentRequest,
+ request: &PaymentsCreateIntentRequest,
platform: &domain::Platform,
) -> RouterResult<operations::ValidateResult> {
+ helpers::validate_sender_details(request.sender_details.as_ref())?;
+
Ok(operations::ValidateResult {
merchant_id: platform.get_processor().get_account().get_id().to_owned(),
storage_scheme: platform.get_processor().get_account().storage_scheme,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index b305a32ce4..fc98002645 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -1015,6 +1015,7 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDat
processor: &'a domain::Processor,
) -> RouterResult<(PaymentUpdateOperation<'b, F>, operations::ValidateResult)> {
helpers::validate_customer_information(request)?;
+ helpers::validate_sender_details(request.sender_details.as_ref())?;
if let Some(amount) = request.amount {
helpers::validate_max_amount(amount)?;
@@ -1107,6 +1108,7 @@ impl PaymentUpdate {
.and_then(|customer| customer.document_details.clone()),
is_account_funded_transaction: request.is_account_funded_transaction,
recipient_details: request.recipient_details.clone(),
+ sender_details: request.sender_details.clone(),
}
}
@@ -1312,6 +1314,26 @@ impl PaymentUpdate {
None => payment_data.payment_intent.recipient_details.clone(),
};
+ // Re-encrypt the sender details only when the update request carries them; otherwise
+ // retain whatever is already stored on the intent.
+ let sender_details = match request.sender_details.as_ref() {
+ Some(sender_details) => Some(
+ core_utils::create_encrypted_data(
+ &key_manager_state,
+ key_store,
+ sender_details.clone(),
+ common_utils::type_name!(diesel_models::payment_intent::PaymentIntent),
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encrypt sender details")?
+ .deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to decode sender details")?,
+ ),
+ None => payment_data.payment_intent.sender_details.clone(),
+ };
+
let order_details = payment_data.payment_intent.order_details.clone();
let connector_metadata = payment_data.payment_intent.connector_metadata.clone();
let frm_metadata = payment_data.payment_intent.frm_metadata.clone();
@@ -1384,6 +1406,7 @@ impl PaymentUpdate {
.is_account_funded_transaction
.or(payment_data.payment_intent.is_account_funded_transaction),
recipient_details,
+ sender_details,
order_details,
metadata,
connector_metadata,
diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rs
index 7a25d37ce4..31b489e447 100644
--- a/crates/router/src/core/payments/operations/payment_update_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs
@@ -197,6 +197,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsUpda
enable_partial_authorization,
is_account_funded_transaction,
recipient_details,
+ sender_details,
enable_avs_check,
enable_account_name_verification,
} = request.clone();
@@ -211,6 +212,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsUpda
billing_address: billing.map(|address| address.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode billing address")?.map(hyperswitch_masking::Secret::new),
customer_details: None,
recipient_details: recipient_details.map(|recipient| recipient.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode recipient details")?.map(hyperswitch_masking::Secret::new),
+ sender_details: sender_details.map(|sender| sender.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode sender details")?.map(hyperswitch_masking::Secret::new),
},
),
),
@@ -314,6 +316,16 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsUpda
.recipient_details
.clone()
.or(payment_intent.recipient_details.clone()),
+ sender_details: decrypted_payment_intent
+ .sender_details
+ .clone()
+ .map(|sender| {
+ sender.deserialize_inner_value(|value| value.parse_value("SenderDetails"))
+ })
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to decode sender details")?
+ .or(payment_intent.sender_details.clone()),
enable_avs_check: enable_avs_check.or(payment_intent.enable_avs_check),
enable_account_name_verification: enable_account_name_verification
.or(payment_intent.enable_account_name_verification),
@@ -416,6 +428,7 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIn
enable_avs_check: intent.enable_avs_check,
settlement_conclusion_applied: intent.settlement_conclusion_applied,
enable_account_name_verification: intent.enable_account_name_verification,
+ sender_details: intent.sender_details,
}));
let new_payment_intent = db
@@ -442,9 +455,11 @@ impl<F: Send + Clone>
#[instrument(skip_all)]
fn validate_request(
&self,
- _request: &PaymentsUpdateIntentRequest,
+ request: &PaymentsUpdateIntentRequest,
platform: &domain::Platform,
) -> RouterResult<operations::ValidateResult> {
+ helpers::validate_sender_details(request.sender_details.as_ref())?;
+
Ok(operations::ValidateResult {
merchant_id: platform.get_processor().get_account().get_id().to_owned(),
storage_scheme: platform.get_processor().get_account().storage_scheme,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 1704ebe2f4..e145186b37 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -479,6 +479,12 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.payment_address.get_payment_method_billing(),
+ );
+
// TODO: few fields are repeated in both routerdata and request
let request = types::PaymentsAuthorizeData {
router_notification_url: connector_callback_urls.notification_url(
@@ -565,6 +571,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
connector_intent_metadata: None,
is_account_funded_transaction: payment_data.payment_intent.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: None,
enable_avs_check: payment_data.payment_intent.enable_avs_check,
enable_account_name_verification: payment_data
@@ -1907,6 +1914,12 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.payment_address.get_payment_method_billing(),
+ );
+
// TODO: few fields are repeated in both routerdata and request
let request = types::SetupMandateRequestData {
currency: payment_data.payment_intent.amount_details.currency,
@@ -1960,6 +1973,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
mit_category: None,
is_account_funded_transaction: payment_data.payment_intent.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: None,
enable_avs_check: payment_data.payment_intent.enable_avs_check,
enable_account_name_verification: payment_data
@@ -3195,6 +3209,9 @@ where
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?
.map(api_models::payments::MaskedRecipientDetails::from);
+ let masked_sender_details = payment_intent
+ .get_sender_details()
+ .map(api_models::sender::SenderDetailsResponse::from);
Ok(services::ApplicationResponse::JsonWithHeaders((
Self {
@@ -3254,6 +3271,7 @@ where
enable_partial_authorization: Some(payment_intent.enable_partial_authorization),
is_account_funded_transaction: payment_intent.is_account_funded_transaction,
recipient_details: masked_recipient_details,
+ sender_details: masked_sender_details,
enable_avs_check: payment_intent.enable_avs_check,
enable_account_name_verification: payment_intent.enable_account_name_verification,
},
@@ -4657,6 +4675,9 @@ where
.map(api_models::payments::MaskedRecipientDetails::from);
let setup_future_usage =
payment_attempt.get_setup_future_usage_with_fallback(&payment_intent);
+ let masked_sender_details = payment_intent
+ .get_sender_details()
+ .map(api_models::sender::SenderDetailsResponse::from);
let payments_response = api::PaymentsResponse {
// Populated only for server integrations, by the update-context enrichment.
payment_method_list: None,
@@ -4808,6 +4829,7 @@ where
billing_descriptor: payment_intent.billing_descriptor,
is_account_funded_transaction: payment_intent.is_account_funded_transaction,
recipient_details: masked_recipient_details,
+ sender_details: masked_sender_details,
partner_merchant_identifier_details: payment_intent.partner_merchant_identifier_details,
payment_method_tokenization_details,
installment_options: payment_intent.installment_options,
@@ -5166,6 +5188,9 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
.ok()
.flatten()
.map(api_models::payments::MaskedRecipientDetails::from);
+ let masked_sender_details = pi
+ .get_sender_details()
+ .map(api_models::sender::SenderDetailsResponse::from);
Self {
// Populated only for server integrations, by the update-context enrichment.
payment_method_list: None,
@@ -5323,6 +5348,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
billing_descriptor: pi.billing_descriptor,
is_account_funded_transaction: pi.is_account_funded_transaction,
recipient_details: masked_recipient_details,
+ sender_details: masked_sender_details,
partner_merchant_identifier_details: pi.partner_merchant_identifier_details,
payment_method_tokenization_details: None,
installment_options: pi.installment_options,
@@ -5650,6 +5676,12 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.address.get_payment_method_billing(),
+ );
+
let merchant_order_reference_id = payment_data
.payment_intent
.merchant_reference_id
@@ -5734,6 +5766,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.payment_intent
.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: None,
enable_avs_check: payment_data.payment_intent.enable_avs_check,
enable_account_name_verification: payment_data
@@ -5975,6 +6008,12 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.address.get_payment_method_billing(),
+ );
+
Ok(Self {
router_notification_url: additional_data.connector_callback_urls.notification_url(
api::ConnectorData::convert_connector(connector_name)?.get_notification_callback(),
@@ -6071,6 +6110,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.payment_intent
.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: payment_data.payment_intent.business_country,
enable_avs_check: payment_data.payment_intent.enable_avs_check,
enable_account_name_verification: payment_data
@@ -7714,6 +7754,12 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.address.get_payment_method_billing(),
+ );
+
let merchant_order_reference_id = payment_data
.payment_intent
.merchant_order_reference_id
@@ -7802,6 +7848,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
.payment_intent
.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: payment_data.payment_intent.business_country,
enable_avs_check: payment_data.payment_intent.enable_avs_check,
enable_account_name_verification: payment_data
@@ -7955,6 +8002,12 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse recipient details")?;
+ let intent_sender_details = payment_data.payment_intent.get_sender_details();
+ let sender_details = helpers::get_sender_details_with_billing_fallback(
+ intent_sender_details,
+ payment_data.address.get_payment_method_billing(),
+ );
+
let connector_intent_metadata = payment_data
.payment_intent
.get_connector_metadata_from_intent()
@@ -8051,6 +8104,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
.payment_intent
.is_account_funded_transaction,
recipient_details,
+ sender_details,
business_country: payment_data.payment_intent.business_country,
connector_intent_metadata,
order_id,
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index 5895903837..fbc0a99f03 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -1,16 +1,19 @@
use std::{collections::HashMap, str::FromStr};
-use api_models::payments::{
- additional_info::WalletAdditionalDataForCard, AdditionalCardInfo, AdditionalPaymentData,
- AmountInfo, ApplePayAddressParameters, ApplePayPaymentRequest, ApplePaySessionResponse,
- ApplepayPaymentMethod, ApplepaySessionTokenResponse, GooglePaySessionResponse,
- GooglePayTokenizationSpecificationType, GpayAllowedMethodsParameters,
- GpayAllowedPaymentMethods, GpayBillingAddressFormat, GpayBillingAddressParameters,
- GpayMerchantInfo, GpaySessionTokenResponse, GpayShippingAddressParameters, GpayTokenParameters,
- GpayTokenizationSpecification, GpayTransactionInfo, NextActionCall, PaypalFlow,
- PaypalSessionTokenResponse, PaypalTransactionInfo, RecipientAccount, RecipientBankAccount,
- RecipientDetails, SdkNextAction, SecretInfoToInitiateSdk, SessionToken,
- ThirdPartySdkSessionResponse,
+use api_models::{
+ payments::{
+ additional_info::WalletAdditionalDataForCard, AdditionalCardInfo, AdditionalPaymentData,
+ AmountInfo, ApplePayAddressParameters, ApplePayPaymentRequest, ApplePaySessionResponse,
+ ApplepayPaymentMethod, ApplepaySessionTokenResponse, GooglePaySessionResponse,
+ GooglePayTokenizationSpecificationType, GpayAllowedMethodsParameters,
+ GpayAllowedPaymentMethods, GpayBillingAddressFormat, GpayBillingAddressParameters,
+ GpayMerchantInfo, GpaySessionTokenResponse, GpayShippingAddressParameters,
+ GpayTokenParameters, GpayTokenizationSpecification, GpayTransactionInfo, NextActionCall,
+ PaypalFlow, PaypalSessionTokenResponse, PaypalTransactionInfo, RecipientAccount,
+ RecipientBankAccount, RecipientDetails, SdkNextAction, SecretInfoToInitiateSdk,
+ SessionToken, ThirdPartySdkSessionResponse,
+ },
+ sender::SenderDetails,
};
use common_enums::{AttemptStatus, AuthenticationType, AuthorizationStatus, RefundStatus};
use common_utils::{
@@ -61,8 +64,9 @@ use unified_connector_service_client::payments::{
self as payments_grpc,
additional_payment_data::PaymentMethodData as AdditionalPaymentMethodData,
client_authentication_token_data, recipient_account::AccountType as RecipientAccountType,
- recipient_bank_account::BankAccountType as RecipientBankAccountType, ConnectorState,
- EventServiceHandleRequest, EventServiceParseRequest,
+ recipient_bank_account::BankAccountType as RecipientBankAccountType,
+ sender_details::SenderType, ConnectorState, EventServiceHandleRequest,
+ EventServiceParseRequest,
};
use crate::{
@@ -698,6 +702,87 @@ impl transformers::ForeignTryFrom<&RecipientDetails> for payments_grpc::Recipien
}
}
+impl ForeignFrom<&api_models::payments::AddressDetails> for payments_grpc::SenderAddress {
+ fn foreign_from(address: &api_models::payments::AddressDetails) -> Self {
+ let country_alpha2_code = address
+ .country
+ .as_ref()
+ .and_then(|c| payments_grpc::CountryAlpha2::from_str_name(&c.to_string()))
+ .map(|c| c.into());
+
+ Self {
+ line1: address.line1.clone(),
+ line2: address.line2.clone(),
+ line3: address.line3.clone(),
+ city: address.city.clone().map(Secret::new),
+ state: address.state.clone(),
+ zip_code: address.zip.clone(),
+ country_alpha2_code,
+ }
+ }
+}
+
+impl transformers::ForeignTryFrom<&SenderDetails> for payments_grpc::SenderDetails {
+ type Error = error_stack::Report<UnifiedConnectorServiceError>;
+
+ fn foreign_try_from(details: &SenderDetails) -> Result<Self, Self::Error> {
+ let sender_type = match details {
+ SenderDetails::Individual(individual) => {
+ SenderType::Individual(payments_grpc::IndividualSenderDetails {
+ first_name: individual.first_name.clone(),
+ last_name: individual.last_name.clone(),
+ date_of_birth: individual
+ .date_of_birth
+ .as_ref()
+ .map(format_date_of_birth)
+ .transpose()?,
+ address: individual
+ .address
+ .as_ref()
+ .map(payments_grpc::SenderAddress::foreign_from),
+ email: individual
+ .email
+ .as_ref()
+ .map(|email| email.peek().to_string().into()),
+ phone_number: individual
+ .phone
+ .as_ref()
+ .and_then(|phone| phone.number.clone()),
+ phone_country_code: individual
+ .phone
+ .as_ref()
+ .and_then(|phone| phone.country_code.clone()),
+ })
+ }
+ SenderDetails::Corporate(corporate) => {
+ SenderType::Corporate(payments_grpc::CorporateSenderDetails {
+ company_name: Some(corporate.company_name.clone()),
+ address: corporate
+ .address
+ .as_ref()
+ .map(payments_grpc::SenderAddress::foreign_from),
+ email: corporate
+ .email
+ .as_ref()
+ .map(|email| email.peek().to_string().into()),
+ phone_number: corporate
+ .phone
+ .as_ref()
+ .and_then(|phone| phone.number.clone()),
+ phone_country_code: corporate
+ .phone
+ .as_ref()
+ .and_then(|phone| phone.country_code.clone()),
+ })
+ }
+ };
+
+ Ok(Self {
+ sender_type: Some(sender_type),
+ })
+ }
+}
+
impl transformers::ForeignTryFrom<&RecipientAccount> for payments_grpc::RecipientAccount {
type Error = error_stack::Report<UnifiedConnectorServiceError>;
@@ -1222,6 +1307,12 @@ impl
}),
currency_conversion_data,
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
@@ -1508,6 +1599,12 @@ impl
partner_merchant_identifier_details: None,
currency_conversion_data,
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
@@ -2927,6 +3024,12 @@ impl
partner_merchant_identifier_details: None,
currency_conversion_data,
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
@@ -3162,6 +3265,12 @@ impl
partner_merchant_identifier_details: None,
currency_conversion_data,
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
@@ -3246,6 +3355,7 @@ impl
Ok(Self {
risk_assessment_data: None,
is_account_funding_transaction: None,
+ sender_details: None,
recipient_details: None,
business_country: None,
split_settlement: None,
@@ -3630,6 +3740,12 @@ impl
}),
}),
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
@@ -3874,6 +3990,7 @@ impl
partner_merchant_identifier_details: None,
payment_channel: None,
is_account_funding_transaction: None,
+ sender_details: None,
recipient_details: None,
additional_connector_details: None,
session_token: None,
@@ -4235,6 +4352,12 @@ impl
.transpose()?
.map(|payment_channel| payment_channel.into()),
is_account_funding_transaction: router_data.request.is_account_funded_transaction,
+ sender_details: router_data
+ .request
+ .sender_details
+ .as_ref()
+ .map(payments_grpc::SenderDetails::foreign_try_from)
+ .transpose()?,
recipient_details: router_data
.request
.recipient_details
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index a5b648e3d6..099c3fe63a 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -2227,6 +2227,7 @@ mod tests {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rs
index 21de965d38..665fe26728 100644
--- a/crates/router/src/services/kafka/payment_intent.rs
+++ b/crates/router/src/services/kafka/payment_intent.rs
@@ -255,6 +255,7 @@ impl<'a> KafkaPaymentIntent<'a> {
external_surcharge_applicable: _,
is_account_funded_transaction: _,
recipient_details: _,
+ sender_details: _,
enable_avs_check: _,
enable_account_name_verification: _,
mit_category: _,
diff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rs
index c319269387..c51853515c 100644
--- a/crates/router/src/services/kafka/payment_intent_event.rs
+++ b/crates/router/src/services/kafka/payment_intent_event.rs
@@ -269,6 +269,7 @@ impl<'a> KafkaPaymentIntentEvent<'a> {
external_surcharge_applicable: _,
is_account_funded_transaction: _,
recipient_details: _,
+ sender_details: _,
enable_avs_check: _,
enable_account_name_verification: _,
mit_category: _,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index dfbb35c00e..a9a430d7cd 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -1452,6 +1452,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
billing_descriptor: data.request.billing_descriptor.clone(),
is_account_funded_transaction: data.request.is_account_funded_transaction,
recipient_details: data.request.recipient_details.clone(),
+ sender_details: data.request.sender_details.clone(),
business_country: data.request.business_country,
tokenization: None,
partner_merchant_identifier_details: data
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index f088ba332e..f406fb3a65 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -76,6 +76,7 @@ impl VerifyConnectorData {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
business_country: None,
tokenization: None,
partner_merchant_identifier_details: None,
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index 5953db61b2..c1598e384a 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -305,6 +305,7 @@ pub async fn generate_sample_data(
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
tokenization: None,
partner_merchant_identifier_details: None,
state_metadata: None,
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index e6745728cf..8c7e6ce454 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -1049,6 +1049,7 @@ impl Default for PaymentAuthorizeType {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
tokenization: None,
partner_merchant_identifier_details: None,
feature_metadata: None,
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 9af5eb6b4a..d54ba7adb4 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -486,6 +486,7 @@ async fn payments_create_core() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
@@ -803,6 +804,7 @@ async fn payments_create_core_adyen_no_redirect() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 378e26b996..4e19a15ff5 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -246,6 +246,7 @@ async fn payments_create_core() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
@@ -572,6 +573,7 @@ async fn payments_create_core_adyen_no_redirect() {
billing_descriptor: None,
is_account_funded_transaction: None,
recipient_details: None,
+ sender_details: None,
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
diff --git a/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/down.sql b/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/down.sql
new file mode 100644
index 0000000000..45576d1995
--- /dev/null
+++ b/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payment_intent DROP COLUMN IF EXISTS sender_details;
diff --git a/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/up.sql b/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/up.sql
new file mode 100644
index 0000000000..c8cf77671d
--- /dev/null
+++ b/migrations/2026-12-19-000000_add_sender_details_to_payment_intent/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS sender_details BYTEA;