Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): [worldpayvantiv] add support for moto flag for v1 and extend vantiv api contract (#8800)
AkshayaFoiger8ac5e50422d2
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 7591fb65fb..d75071dc77 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -20023,6 +20023,40 @@}}},+ "PaymentChannel": {+ "oneOf": [+ {+ "type": "string",+ "enum": [+ "ecommerce"+ ]+ },+ {+ "type": "string",+ "enum": [+ "mail_order"+ ]+ },+ {+ "type": "string",+ "enum": [+ "telephone_order"+ ]+ },+ {+ "type": "object",+ "required": [+ "other"+ ],+ "properties": {+ "other": {+ "type": "string"+ }+ }+ }+ ],+ "description": "Describes the channel through which the payment was initiated."+ },"PaymentChargeType": {"oneOf": [{@@ -22396,6 +22430,14 @@"type": "boolean","description": "If enabled, provides whole connector response","nullable": true+ },+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true}}},@@ -22819,6 +22861,14 @@"type": "boolean","description": "If enabled, provides whole connector response","nullable": true+ },+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true}}},@@ -23306,6 +23356,14 @@],"nullable": true},+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true+ },"payment_method_id": {"type": "string","description": "A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.",@@ -24120,6 +24178,14 @@"type": "boolean","description": "If enabled, provides whole connector response","nullable": true+ },+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true}},"additionalProperties": false@@ -24633,6 +24699,14 @@],"nullable": true},+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true+ },"payment_method_id": {"type": "string","description": "A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.",@@ -25290,6 +25364,14 @@"type": "boolean","description": "If enabled, provides whole connector response","nullable": true+ },+ "payment_channel": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentChannel"+ }+ ],+ "nullable": true}}},diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex a3e7cc9d51..0176553c5c 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -1186,6 +1186,10 @@ pub struct PaymentsRequest {#[serde(skip_deserializing)]#[remove_in(PaymentsUpdateRequest, PaymentsCreateRequest, PaymentsConfirmRequest)]pub is_payment_id_from_merchant: bool,++ /// Indicates how the payment was initiated (e.g., ecommerce, mail, or telephone).+ #[schema(value_type = Option<PaymentChannel>)]+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]@@ -5156,6 +5160,10 @@ pub struct PaymentsResponse {/// The browser information used for this paymentpub browser_info: Option<serde_json::Value>,+ /// Indicates how the payment was initiated (e.g., ecommerce, mail, or telephone).+ #[schema(value_type = Option<PaymentChannel>)]+ pub payment_channel: Option<common_enums::PaymentChannel>,+/// A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.pub payment_method_id: Option<String>,diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 6b35bbaf9c..33e0e5da86 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -2250,6 +2250,37 @@ pub enum ScaExemptionType {TransactionRiskAnalysis,}+#[derive(+ Clone,+ Debug,+ Default,+ Eq,+ PartialOrd,+ Ord,+ Hash,+ PartialEq,+ serde::Deserialize,+ serde::Serialize,+ strum::Display,+ strum::VariantNames,+ strum::EnumIter,+ strum::EnumString,+ ToSchema,+)]+#[router_derive::diesel_enum(storage_type = "text")]+#[serde(rename_all = "snake_case")]+#[strum(serialize_all = "snake_case")]+/// Describes the channel through which the payment was initiated.+pub enum PaymentChannel {+ #[default]+ Ecommerce,+ MailOrder,+ TelephoneOrder,+ #[serde(untagged)]+ #[strum(default)]+ Other(String),+}+#[derive(Clone,Copy,diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex 72ee13a95b..bd18e43e31 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -64,6 +64,7 @@ pub struct PaymentIntent {pub created_by: Option<String>,pub is_iframe_redirection_enabled: Option<bool>,pub is_payment_id_from_merchant: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,pub merchant_reference_id: Option<common_utils::id_type::PaymentReferenceId>,pub billing_address: Option<Encryption>,pub shipping_address: Option<Encryption>,@@ -157,6 +158,7 @@ pub struct PaymentIntent {pub is_iframe_redirection_enabled: Option<bool>,pub extended_return_url: Option<String>,pub is_payment_id_from_merchant: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression, PartialEq)]@@ -355,6 +357,7 @@ pub struct PaymentIntentNew {pub created_by: Option<String>,pub is_iframe_redirection_enabled: Option<bool>,pub is_payment_id_from_merchant: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[cfg(feature = "v1")]@@ -431,6 +434,7 @@ pub struct PaymentIntentNew {pub is_iframe_redirection_enabled: Option<bool>,pub extended_return_url: Option<String>,pub is_payment_id_from_merchant: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[cfg(feature = "v2")]@@ -556,6 +560,7 @@ pub struct PaymentIntentUpdateFields {pub is_payment_processor_token_flow: Option<bool>,pub force_3ds_challenge: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,+ pub payment_channel: Option<Option<common_enums::PaymentChannel>>,}#[cfg(feature = "v1")]@@ -590,6 +595,7 @@ pub struct PaymentIntentUpdateFields {pub tax_details: Option<TaxDetails>,pub force_3ds_challenge: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}// TODO: uncomment fields as necessary@@ -725,7 +731,6 @@ impl PaymentIntentUpdateInternal {force_3ds_challenge: force_3ds_challenge.or(source.force_3ds_challenge),is_iframe_redirection_enabled: is_iframe_redirection_enabled.or(source.is_iframe_redirection_enabled),-// Fields from sourcemerchant_id: source.merchant_id,customer_id: source.customer_id,@@ -749,6 +754,7 @@ impl PaymentIntentUpdateInternal {enable_payment_link: source.enable_payment_link,id: source.id,is_payment_id_from_merchant: source.is_payment_id_from_merchant,+ payment_channel: source.payment_channel,}}}@@ -797,6 +803,7 @@ pub struct PaymentIntentUpdateInternal {pub force_3ds_challenge: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,pub extended_return_url: Option<String>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[cfg(feature = "v1")]@@ -842,6 +849,7 @@ impl PaymentIntentUpdate {force_3ds_challenge,is_iframe_redirection_enabled,extended_return_url,+ payment_channel,} = self.into();PaymentIntent {amount: amount.unwrap_or(source.amount),@@ -891,6 +899,7 @@ impl PaymentIntentUpdate {is_iframe_redirection_enabled: is_iframe_redirection_enabled.or(source.is_iframe_redirection_enabled),extended_return_url: extended_return_url.or(source.extended_return_url),+ payment_channel: payment_channel.or(source.payment_channel),..source}}@@ -943,6 +952,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::Update(value) => Self {amount: Some(value.amount),@@ -985,6 +995,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: value.force_3ds_challenge,is_iframe_redirection_enabled: value.is_iframe_redirection_enabled,extended_return_url: value.return_url,+ payment_channel: value.payment_channel,},PaymentIntentUpdate::PaymentCreateUpdate {return_url,@@ -1034,6 +1045,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: return_url,+ payment_channel: None,},PaymentIntentUpdate::PGStatusUpdate {status,@@ -1079,6 +1091,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::MerchantStatusUpdate {status,@@ -1125,6 +1138,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::ResponseUpdate {// amount,@@ -1178,6 +1192,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {active_attempt_id,@@ -1223,6 +1238,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::StatusAndAttemptUpdate {status,@@ -1269,6 +1285,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::ApproveUpdate {status,@@ -1314,6 +1331,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::RejectUpdate {status,@@ -1359,6 +1377,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::SurchargeApplicableUpdate {surcharge_applicable,@@ -1403,6 +1422,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => Self {amount: Some(amount),@@ -1444,6 +1464,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::AuthorizationCountUpdate {authorization_count,@@ -1487,6 +1508,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::CompleteAuthorizeUpdate {shipping_address_id,@@ -1530,6 +1552,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::ManualUpdate { status, updated_by } => Self {status,@@ -1571,6 +1594,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},PaymentIntentUpdate::SessionResponseUpdate {tax_details,@@ -1617,6 +1641,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {force_3ds_challenge: None,is_iframe_redirection_enabled: None,extended_return_url: None,+ payment_channel: None,},}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex c141f76553..76ab261965 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1069,6 +1069,8 @@ diesel::table! {#[max_length = 2048]extended_return_url -> Nullable<Varchar>,is_payment_id_from_merchant -> Nullable<Bool>,+ #[max_length = 64]+ payment_channel -> Nullable<Varchar>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex e434e43b2c..3f862a8205 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1002,6 +1002,8 @@ diesel::table! {is_iframe_redirection_enabled -> Nullable<Bool>,is_payment_id_from_merchant -> Nullable<Bool>,#[max_length = 64]+ payment_channel -> Nullable<Varchar>,+ #[max_length = 64]merchant_reference_id -> Nullable<Varchar>,billing_address -> Nullable<Bytea>,shipping_address -> Nullable<Bytea>,diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rsindex 590734faf7..3fd7456e2c 100644--- a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs@@ -2,7 +2,10 @@ use common_utils::{ext_traits::Encode, types::MinorUnit};use error_stack::ResultExt;use hyperswitch_domain_models::{payment_method_data::PaymentMethodData,- router_data::{ConnectorAuthType, ErrorResponse, RouterData},+ router_data::{+ AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,+ ErrorResponse, RouterData,+ },router_flow_types::refunds::{Execute, RSync},router_request_types::{PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,@@ -157,7 +160,7 @@ pub struct Capture {#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]-pub struct BillToAddressData {+pub struct VantivAddressData {pub name: Option<Secret<String>>,pub address_line1: Option<Secret<String>>,pub address_line2: Option<Secret<String>>,@@ -190,7 +193,9 @@ pub struct Authorization {pub amount: MinorUnit,pub order_source: OrderSource,#[serde(skip_serializing_if = "Option::is_none")]- pub bill_to_address: Option<BillToAddressData>,+ pub bill_to_address: Option<VantivAddressData>,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub ship_to_address: Option<VantivAddressData>,#[serde(skip_serializing_if = "Option::is_none")]pub card: Option<WorldpayvantivCardData>,#[serde(skip_serializing_if = "Option::is_none")]@@ -214,7 +219,9 @@ pub struct Sale {pub amount: MinorUnit,pub order_source: OrderSource,#[serde(skip_serializing_if = "Option::is_none")]- pub bill_to_address: Option<BillToAddressData>,+ pub bill_to_address: Option<VantivAddressData>,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub ship_to_address: Option<VantivAddressData>,#[serde(skip_serializing_if = "Option::is_none")]pub card: Option<WorldpayvantivCardData>,#[serde(skip_serializing_if = "Option::is_none")]@@ -242,6 +249,8 @@ pub struct RefundRequest {#[serde(rename_all = "lowercase")]pub enum OrderSource {Ecommerce,+ MailOrder,+ Telephone,}#[derive(Debug, Clone, Serialize)]@@ -282,8 +291,10 @@ pub enum WorldpayvativCardType {Discover,#[serde(rename = "DC")]DinersClub,- #[serde(rename = "JCB")]+ #[serde(rename = "JC")]JCB,+ #[serde(rename = "")]+ UnionPay,}impl TryFrom<common_enums::CardNetwork> for WorldpayvativCardType {@@ -296,6 +307,7 @@ impl TryFrom<common_enums::CardNetwork> for WorldpayvativCardType {common_enums::CardNetwork::Discover => Ok(Self::Discover),common_enums::CardNetwork::DinersClub => Ok(Self::DinersClub),common_enums::CardNetwork::JCB => Ok(Self::JCB),+ common_enums::CardNetwork::UnionPay => Ok(Self::UnionPay),_ => Err(errors::ConnectorError::NotSupported {message: "Card network".to_string(),connector: "worldpayvantiv",@@ -422,13 +434,13 @@ impl<F> TryFrom<ResponseRouterData<F, VantivSyncResponse, PaymentsSyncData, Paym}}-fn get_bill_to_address(item: &PaymentsAuthorizeRouterData) -> Option<BillToAddressData> {+fn get_bill_to_address(item: &PaymentsAuthorizeRouterData) -> Option<VantivAddressData> {let billing_address = item.get_optional_billing();billing_address.and_then(|billing_address| {billing_address.address.clone()- .map(|address| BillToAddressData {+ .map(|address| VantivAddressData {name: address.get_optional_full_name(),address_line1: item.get_optional_billing_line1(),address_line2: item.get_optional_billing_line2(),@@ -443,6 +455,27 @@ fn get_bill_to_address(item: &PaymentsAuthorizeRouterData) -> Option<BillToAddre})}+fn get_ship_to_address(item: &PaymentsAuthorizeRouterData) -> Option<VantivAddressData> {+ let shipping_address = item.get_optional_shipping();+ shipping_address.and_then(|shipping_address| {+ shipping_address+ .address+ .clone()+ .map(|address| VantivAddressData {+ name: address.get_optional_full_name(),+ address_line1: item.get_optional_shipping_line1(),+ address_line2: item.get_optional_shipping_line2(),+ address_line3: item.get_optional_shipping_line3(),+ city: item.get_optional_shipping_city(),+ state: item.get_optional_shipping_state(),+ zip: item.get_optional_shipping_zip(),+ email: item.get_optional_shipping_email(),+ country: item.get_optional_shipping_country(),+ phone: item.get_optional_shipping_phone_number(),+ })+ })+}+impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnlineRequest {type Error = error_stack::Report<errors::ConnectorError>;fn try_from(@@ -456,7 +489,6 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl};let worldpayvantiv_metadata =WorldpayvantivMetadataObject::try_from(&item.router_data.connector_meta_data)?;-if worldpayvantiv_metadata.merchant_config_currency != item.router_data.request.currency {Err(errors::ConnectorError::CurrencyNotSupported {message: item.router_data.request.currency.to_string(),@@ -465,7 +497,6 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl};let card = get_vantiv_card_data(&item.router_data.request.payment_method_data.clone())?;-let report_group = item.router_data.request@@ -479,65 +510,71 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl.transpose()?.and_then(|worldpayvantiv_metadata| worldpayvantiv_metadata.report_group).unwrap_or(worldpayvantiv_metadata.report_group);-let worldpayvantiv_auth_type =WorldpayvantivAuthType::try_from(&item.router_data.connector_auth_type)?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,};-let customer_id = item.router_data.customer_id.clone().map(|customer_id| customer_id.get_string_repr().to_string());let bill_to_address = get_bill_to_address(item.router_data);+ let ship_to_address = get_ship_to_address(item.router_data);let processing_info = get_processing_info(&item.router_data.request)?;-- let (authorization, sale) = if item.router_data.request.is_auto_capture()? {- (- None,- Some(Sale {- id: format!(- "{}_{}",- OperationId::Sale,- item.router_data.connector_request_reference_id- ),- report_group: report_group.clone(),- customer_id,- order_id: item.router_data.connector_request_reference_id.clone(),- amount: item.amount,- order_source: OrderSource::Ecommerce,- bill_to_address,- card: card.clone(),- token: processing_info.token,- processing_type: processing_info.processing_type,- original_network_transaction_id: processing_info.network_transaction_id,- }),- )- } else {- (- Some(Authorization {- id: format!(- "{}_{}",- OperationId::Auth,- item.router_data.connector_request_reference_id- ),- report_group: report_group.clone(),- customer_id,- order_id: item.router_data.connector_request_reference_id.clone(),- amount: item.amount,- order_source: OrderSource::Ecommerce,- bill_to_address,- card: card.clone(),- token: processing_info.token,- processing_type: processing_info.processing_type,- original_network_transaction_id: processing_info.network_transaction_id,- }),- None,- )- };+ let order_source = OrderSource::from(&item.router_data.request.payment_channel);+ let (authorization, sale) =+ if item.router_data.request.is_auto_capture()? && item.amount != MinorUnit::zero() {+ (+ None,+ Some(Sale {+ id: format!(+ "{}_{}",+ OperationId::Sale,+ item.router_data.connector_request_reference_id+ ),+ report_group: report_group.clone(),+ customer_id,+ order_id: item.router_data.connector_request_reference_id.clone(),+ amount: item.amount,+ order_source,+ bill_to_address,+ ship_to_address,+ card: card.clone(),+ token: processing_info.token,+ processing_type: processing_info.processing_type,+ original_network_transaction_id: processing_info.network_transaction_id,+ }),+ )+ } else {+ let operation_id = if item.router_data.request.is_auto_capture()? {+ OperationId::Sale+ } else {+ OperationId::Auth+ };+ (+ Some(Authorization {+ id: format!(+ "{}_{}",+ operation_id, item.router_data.connector_request_reference_id+ ),+ report_group: report_group.clone(),+ customer_id,+ order_id: item.router_data.connector_request_reference_id.clone(),+ amount: item.amount,+ order_source,+ bill_to_address,+ ship_to_address,+ card: card.clone(),+ token: processing_info.token,+ processing_type: processing_info.processing_type,+ original_network_transaction_id: processing_info.network_transaction_id,+ }),+ None,+ )+ };Ok(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),@@ -553,6 +590,18 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl}}+impl From<&Option<common_enums::PaymentChannel>> for OrderSource {+ fn from(payment_channel: &Option<common_enums::PaymentChannel>) -> Self {+ match payment_channel {+ Some(common_enums::PaymentChannel::Ecommerce)+ | Some(common_enums::PaymentChannel::Other(_))+ | None => Self::Ecommerce,+ Some(common_enums::PaymentChannel::MailOrder) => Self::MailOrder,+ Some(common_enums::PaymentChannel::TelephoneOrder) => Self::Telephone,+ }+ }+}+fn get_processing_info(request: &PaymentsAuthorizeData,) -> Result<VantivMandateDetail, error_stack::Report<errors::ConnectorError>> {@@ -786,6 +835,17 @@ pub struct CaptureResponse {pub struct FraudResult {pub avs_result: Option<String>,pub card_validation_result: Option<String>,+ pub authentication_result: Option<String>,+ pub advanced_a_v_s_result: Option<String>,+ pub advanced_fraud_results: Option<AdvancedFraudResults>,+}++#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct AdvancedFraudResults {+ pub device_review_status: Option<String>,+ pub device_reputation_score: Option<String>,+ pub triggered_rule: Option<Vec<String>>,}#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]@@ -1113,8 +1173,8 @@ impl<F>};let connector_metadata = Some(report_group.encode_to_value().change_context(errors::ConnectorError::ResponseHandlingFailed)?);-let mandate_reference_data = sale_response.token_response.map(MandateReference::from);+ let connector_response = sale_response.fraud_result.as_ref().map(get_connector_response);Ok(Self {status,@@ -1128,12 +1188,19 @@ impl<F>incremental_authorization_allowed: None,charges: None,}),+ connector_response,..item.data})}},(None, Some(auth_response)) => {- let status = get_attempt_status(WorldpayvantivPaymentFlow::Auth, auth_response.response)?;+ let payment_flow_type = if item.data.request.is_auto_capture()? {+ WorldpayvantivPaymentFlow::Sale+ } else {+ WorldpayvantivPaymentFlow::Auth+ };++ let status = get_attempt_status(payment_flow_type, auth_response.response)?;if connector_utils::is_payment_failure(status) {Ok(Self {status,@@ -1156,8 +1223,8 @@ impl<F>};let connector_metadata = Some(report_group.encode_to_value().change_context(errors::ConnectorError::ResponseHandlingFailed)?);-let mandate_reference_data = auth_response.token_response.map(MandateReference::from);+ let connector_response = auth_response.fraud_result.as_ref().map(get_connector_response);Ok(Self {status,@@ -1171,6 +1238,7 @@ impl<F>incremental_authorization_allowed: None,charges: None,}),+ connector_response,..item.data})}@@ -2967,3 +3035,21 @@ fn get_vantiv_card_data(_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),}}++fn get_connector_response(payment_response: &FraudResult) -> ConnectorResponseData {+ let payment_checks = Some(serde_json::json!({+ "avs_result": payment_response.avs_result,+ "card_validation_result": payment_response.card_validation_result,+ "authentication_result": payment_response.authentication_result,+ "advanced_a_v_s_result": payment_response.advanced_a_v_s_result,+ }));++ ConnectorResponseData::with_additional_payment_method_data(+ AdditionalPaymentMethodConnectorResponse::Card {+ authentication_data: None,+ payment_checks,+ card_network: None,+ domestic_network: None,+ },+ )+}diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rsindex 3c581988c2..3194349883 100644--- a/crates/hyperswitch_connectors/src/utils.rs+++ b/crates/hyperswitch_connectors/src/utils.rs@@ -500,6 +500,7 @@ pub trait RouterData {fn get_optional_shipping(&self) -> Option<&Address>;fn get_optional_shipping_line1(&self) -> Option<Secret<String>>;fn get_optional_shipping_line2(&self) -> Option<Secret<String>>;+ fn get_optional_shipping_line3(&self) -> Option<Secret<String>>;fn get_optional_shipping_city(&self) -> Option<String>;fn get_optional_shipping_country(&self) -> Option<enums::CountryAlpha2>;fn get_optional_shipping_zip(&self) -> Option<Secret<String>>;@@ -601,6 +602,15 @@ impl<Flow, Request, Response> RouterData})}+ fn get_optional_shipping_line3(&self) -> Option<Secret<String>> {+ self.address.get_shipping().and_then(|shipping_address| {+ shipping_address+ .clone()+ .address+ .and_then(|shipping_details| shipping_details.line3)+ })+ }+fn get_optional_shipping_city(&self) -> Option<String> {self.address.get_shipping().and_then(|shipping_address| {shipping_address@@ -6224,6 +6234,7 @@ pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(connector_testing_data: data.request.connector_testing_data.clone(),order_id: None,locale: None,+ payment_channel: None,}}diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex e9b234eb46..62f4dbf8ac 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -116,6 +116,7 @@ pub struct PaymentIntent {pub force_3ds_challenge_trigger: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,pub is_payment_id_from_merchant: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}impl PaymentIntent {diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex 43e41f0095..04e3adf0bd 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -242,6 +242,7 @@ pub struct PaymentIntentUpdateFields {pub force_3ds_challenge: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,pub is_confirm_operation: bool,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[cfg(feature = "v1")]@@ -428,6 +429,7 @@ pub struct PaymentIntentUpdateInternal {pub tax_details: Option<diesel_models::TaxDetails>,pub force_3ds_challenge: Option<bool>,pub is_iframe_redirection_enabled: Option<bool>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}// This conversion is used in the `update_payment_intent` function@@ -1059,6 +1061,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {tax_details: value.tax_details,force_3ds_challenge: value.force_3ds_challenge,is_iframe_redirection_enabled: value.is_iframe_redirection_enabled,+ payment_channel: value.payment_channel,}))}PaymentIntentUpdate::PaymentCreateUpdate {@@ -1217,6 +1220,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInttax_details,force_3ds_challenge,is_iframe_redirection_enabled,+ payment_channel,} = value;Self {amount,@@ -1258,6 +1262,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateIntforce_3ds_challenge,is_iframe_redirection_enabled,extended_return_url: return_url,+ payment_channel,}}}@@ -1727,6 +1732,7 @@ impl behaviour::Conversion for PaymentIntent {created_by: created_by.map(|cb| cb.to_string()),is_iframe_redirection_enabled,is_payment_id_from_merchant,+ payment_channel: None,})}async fn convert_back(@@ -1957,6 +1963,7 @@ impl behaviour::Conversion for PaymentIntent {is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,routing_algorithm_id: self.routing_algorithm_id,is_payment_id_from_merchant: self.is_payment_id_from_merchant,+ payment_channel: None,})}}@@ -2032,6 +2039,7 @@ impl behaviour::Conversion for PaymentIntent {is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,extended_return_url: self.return_url,is_payment_id_from_merchant: self.is_payment_id_from_merchant,+ payment_channel: self.payment_channel,})}@@ -2133,6 +2141,7 @@ impl behaviour::Conversion for PaymentIntent {force_3ds_challenge_trigger: storage_model.force_3ds_challenge_trigger,is_iframe_redirection_enabled: storage_model.is_iframe_redirection_enabled,is_payment_id_from_merchant: storage_model.is_payment_id_from_merchant,+ payment_channel: storage_model.payment_channel,})}.await@@ -2206,6 +2215,7 @@ impl behaviour::Conversion for PaymentIntent {is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,extended_return_url: self.return_url,is_payment_id_from_merchant: self.is_payment_id_from_merchant,+ payment_channel: self.payment_channel,})}}diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 9aca1f867f..c33603ab27 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -81,6 +81,7 @@ pub struct PaymentsAuthorizeData {pub connector_testing_data: Option<pii::SecretSerdeValue>,pub order_id: Option<String>,pub locale: Option<String>,+ pub payment_channel: Option<common_enums::PaymentChannel>,}#[derive(Debug, Clone)]pub struct PaymentsPostSessionTokensData {diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex bb2937a653..58e178f5b9 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -257,6 +257,7 @@ Never share your secret api keys. Keep them guarded and secure.common_types::three_ds_decision_rule_engine::ThreeDSDecisionRule,common_types::three_ds_decision_rule_engine::ThreeDSDecision,common_types::payments::MerchantCountryCode,+ api_models::enums::PaymentChannel,api_models::three_ds_decision_rule::ThreeDsDecisionRuleExecuteRequest,api_models::three_ds_decision_rule::ThreeDsDecisionRuleExecuteResponse,api_models::three_ds_decision_rule::PaymentData,diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex ca8a970865..0e7ccdcac8 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -3868,6 +3868,7 @@ mod tests {force_3ds_challenge_trigger: None,is_iframe_redirection_enabled: None,is_payment_id_from_merchant: None,+ payment_channel: None,};let req_cs = Some("1".to_string());assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_ok());@@ -3945,6 +3946,7 @@ mod tests {force_3ds_challenge_trigger: None,is_iframe_redirection_enabled: None,is_payment_id_from_merchant: None,+ payment_channel: None,};let req_cs = Some("1".to_string());assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent,).is_err())@@ -4020,6 +4022,7 @@ mod tests {force_3ds_challenge_trigger: None,is_iframe_redirection_enabled: None,is_payment_id_from_merchant: None,+ payment_channel: None,};let req_cs = Some("1".to_string());assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_err())diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex a6d1047e6d..10c93a064b 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -2054,6 +2054,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for.payment_intent.is_iframe_redirection_enabled,is_confirm_operation: true, // Indicates that this is a confirm operation+ payment_channel: payment_data.payment_intent.payment_channel,})),&m_key_store,storage_scheme,diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 5dfdb5427e..7d1d32135a 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -1621,6 +1621,7 @@ impl PaymentCreate {.is_iframe_redirection_enabled.or(business_profile.is_iframe_redirection_enabled),is_payment_id_from_merchant: Some(is_payment_id_from_merchant),+ payment_channel: request.payment_channel.clone(),})}diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 0b77e5c31c..a0dae81a5f 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -451,6 +451,11 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.force_3ds_challenge.or(payment_intent.force_3ds_challenge);+ payment_intent.payment_channel = request+ .payment_channel+ .clone()+ .or(payment_intent.payment_channel);+let payment_data = PaymentData {flow: PhantomData,payment_intent,@@ -943,6 +948,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for.payment_intent.is_iframe_redirection_enabled,is_confirm_operation: false, // this is not a confirm operation+ payment_channel: payment_data.payment_intent.payment_channel,})),key_store,storage_scheme,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 0cb84fc75c..dd9b41ee9d 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -327,6 +327,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(connector_testing_data: None,order_id: None,locale: None,+ payment_channel: None,};let connector_mandate_request_reference_id = payment_data.payment_attempt@@ -2983,6 +2984,7 @@ whereissuer_error_message: payment_attempt.issuer_error_message,is_iframe_redirection_enabled: payment_intent.is_iframe_redirection_enabled,whole_connector_response: payment_data.get_whole_connector_response(),+ payment_channel: payment_intent.payment_channel,};services::ApplicationResponse::JsonWithHeaders((payments_response, headers))@@ -3276,7 +3278,8 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paywhole_connector_response: None,issuer_error_code: pa.issuer_error_code,issuer_error_message: pa.issuer_error_message,- is_iframe_redirection_enabled:pi.is_iframe_redirection_enabled+ is_iframe_redirection_enabled:pi.is_iframe_redirection_enabled,+ payment_channel: pi.payment_channel,}}}@@ -3606,6 +3609,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizconnector_testing_data: None,order_id: None,locale: None,+ payment_channel: None,})}}@@ -3838,6 +3842,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizconnector_testing_data,order_id: None,locale: Some(additional_data.state.locale.clone()),+ payment_channel: payment_data.payment_intent.payment_channel,})}}diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex 4887a80f31..3a51c628b8 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -1099,6 +1099,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {connector_testing_data: data.request.connector_testing_data.clone(),order_id: None,locale: None,+ payment_channel: None,}}}diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rsindex ba0413440a..046635a1e6 100644--- a/crates/router/src/types/api/verify_connector.rs+++ b/crates/router/src/types/api/verify_connector.rs@@ -66,6 +66,7 @@ impl VerifyConnectorData {connector_testing_data: None,order_id: None,locale: None,+ payment_channel: None,}}diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex b04f340056..93398290d3 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -290,6 +290,7 @@ pub async fn generate_sample_data(force_3ds_challenge_trigger: None,is_iframe_redirection_enabled: None,is_payment_id_from_merchant: None,+ payment_channel: None,};let (connector_transaction_id, processor_transaction_data) =ConnectorTransactionId::form_id_and_data(attempt_id.clone());diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex 2603ace85d..5d6dce2c58 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -998,6 +998,7 @@ impl Default for PaymentAuthorizeType {connector_testing_data: None,order_id: None,locale: None,+ payment_channel: None,};Self(data)}diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 1879af550f..32299c100b 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -465,6 +465,7 @@ async fn payments_create_core() {issuer_error_message: None,is_iframe_redirection_enabled: None,whole_connector_response: None,+ payment_channel: None,};let expected_response =services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));@@ -743,6 +744,7 @@ async fn payments_create_core_adyen_no_redirect() {issuer_error_message: None,is_iframe_redirection_enabled: None,whole_connector_response: None,+ payment_channel: None,},vec![],));diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex e7aaa09f5b..92e1ca505a 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -227,6 +227,7 @@ async fn payments_create_core() {issuer_error_message: None,is_iframe_redirection_enabled: None,whole_connector_response: None,+ payment_channel: None,};let expected_response =@@ -513,6 +514,7 @@ async fn payments_create_core_adyen_no_redirect() {issuer_error_message: None,is_iframe_redirection_enabled: None,whole_connector_response: None,+ payment_channel: None,},vec![],));diff --git a/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/down.sql b/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/down.sqlnew file mode 100644index 0000000000..9f1581372d--- /dev/null+++ b/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/down.sql@@ -0,0 +1,2 @@+-- This file should undo anything in `up.sql`+ALTER TABLE payment_intent DROP COLUMN payment_channel;diff --git a/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/up.sql b/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/up.sqlnew file mode 100644index 0000000000..c4a09f195a--- /dev/null+++ b/migrations/2025-07-28-762893_add_payment_channel_to_payment_intent/up.sql@@ -0,0 +1 @@+ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS payment_channel VARCHAR(64) DEFAULT NULL;\ No newline at end of file