diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 6eab5ed2655c..d9c27a2f0187 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2972,8 +2972,8 @@ "required": [ "order_amount", "currency", - "skip_external_tax_calculation", - "skip_surcharge_calculation" + "external_tax_calculation", + "surcharge_calculation" ], "properties": { "order_amount": { @@ -3002,10 +3002,10 @@ ], "nullable": true }, - "skip_external_tax_calculation": { + "external_tax_calculation": { "$ref": "#/components/schemas/TaxCalculationOverride" }, - "skip_surcharge_calculation": { + "surcharge_calculation": { "$ref": "#/components/schemas/SurchargeCalculationOverride" }, "surcharge_amount": { @@ -6125,8 +6125,8 @@ "type": "object", "required": [ "currency", - "skip_external_tax_calculation", - "skip_surcharge_calculation", + "external_tax_calculation", + "surcharge_calculation", "net_amount", "amount_capturable" ], @@ -6157,10 +6157,10 @@ ], "nullable": true }, - "skip_external_tax_calculation": { + "external_tax_calculation": { "$ref": "#/components/schemas/TaxCalculationOverride" }, - "skip_surcharge_calculation": { + "surcharge_calculation": { "$ref": "#/components/schemas/SurchargeCalculationOverride" }, "surcharge_amount": { @@ -14971,6 +14971,7 @@ "status", "amount_details", "client_secret", + "profile_id", "capture_method", "authentication_type", "customer_present", @@ -14997,6 +14998,10 @@ "description": "It's a token used for client side verification.", "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo" }, + "profile_id": { + "type": "string", + "description": "The identifier for the profile. This is inferred from the `x-profile-id` header" + }, "merchant_reference_id": { "type": "string", "description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.", @@ -15816,6 +15821,22 @@ } ], "nullable": true + }, + "shipping": { + "allOf": [ + { + "$ref": "#/components/schemas/Address" + } + ], + "nullable": true + }, + "billing": { + "allOf": [ + { + "$ref": "#/components/schemas/Address" + } + ], + "nullable": true } } }, @@ -19661,8 +19682,8 @@ "SurchargeCalculationOverride": { "type": "string", "enum": [ - "Skip", - "Calculate" + "skip", + "calculate" ] }, "SurchargeDetailsResponse": { @@ -19763,8 +19784,8 @@ "TaxCalculationOverride": { "type": "string", "enum": [ - "Skip", - "Calculate" + "skip", + "calculate" ] }, "ThirdPartySdkSessionResponse": { diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index f46fd450bd43..603c0f769347 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -316,6 +316,10 @@ pub struct PaymentsIntentResponse { #[schema(value_type = String, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")] pub client_secret: common_utils::types::ClientSecret, + /// The identifier for the profile. This is inferred from the `x-profile-id` header + #[schema(value_type = String)] + pub profile_id: id_type::ProfileId, + /// Unique identifier for the payment. This ensures idempotency for multiple payments /// that have been done by a single merchant. #[schema( @@ -476,10 +480,10 @@ pub struct AmountDetailsResponse { pub order_tax_amount: Option, /// The action to whether calculate tax by calling external tax provider or not #[schema(value_type = TaxCalculationOverride)] - pub skip_external_tax_calculation: common_enums::TaxCalculationOverride, + pub external_tax_calculation: common_enums::TaxCalculationOverride, /// The action to whether calculate surcharge or not #[schema(value_type = SurchargeCalculationOverride)] - pub skip_surcharge_calculation: common_enums::SurchargeCalculationOverride, + pub surcharge_calculation: common_enums::SurchargeCalculationOverride, /// The surcharge amount to be added to the order, collected from the merchant pub surcharge_amount: Option, /// tax on surcharge amount @@ -502,10 +506,10 @@ pub struct ConfirmIntentAmountDetailsResponse { pub order_tax_amount: Option, /// The action to whether calculate tax by calling external tax provider or not #[schema(value_type = TaxCalculationOverride)] - pub skip_external_tax_calculation: common_enums::TaxCalculationOverride, + pub external_tax_calculation: common_enums::TaxCalculationOverride, /// The action to whether calculate surcharge or not #[schema(value_type = SurchargeCalculationOverride)] - pub skip_surcharge_calculation: common_enums::SurchargeCalculationOverride, + pub surcharge_calculation: common_enums::SurchargeCalculationOverride, /// The surcharge amount to be added to the order, collected from the merchant pub surcharge_amount: Option, /// tax on surcharge amount @@ -4729,6 +4733,12 @@ pub struct PaymentsRetrieveResponse { /// Error details for the payment if any pub error: Option, + + /// The shipping address associated with the payment intent + pub shipping: Option
, + + /// The billing address associated with the payment intent + pub billing: Option
, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 781b5e3710a7..0268b7800c1f 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3328,6 +3328,7 @@ pub enum PresenceOfCustomerDuringPayment { } #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema)] +#[serde(rename_all = "snake_case")] pub enum TaxCalculationOverride { /// Skip calling the external tax provider #[default] @@ -3337,6 +3338,7 @@ pub enum TaxCalculationOverride { } #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema)] +#[serde(rename_all = "snake_case")] pub enum SurchargeCalculationOverride { /// Skip calculating surcharge #[default] diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs b/crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs index d5a7f981a1b1..433308059ae9 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments::AddressDetails; use common_enums::enums; use common_utils::{pii::Email, request::Method}; use error_stack::ResultExt; @@ -182,7 +181,9 @@ impl TryFrom<&DlocalRouterData<&types::PaymentsAuthorizeRouterData>> for DlocalP } } -fn get_payer_name(address: &AddressDetails) -> Option> { +fn get_payer_name( + address: &hyperswitch_domain_models::address::AddressDetails, +) -> Option> { let first_name = address .first_name .clone() diff --git a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs index cef3d684e7b0..bbfa0598cfa1 100644 --- a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs @@ -354,7 +354,7 @@ fn get_billing_details( } fn get_address_details( - address: Option<&api_models::payments::AddressDetails>, + address: Option<&hyperswitch_domain_models::address::AddressDetails>, ) -> Result, Error> { let address_details = match address { Some(address) => { diff --git a/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs b/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs index 540bcaebaaeb..1973e622be1b 100644 --- a/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs @@ -1,4 +1,4 @@ -use api_models::{payments::AddressDetails, webhooks::IncomingWebhookEvent}; +use api_models::webhooks::IncomingWebhookEvent; use cards::CardNumber; use common_enums::enums; use common_utils::{ @@ -555,7 +555,9 @@ where } } -fn get_address_details(address_details: Option<&AddressDetails>) -> Option
{ +fn get_address_details( + address_details: Option<&hyperswitch_domain_models::address::AddressDetails>, +) -> Option
{ address_details.map(|address| Address { line1: address.line1.clone(), line2: address.line1.clone(), diff --git a/crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs index 89ee8d1b29b6..e3ebcf490de1 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments; use common_enums::enums::{AttemptStatus, BankNames, CaptureMethod, CountryAlpha2, Currency}; use common_utils::{pii::Email, request::Method}; use hyperswitch_domain_models::{ @@ -418,15 +417,18 @@ fn make_bank_redirect_request( } fn get_address( - billing: &payments::Address, -) -> Option<(&payments::Address, &payments::AddressDetails)> { + billing: &hyperswitch_domain_models::address::Address, +) -> Option<( + &hyperswitch_domain_models::address::Address, + &hyperswitch_domain_models::address::AddressDetails, +)> { let address = billing.address.as_ref()?; address.country.as_ref()?; Some((billing, address)) } fn build_customer_info( - billing_address: &payments::Address, + billing_address: &hyperswitch_domain_models::address::Address, email: &Option, ) -> Result> { let (billing, address) = @@ -454,8 +456,8 @@ fn build_customer_info( }) } -impl From for BillingAddress { - fn from(value: payments::AddressDetails) -> Self { +impl From for BillingAddress { + fn from(value: hyperswitch_domain_models::address::AddressDetails) -> Self { Self { city: value.city, country_code: value.country, @@ -466,8 +468,8 @@ impl From for BillingAddress { } } -impl From for Shipping { - fn from(value: payments::AddressDetails) -> Self { +impl From for Shipping { + fn from(value: hyperswitch_domain_models::address::AddressDetails) -> Self { Self { city: value.city, country_code: value.country, diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs index 8ecc3ad792ce..781d364a5977 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use api_models::payments::{Address, MandateIds, MandateReferenceId}; +use api_models::payments::{MandateIds, MandateReferenceId}; use base64::Engine; use common_enums::enums; use common_utils::{ @@ -8,6 +8,7 @@ use common_utils::{ }; use error_stack::ResultExt; use hyperswitch_domain_models::{ + address, payment_method_data::{PaymentMethodData, WalletData}, router_data::{ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{Authorize, SetupMandate}, @@ -70,7 +71,7 @@ impl TryFrom> for WorldpayConnectorMetadataObject fn fetch_payment_instrument( payment_method: PaymentMethodData, - billing_address: Option<&Address>, + billing_address: Option<&address::Address>, mandate_ids: Option, ) -> CustomResult { match payment_method { @@ -232,7 +233,7 @@ trait WorldpayPaymentsRequestData { fn get_off_session(&self) -> Option; fn get_mandate_id(&self) -> Option; fn get_currency(&self) -> enums::Currency; - fn get_optional_billing_address(&self) -> Option<&Address>; + fn get_optional_billing_address(&self) -> Option<&address::Address>; fn get_connector_meta_data(&self) -> Option<&pii::SecretSerdeValue>; fn get_payment_method(&self) -> enums::PaymentMethod; fn get_payment_method_type(&self) -> Option; @@ -278,7 +279,7 @@ impl WorldpayPaymentsRequestData self.request.currency } - fn get_optional_billing_address(&self) -> Option<&Address> { + fn get_optional_billing_address(&self) -> Option<&address::Address> { self.get_optional_billing() } @@ -338,7 +339,7 @@ impl WorldpayPaymentsRequestData self.request.currency } - fn get_optional_billing_address(&self) -> Option<&Address> { + fn get_optional_billing_address(&self) -> Option<&address::Address> { self.get_optional_billing() } diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs index 181f46a20523..cef71610cb4b 100644 --- a/crates/hyperswitch_connectors/src/utils.rs +++ b/crates/hyperswitch_connectors/src/utils.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; -use api_models::payments::{self, Address, AddressDetails, PhoneDetails}; +use api_models::payments; use base64::Engine; use common_enums::{ enums, @@ -16,6 +16,7 @@ use common_utils::{ }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ + address::{Address, AddressDetails, PhoneDetails}, payment_method_data::{Card, PaymentMethodData}, router_data::{ ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData, diff --git a/crates/hyperswitch_domain_models/src/address.rs b/crates/hyperswitch_domain_models/src/address.rs index 85595c1ad9e3..c9beb359c433 100644 --- a/crates/hyperswitch_domain_models/src/address.rs +++ b/crates/hyperswitch_domain_models/src/address.rs @@ -11,15 +11,22 @@ impl masking::SerializableSecret for Address {} impl Address { /// Unify the address, giving priority to `self` when details are present in both - pub fn unify_address(self, other: Option<&Self>) -> Self { + pub fn unify_address(&self, other: Option<&Self>) -> Self { let other_address_details = other.and_then(|address| address.address.as_ref()); Self { address: self .address + .as_ref() .map(|address| address.unify_address_details(other_address_details)) .or(other_address_details.cloned()), - email: self.email.or(other.and_then(|other| other.email.clone())), - phone: self.phone.or(other.and_then(|other| other.phone.clone())), + email: self + .email + .clone() + .or(other.and_then(|other| other.email.clone())), + phone: self + .phone + .clone() + .or(other.and_then(|other| other.phone.clone())), } } } @@ -51,14 +58,14 @@ impl AddressDetails { } /// Unify the address details, giving priority to `self` when details are present in both - pub fn unify_address_details(self, other: Option<&Self>) -> Self { + pub fn unify_address_details(&self, other: Option<&Self>) -> Self { if let Some(other) = other { let (first_name, last_name) = if self .first_name .as_ref() .is_some_and(|first_name| !first_name.peek().trim().is_empty()) { - (self.first_name, self.last_name) + (self.first_name.clone(), self.last_name.clone()) } else { (other.first_name.clone(), other.last_name.clone()) }; @@ -66,16 +73,16 @@ impl AddressDetails { Self { first_name, last_name, - city: self.city.or(other.city.clone()), + city: self.city.clone().or(other.city.clone()), country: self.country.or(other.country), - line1: self.line1.or(other.line1.clone()), - line2: self.line2.or(other.line2.clone()), - line3: self.line3.or(other.line3.clone()), - zip: self.zip.or(other.zip.clone()), - state: self.state.or(other.state.clone()), + line1: self.line1.clone().or(other.line1.clone()), + line2: self.line2.clone().or(other.line2.clone()), + line3: self.line3.clone().or(other.line3.clone()), + zip: self.zip.clone().or(other.zip.clone()), + state: self.state.clone().or(other.state.clone()), } } else { - self + self.clone() } } } diff --git a/crates/hyperswitch_domain_models/src/payment_address.rs b/crates/hyperswitch_domain_models/src/payment_address.rs index 548dd0c54166..176bef0c88bb 100644 --- a/crates/hyperswitch_domain_models/src/payment_address.rs +++ b/crates/hyperswitch_domain_models/src/payment_address.rs @@ -1,4 +1,4 @@ -use api_models::payments::Address; +use crate::address::Address; #[derive(Clone, Default, Debug)] pub struct PaymentAddress { diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs index 006d78e2f7ab..207668817e36 100644 --- a/crates/hyperswitch_domain_models/src/payments.rs +++ b/crates/hyperswitch_domain_models/src/payments.rs @@ -34,8 +34,8 @@ use self::payment_attempt::PaymentAttempt; use crate::RemoteStorageObject; #[cfg(feature = "v2")] use crate::{ - address::Address, business_profile, errors, merchant_account, payment_method_data, - ApiModelToDieselModelConvertor, + address::Address, business_profile, errors, merchant_account, payment_address, + payment_method_data, ApiModelToDieselModelConvertor, }; #[cfg(feature = "v1")] @@ -582,6 +582,7 @@ where pub payment_intent: PaymentIntent, pub payment_attempt: PaymentAttempt, pub payment_method_data: Option, + pub payment_address: payment_address::PaymentAddress, } #[cfg(feature = "v2")] @@ -593,6 +594,7 @@ where pub flow: PhantomData, pub payment_intent: PaymentIntent, pub payment_attempt: Option, + pub payment_address: payment_address::PaymentAddress, /// Should the payment status be synced with connector /// This will depend on the payment status and the force sync flag in the request pub should_sync_with_connector: bool, diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs index 289b1bab37df..591ccc4ff981 100644 --- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs +++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs @@ -381,6 +381,17 @@ impl PaymentAttempt { let now = common_utils::date_time::now(); + let payment_method_billing_address = encrypted_data + .payment_method_billing_address + .as_ref() + .map(|data| { + data.clone() + .deserialize_inner_value(|value| value.parse_value("Address")) + }) + .transpose() + .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError) + .attach_printable("Unable to decode billing address")?; + Ok(Self { payment_id: payment_intent.id.clone(), merchant_id: payment_intent.merchant_id.clone(), @@ -423,8 +434,7 @@ impl PaymentAttempt { payment_method_subtype: request.payment_method_subtype, authentication_applied: None, external_reference_id: None, - // TODO: encrypt and store this - payment_method_billing_address: None, + payment_method_billing_address, error: None, connector_mandate_detail: None, id, diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index c282afa9d0d6..b14e27e8453f 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -1,6 +1,6 @@ pub mod authentication; pub mod fraud_check; -use api_models::payments::{AdditionalPaymentData, Address, RequestSurchargeDetails}; +use api_models::payments::{AdditionalPaymentData, RequestSurchargeDetails}; use common_utils::{ consts, errors, ext_traits::OptionExt, @@ -15,6 +15,7 @@ use serde_with::serde_as; use super::payment_method_data::PaymentMethodData; use crate::{ + address, errors::api_error_response::ApiErrorResponse, mandates, payments, router_data::{self, RouterData}, @@ -836,7 +837,7 @@ pub struct PaymentsTaxCalculationData { pub currency: storage_enums::Currency, pub shipping_cost: Option, pub order_details: Option>, - pub shipping_address: Address, + pub shipping_address: address::Address, } #[derive(Debug, Clone, Default)] diff --git a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs index ab36deb425f5..067c6042ec20 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs @@ -4,7 +4,7 @@ use error_stack::{Report, ResultExt}; use serde::{Deserialize, Serialize}; use crate::{ - errors::api_error_response::ApiErrorResponse, payment_method_data::PaymentMethodData, + address, errors::api_error_response::ApiErrorResponse, payment_method_data::PaymentMethodData, router_request_types::BrowserInformation, }; @@ -77,8 +77,8 @@ pub struct PreAuthNRequestData { #[derive(Clone, Debug)] pub struct ConnectorAuthenticationRequestData { pub payment_method_data: PaymentMethodData, - pub billing_address: api_models::payments::Address, - pub shipping_address: Option, + pub billing_address: address::Address, + pub shipping_address: Option, pub browser_details: Option, pub amount: Option, pub currency: Option, diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 55516eeb3bcf..545c058ce1cd 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -321,9 +321,10 @@ impl TryFrom for payments::PaymentsRequest { let billing = pmd.billing_details.clone().map(payments::Address::from); let payment_method_data = match pmd.payment_method_details.as_ref() { Some(spmd) => Some(payments::PaymentMethodData::from(spmd.to_owned())), - None => { - get_pmd_based_on_payment_method_type(item.payment_method_types, billing.clone()) - } + None => get_pmd_based_on_payment_method_type( + item.payment_method_types, + billing.clone().map(From::from), + ), }; payments::PaymentMethodDataRequest { @@ -911,7 +912,7 @@ pub struct StripePaymentRetrieveBody { //To handle payment types that have empty payment method data fn get_pmd_based_on_payment_method_type( payment_method_type: Option, - billing_details: Option, + billing_details: Option, ) -> Option { match payment_method_type { Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi( diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index cae5f508a2ed..5309f5fa76c8 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -1755,7 +1755,7 @@ fn get_amount_data(item: &AdyenRouterData<&types::PaymentsAuthorizeRouterData>) } pub fn get_address_info( - address: Option<&payments::Address>, + address: Option<&hyperswitch_domain_models::address::Address>, ) -> Option>> { address.and_then(|add| { add.address.as_ref().map( @@ -1817,7 +1817,9 @@ fn get_telephone_number(item: &types::PaymentsAuthorizeRouterData) -> Option) -> Option { +fn get_shopper_name( + address: Option<&hyperswitch_domain_models::address::Address>, +) -> Option { let billing = address.and_then(|billing| billing.address.as_ref()); Some(ShopperName { first_name: billing.and_then(|a| a.first_name.clone()), @@ -1825,7 +1827,9 @@ fn get_shopper_name(address: Option<&payments::Address>) -> Option }) } -fn get_country_code(address: Option<&payments::Address>) -> Option { +fn get_country_code( + address: Option<&hyperswitch_domain_models::address::Address>, +) -> Option { address.and_then(|billing| billing.address.as_ref().and_then(|address| address.country)) } @@ -4863,7 +4867,7 @@ impl TryFrom<&AdyenRouterData<&types::PayoutsRouterData>> for AdyenPayoutC })?, }; let bank_data = PayoutBankData { bank: bank_details }; - let address: &payments::AddressDetails = item.router_data.get_billing_address()?; + let address = item.router_data.get_billing_address()?; Ok(Self { amount: Amount { value: item.amount.to_owned(), @@ -4905,7 +4909,7 @@ impl TryFrom<&AdyenRouterData<&types::PayoutsRouterData>> for AdyenPayoutC })? } }; - let address: &payments::AddressDetails = item.router_data.get_billing_address()?; + let address = item.router_data.get_billing_address()?; let payout_wallet = PayoutWalletData { selected_brand: PayoutBrand::Paypal, additional_data, diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index 1530cbd82f83..71cc006700e4 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments; use base64::Engine; use common_utils::pii; use masking::{ExposeInterface, PeekInterface, Secret}; @@ -494,7 +493,7 @@ impl // } fn build_bill_to( - address_details: Option<&payments::Address>, + address_details: Option<&hyperswitch_domain_models::address::Address>, email: pii::Email, ) -> Result> { let default_address = BillTo { diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs index 022512ea1c19..d3fc0779e255 100644 --- a/crates/router/src/connector/bluesnap/transformers.rs +++ b/crates/router/src/connector/bluesnap/transformers.rs @@ -1125,7 +1125,7 @@ pub enum BluesnapErrors { } fn get_card_holder_info( - address: &api::AddressDetails, + address: &hyperswitch_domain_models::address::AddressDetails, email: Email, ) -> CustomResult, errors::ConnectorError> { let first_name = address.get_first_name()?; diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 2ea36e3e35e5..af0c02ef2c85 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -1,9 +1,6 @@ use api_models::payments; #[cfg(feature = "payouts")] -use api_models::{ - payments::{AddressDetails, PhoneDetails}, - payouts::PayoutMethodData, -}; +use api_models::payouts::PayoutMethodData; use base64::Engine; use common_enums::FutureUsage; use common_utils::{ @@ -12,6 +9,8 @@ use common_utils::{ types::SemanticVersion, }; use error_stack::ResultExt; +#[cfg(feature = "payouts")] +use hyperswitch_domain_models::address::{AddressDetails, PhoneDetails}; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -1102,7 +1101,7 @@ impl // } fn build_bill_to( - address_details: Option<&payments::Address>, + address_details: Option<&hyperswitch_domain_models::address::Address>, email: pii::Email, ) -> Result> { let default_address = BillTo { diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rs index c5c34574433d..579bd77d4d63 100644 --- a/crates/router/src/connector/gocardless/transformers.rs +++ b/crates/router/src/connector/gocardless/transformers.rs @@ -1,7 +1,4 @@ -use api_models::{ - enums::{CountryAlpha2, UsStatesAbbreviation}, - payments::AddressDetails, -}; +use api_models::enums::{CountryAlpha2, UsStatesAbbreviation}; use common_utils::{ id_type, pii::{self, IpAddress}, @@ -105,7 +102,7 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequest } fn get_region( - address_details: &AddressDetails, + address_details: &hyperswitch_domain_models::address::AddressDetails, ) -> Result>, error_stack::Report> { match address_details.country { Some(CountryAlpha2::US) => { diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rs index 62a5cef0bcae..803dc4a428d2 100644 --- a/crates/router/src/connector/klarna/transformers.rs +++ b/crates/router/src/connector/klarna/transformers.rs @@ -218,7 +218,7 @@ impl TryFrom<&KlarnaRouterData<&types::PaymentsAuthorizeRouterData>> for KlarnaP } fn get_address_info( - address: Option<&payments::Address>, + address: Option<&hyperswitch_domain_models::address::Address>, ) -> Option>> { address.and_then(|add| { add.address.as_ref().map( diff --git a/crates/router/src/connector/netcetera/netcetera_types.rs b/crates/router/src/connector/netcetera/netcetera_types.rs index 68a01b26fba8..ac6aad8c1366 100644 --- a/crates/router/src/connector/netcetera/netcetera_types.rs +++ b/crates/router/src/connector/netcetera/netcetera_types.rs @@ -208,7 +208,7 @@ pub struct ThreeDSRequestorAuthenticationInformation { /// card to a wallet. /// /// This field is optional. The accepted values are: -/// +/// /// - 01 -> No preference /// - 02 -> No challenge requested /// - 03 -> Challenge requested: 3DS Requestor Preference @@ -686,15 +686,15 @@ pub struct Cardholder { impl TryFrom<( - api_models::payments::Address, - Option, + hyperswitch_domain_models::address::Address, + Option, )> for Cardholder { type Error = error_stack::Report; fn try_from( (billing_address, shipping_address): ( - api_models::payments::Address, - Option, + hyperswitch_domain_models::address::Address, + Option, ), ) -> Result { Ok(Self { @@ -801,9 +801,11 @@ pub struct PhoneNumber { subscriber: Option>, } -impl TryFrom for PhoneNumber { +impl TryFrom for PhoneNumber { type Error = error_stack::Report; - fn try_from(value: api_models::payments::PhoneDetails) -> Result { + fn try_from( + value: hyperswitch_domain_models::address::PhoneDetails, + ) -> Result { Ok(Self { country_code: Some(value.extract_country_code()?), subscriber: value.number, diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index c350f151d721..11e01b78e134 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -653,7 +653,9 @@ impl TryFrom<&types::SetupMandateRouterData> for PaypalZeroMandateRequest { } } -fn get_address_info(payment_address: Option<&api_models::payments::Address>) -> Option
{ +fn get_address_info( + payment_address: Option<&hyperswitch_domain_models::address::Address>, +) -> Option
{ let address = payment_address.and_then(|payment_address| payment_address.address.as_ref()); match address { Some(address) => address.get_optional_country().map(|country| Address { diff --git a/crates/router/src/connector/riskified/transformers/api.rs b/crates/router/src/connector/riskified/transformers/api.rs index 2d519b3caa8d..e8c1b8744179 100644 --- a/crates/router/src/connector/riskified/transformers/api.rs +++ b/crates/router/src/connector/riskified/transformers/api.rs @@ -620,9 +620,11 @@ pub struct ErrorData { pub message: String, } -impl TryFrom<&api_models::payments::Address> for OrderAddress { +impl TryFrom<&hyperswitch_domain_models::address::Address> for OrderAddress { type Error = Error; - fn try_from(address_info: &api_models::payments::Address) -> Result { + fn try_from( + address_info: &hyperswitch_domain_models::address::Address, + ) -> Result { let address = address_info .clone() diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index b5901f56d3b6..c3d6806ff0ea 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -79,14 +79,21 @@ impl AccessTokenRequestInfo for types::RefreshTokenRouterData { } pub trait RouterData { - fn get_billing(&self) -> Result<&api::Address, Error>; + fn get_billing(&self) -> Result<&hyperswitch_domain_models::address::Address, Error>; fn get_billing_country(&self) -> Result; - fn get_billing_phone(&self) -> Result<&api::PhoneDetails, Error>; + fn get_billing_phone(&self) + -> Result<&hyperswitch_domain_models::address::PhoneDetails, Error>; fn get_description(&self) -> Result; fn get_return_url(&self) -> Result; - fn get_billing_address(&self) -> Result<&api::AddressDetails, Error>; - fn get_shipping_address(&self) -> Result<&api::AddressDetails, Error>; - fn get_shipping_address_with_phone_number(&self) -> Result<&api::Address, Error>; + fn get_billing_address( + &self, + ) -> Result<&hyperswitch_domain_models::address::AddressDetails, Error>; + fn get_shipping_address( + &self, + ) -> Result<&hyperswitch_domain_models::address::AddressDetails, Error>; + fn get_shipping_address_with_phone_number( + &self, + ) -> Result<&hyperswitch_domain_models::address::Address, Error>; fn get_connector_meta(&self) -> Result; fn get_session_token(&self) -> Result; fn get_billing_first_name(&self) -> Result, Error>; @@ -112,8 +119,8 @@ pub trait RouterData { #[cfg(feature = "payouts")] fn get_quote_id(&self) -> Result; - fn get_optional_billing(&self) -> Option<&api::Address>; - fn get_optional_shipping(&self) -> Option<&api::Address>; + fn get_optional_billing(&self) -> Option<&hyperswitch_domain_models::address::Address>; + fn get_optional_shipping(&self) -> Option<&hyperswitch_domain_models::address::Address>; fn get_optional_shipping_line1(&self) -> Option>; fn get_optional_shipping_line2(&self) -> Option>; fn get_optional_shipping_city(&self) -> Option; @@ -191,7 +198,7 @@ pub fn get_unimplemented_payment_method_error_message(connector: &str) -> String } impl RouterData for types::RouterData { - fn get_billing(&self) -> Result<&api::Address, Error> { + fn get_billing(&self) -> Result<&hyperswitch_domain_models::address::Address, Error> { self.address .get_payment_method_billing() .ok_or_else(missing_field_err("billing")) @@ -207,18 +214,20 @@ impl RouterData for types::RouterData Result<&api::PhoneDetails, Error> { + fn get_billing_phone( + &self, + ) -> Result<&hyperswitch_domain_models::address::PhoneDetails, Error> { self.address .get_payment_method_billing() .and_then(|a| a.phone.as_ref()) .ok_or_else(missing_field_err("billing.phone")) } - fn get_optional_billing(&self) -> Option<&api::Address> { + fn get_optional_billing(&self) -> Option<&hyperswitch_domain_models::address::Address> { self.address.get_payment_method_billing() } - fn get_optional_shipping(&self) -> Option<&api::Address> { + fn get_optional_shipping(&self) -> Option<&hyperswitch_domain_models::address::Address> { self.address.get_shipping() } @@ -317,7 +326,9 @@ impl RouterData for types::RouterData Result<&api::AddressDetails, Error> { + fn get_billing_address( + &self, + ) -> Result<&hyperswitch_domain_models::address::AddressDetails, Error> { self.address .get_payment_method_billing() .as_ref() @@ -534,14 +545,18 @@ impl RouterData for types::RouterData Result<&api::AddressDetails, Error> { + fn get_shipping_address( + &self, + ) -> Result<&hyperswitch_domain_models::address::AddressDetails, Error> { self.address .get_shipping() .and_then(|a| a.address.as_ref()) .ok_or_else(missing_field_err("shipping.address")) } - fn get_shipping_address_with_phone_number(&self) -> Result<&api::Address, Error> { + fn get_shipping_address_with_phone_number( + &self, + ) -> Result<&hyperswitch_domain_models::address::Address, Error> { self.address .get_shipping() .ok_or_else(missing_field_err("shipping")) @@ -602,7 +617,7 @@ pub trait AddressData { fn get_optional_full_name(&self) -> Option>; } -impl AddressData for api::Address { +impl AddressData for hyperswitch_domain_models::address::Address { fn get_email(&self) -> Result { self.email.clone().ok_or_else(missing_field_err("email")) } @@ -1762,7 +1777,7 @@ pub trait PhoneDetailsData { fn extract_country_code(&self) -> Result; } -impl PhoneDetailsData for api::PhoneDetails { +impl PhoneDetailsData for hyperswitch_domain_models::address::PhoneDetails { fn get_country_code(&self) -> Result { self.country_code .clone() @@ -1811,7 +1826,7 @@ pub trait AddressDetailsData { fn get_optional_country(&self) -> Option; } -impl AddressDetailsData for api::AddressDetails { +impl AddressDetailsData for hyperswitch_domain_models::address::AddressDetails { fn get_first_name(&self) -> Result<&Secret, Error> { self.first_name .as_ref() diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs index 3a2e35190e60..42ee4acadef1 100644 --- a/crates/router/src/connector/wellsfargo/transformers.rs +++ b/crates/router/src/connector/wellsfargo/transformers.rs @@ -802,7 +802,9 @@ impl } } -fn get_phone_number(item: Option<&payments::Address>) -> Option> { +fn get_phone_number( + item: Option<&hyperswitch_domain_models::address::Address>, +) -> Option> { item.as_ref() .and_then(|billing| billing.phone.as_ref()) .and_then(|phone| { @@ -816,7 +818,7 @@ fn get_phone_number(item: Option<&payments::Address>) -> Option> } fn build_bill_to( - address_details: Option<&payments::Address>, + address_details: Option<&hyperswitch_domain_models::address::Address>, email: pii::Email, ) -> Result> { let phone_number = get_phone_number(address_details); diff --git a/crates/router/src/connector/wise/transformers.rs b/crates/router/src/connector/wise/transformers.rs index 94849f2b1ca7..513a762bfd3c 100644 --- a/crates/router/src/connector/wise/transformers.rs +++ b/crates/router/src/connector/wise/transformers.rs @@ -306,7 +306,7 @@ pub enum WiseStatus { #[cfg(feature = "payouts")] fn get_payout_address_details( - address: Option<&api_models::payments::Address>, + address: Option<&hyperswitch_domain_models::address::Address>, ) -> Option { address.and_then(|add| { add.address.as_ref().map(|a| WiseAddressDetails { @@ -323,7 +323,7 @@ fn get_payout_address_details( #[cfg(feature = "payouts")] fn get_payout_bank_details( payout_method_data: PayoutMethodData, - address: Option<&api_models::payments::Address>, + address: Option<&hyperswitch_domain_models::address::Address>, entity_type: PayoutEntityType, ) -> Result { let wise_address_details = match get_payout_address_details(address) { diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs index b4718a64de5a..09cebda49088 100644 --- a/crates/router/src/core/authentication.rs +++ b/crates/router/src/core/authentication.rs @@ -24,8 +24,8 @@ pub async fn perform_authentication( authentication_connector: String, payment_method_data: domain::PaymentMethodData, payment_method: common_enums::PaymentMethod, - billing_address: payments::Address, - shipping_address: Option, + billing_address: hyperswitch_domain_models::address::Address, + shipping_address: Option, browser_details: Option, merchant_connector_account: payments_core::helpers::MerchantConnectorAccountType, amount: Option, diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs index bcbd1481711d..c4b35d527980 100644 --- a/crates/router/src/core/authentication/transformers.rs +++ b/crates/router/src/core/authentication/transformers.rs @@ -28,8 +28,8 @@ pub fn construct_authentication_router_data( authentication_connector: String, payment_method_data: domain::PaymentMethodData, payment_method: PaymentMethod, - billing_address: payments::Address, - shipping_address: Option, + billing_address: hyperswitch_domain_models::address::Address, + shipping_address: Option, browser_details: Option, amount: Option, currency: Option, diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index 599d696ec06d..a7c4a4c4ade3 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -754,7 +754,7 @@ pub(crate) async fn get_payment_method_create_request( payment_method_type: Option, customer_id: &Option, billing_name: Option>, - payment_method_billing_address: Option<&api_models::payments::Address>, + payment_method_billing_address: Option<&hyperswitch_domain_models::address::Address>, ) -> RouterResult { match payment_method_data { Some(pm_data) => match payment_method { @@ -789,7 +789,8 @@ pub(crate) async fn get_payment_method_create_request( .map(|card_network| card_network.to_string()), client_secret: None, payment_method_data: None, - billing: payment_method_billing_address.cloned(), + //TODO: why are we using api model in router internally + billing: payment_method_billing_address.cloned().map(From::from), connector_mandate_details: None, network_transaction_id: None, }; diff --git a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs index ff52799ed631..6a2b3198e932 100644 --- a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs +++ b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs @@ -122,7 +122,7 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list( algorithm_ref: routing::RoutingAlgorithmRef, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, - billing_address: Option, + billing_address: Option, response_payment_method_types: &mut [api_models::payment_methods::ResponsePaymentMethodsEnabled], ) -> ConditionalConfigResult<( types::SurchargeMetadata, @@ -242,7 +242,7 @@ pub async fn perform_surcharge_decision_management_for_session_flow( algorithm_ref: routing::RoutingAlgorithmRef, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, - billing_address: Option, + billing_address: Option, payment_method_type_list: &Vec, ) -> ConditionalConfigResult { let mut surcharge_metadata = types::SurchargeMetadata::new(payment_attempt.attempt_id.clone()); diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 684293151ed5..fd9eaaa9c77d 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -1223,7 +1223,7 @@ pub async fn call_surcharge_decision_management_for_session_flow( _business_profile: &domain::Profile, _payment_attempt: &storage::PaymentAttempt, _payment_intent: &storage::PaymentIntent, - _billing_address: Option, + _billing_address: Option, _session_connector_data: &[api::SessionConnectorData], ) -> RouterResult> { todo!() @@ -1237,7 +1237,7 @@ pub async fn call_surcharge_decision_management_for_session_flow( _business_profile: &domain::Profile, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, - billing_address: Option, + billing_address: Option, session_connector_data: &[api::SessionConnectorData], ) -> RouterResult> { if let Some(surcharge_amount) = payment_attempt.net_amount.get_surcharge_amount() { @@ -1484,7 +1484,7 @@ where F: Send + Clone + Sync, Req: Send + Sync, FData: Send + Sync + Clone, - Op: Operation + Send + Sync + Clone, + Op: Operation + ValidateStatusForOperation + Send + Sync + Clone, Req: Debug, D: OperationSessionGetters + OperationSessionSetters + Send + Sync + Clone, Res: transformers::ToResponse, @@ -4253,7 +4253,7 @@ where #[derive(Clone, serde::Serialize, Debug)] pub struct TaxData { - pub shipping_details: api_models::payments::Address, + pub shipping_details: hyperswitch_domain_models::address::Address, pub payment_method_type: enums::PaymentMethodType, } @@ -6686,7 +6686,7 @@ pub trait OperationSessionGetters { fn get_currency(&self) -> storage_enums::Currency; fn get_amount(&self) -> api::Amount; fn get_payment_attempt_connector(&self) -> Option<&str>; - fn get_billing_address(&self) -> Option; + fn get_billing_address(&self) -> Option; fn get_payment_method_data(&self) -> Option<&domain::PaymentMethodData>; fn get_sessions_token(&self) -> Vec; fn get_token_data(&self) -> Option<&storage::PaymentTokenData>; @@ -6740,6 +6740,7 @@ pub trait OperationSessionSetters { fn set_connector_in_payment_attempt(&mut self, connector: Option); } +#[cfg(feature = "v1")] impl OperationSessionGetters for PaymentData { fn get_payment_attempt(&self) -> &storage::PaymentAttempt { &self.payment_attempt @@ -6840,7 +6841,7 @@ impl OperationSessionGetters for PaymentData { self.payment_attempt.connector.as_deref() } - fn get_billing_address(&self) -> Option { + fn get_billing_address(&self) -> Option { self.address.get_payment_method_billing().cloned() } @@ -6869,15 +6870,15 @@ impl OperationSessionGetters for PaymentData { self.payment_attempt.capture_method } - #[cfg(feature = "v2")] - fn get_capture_method(&self) -> Option { - Some(self.payment_intent.capture_method) - } + // #[cfg(feature = "v2")] + // fn get_capture_method(&self) -> Option { + // Some(self.payment_intent.capture_method) + // } - #[cfg(feature = "v2")] - fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> { - todo!(); - } + // #[cfg(feature = "v2")] + // fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> { + // todo!(); + // } } #[cfg(feature = "v1")] @@ -7082,7 +7083,7 @@ impl OperationSessionGetters for PaymentIntentData { todo!() } - fn get_billing_address(&self) -> Option { + fn get_billing_address(&self) -> Option { todo!() } @@ -7110,7 +7111,6 @@ impl OperationSessionGetters for PaymentIntentData { todo!() } - #[cfg(feature = "v2")] fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> { todo!(); } @@ -7219,9 +7219,8 @@ impl OperationSessionGetters for PaymentConfirmData { todo!() } - // what is this address find out and not required remove this fn get_address(&self) -> &PaymentAddress { - todo!() + &self.payment_address } fn get_creds_identifier(&self) -> Option<&str> { @@ -7296,7 +7295,7 @@ impl OperationSessionGetters for PaymentConfirmData { todo!() } - fn get_billing_address(&self) -> Option { + fn get_billing_address(&self) -> Option { todo!() } @@ -7324,9 +7323,8 @@ impl OperationSessionGetters for PaymentConfirmData { todo!() } - #[cfg(feature = "v2")] fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> { - todo!(); + Some(&self.payment_attempt) } } @@ -7435,9 +7433,8 @@ impl OperationSessionGetters for PaymentStatusData { todo!() } - // what is this address find out and not required remove this fn get_address(&self) -> &PaymentAddress { - todo!() + &self.payment_address } fn get_creds_identifier(&self) -> Option<&str> { @@ -7512,7 +7509,7 @@ impl OperationSessionGetters for PaymentStatusData { todo!() } - fn get_billing_address(&self) -> Option { + fn get_billing_address(&self) -> Option { todo!() } @@ -7540,7 +7537,6 @@ impl OperationSessionGetters for PaymentStatusData { todo!() } - #[cfg(feature = "v2")] fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> { self.payment_attempt.as_ref() } diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index b56260b407eb..4b4091b1c3a6 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -708,7 +708,8 @@ impl GetTracker, api::PaymentsRequest> for Pa .and_then(|pmd| pmd.payment_method_data.as_ref()) .and_then(|payment_method_data_billing| { payment_method_data_billing.get_billing_address() - }); + }) + .map(From::from); let unified_address = address.unify_with_payment_method_data_billing(payment_method_data_billing); diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rs index 5965bdc88503..05c901025655 100644 --- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs +++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs @@ -228,11 +228,28 @@ impl GetTracker, PaymentsConfirmIntent .clone() .map(hyperswitch_domain_models::payment_method_data::PaymentMethodData::from); + let payment_address = hyperswitch_domain_models::payment_address::PaymentAddress::new( + payment_intent + .shipping_address + .clone() + .map(|address| address.into_inner()), + payment_intent + .billing_address + .clone() + .map(|address| address.into_inner()), + payment_attempt + .payment_method_billing_address + .clone() + .map(|address| address.into_inner()), + Some(true), + ); + let payment_data = PaymentConfirmData { flow: std::marker::PhantomData, payment_intent, payment_attempt, payment_method_data, + payment_address, }; let get_trackers_response = operations::GetTrackerResponse { payment_data }; diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 697c06603da0..30891e76e86f 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -566,7 +566,8 @@ impl GetTracker, api::PaymentsRequest> for Pa .and_then(|pmd| pmd.payment_method_data.as_ref()) .and_then(|payment_method_data_billing| { payment_method_data_billing.get_billing_address() - }); + }) + .map(From::from); let unified_address = address.unify_with_payment_method_data_billing(payment_method_data_billing); diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rs index a69c3187c781..f66186c7c571 100644 --- a/crates/router/src/core/payments/operations/payment_get.rs +++ b/crates/router/src/core/payments/operations/payment_get.rs @@ -163,10 +163,29 @@ impl GetTracker, PaymentsRetrieveReques let should_sync_with_connector = request.force_sync && payment_intent.status.should_force_sync_with_connector(); + // We need the address here to send it in the response + let payment_address = hyperswitch_domain_models::payment_address::PaymentAddress::new( + payment_intent + .shipping_address + .clone() + .map(|address| address.into_inner()), + payment_intent + .billing_address + .clone() + .map(|address| address.into_inner()), + payment_attempt + .as_ref() + .and_then(|payment_attempt| payment_attempt.payment_method_billing_address.as_ref()) + .cloned() + .map(|address| address.into_inner()), + Some(true), + ); + let payment_data = PaymentStatusData { flow: std::marker::PhantomData, payment_intent, payment_attempt, + payment_address, should_sync_with_connector, }; diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index e3f9ad5d9054..d77236c8a2bc 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -720,7 +720,7 @@ impl PostUpdateTracker, types::SdkPaymentsSessionUpd let shipping_address = payments_helpers::create_or_update_address_for_payment_by_request( db, - shipping_address.as_ref(), + shipping_address.map(From::from).as_ref(), payment_data.payment_intent.shipping_address_id.as_deref(), &payment_data.payment_intent.merchant_id, payment_data.payment_intent.customer_id.as_ref(), diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs index 2d4054a60bed..c615e2eb1744 100644 --- a/crates/router/src/core/payments/operations/tax_calculation.rs +++ b/crates/router/src/core/payments/operations/tax_calculation.rs @@ -129,7 +129,7 @@ impl GetTracker, api::PaymentsDynamicTaxCalcu })?; let tax_data = payments::TaxData { - shipping_details: request.shipping.clone(), + shipping_details: request.shipping.clone().into(), payment_method_type: request.payment_method_type, }; @@ -403,7 +403,7 @@ impl UpdateTracker, api::PaymentsDynamicTaxCalculati let shipping_address = helpers::create_or_update_address_for_payment_by_request( state, - shipping_address.as_ref(), + shipping_address.map(From::from).as_ref(), payment_data.payment_intent.shipping_address_id.as_deref(), &payment_data.payment_intent.merchant_id, payment_data.payment_intent.customer_id.as_ref(), diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs index 2fb49c37d224..76456c8dbc90 100644 --- a/crates/router/src/core/payments/routing.rs +++ b/crates/router/src/core/payments/routing.rs @@ -12,7 +12,6 @@ use api_models::routing as api_routing; use api_models::{ admin as admin_api, enums::{self as api_enums, CountryAlpha2}, - payments::Address, routing::ConnectorSelection, }; use diesel_models::enums as storage_enums; @@ -27,6 +26,7 @@ use euclid::{ use external_services::grpc_client::dynamic_routing::{ success_rate::CalSuccessRateResponse, SuccessBasedDynamicRouting, }; +use hyperswitch_domain_models::address::Address; use kgraph_utils::{ mca as mca_graph, transformers::{IntoContext, IntoDirValue}, diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs index 14f64cab1535..efee99bb7a0e 100644 --- a/crates/router/src/core/payments/tokenization.rs +++ b/crates/router/src/core/payments/tokenization.rs @@ -80,7 +80,7 @@ pub async fn save_payment_method( payment_method_type: Option, key_store: &domain::MerchantKeyStore, billing_name: Option>, - payment_method_billing_address: Option<&api::Address>, + payment_method_billing_address: Option<&hyperswitch_domain_models::address::Address>, business_profile: &domain::Profile, mut original_connector_mandate_reference_id: Option, ) -> RouterResult diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 9e0557d5b3eb..fe70c3b71080 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -332,7 +332,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>( .map(|description| description.get_string_repr()) .map(ToOwned::to_owned), // TODO: Create unified address - address: hyperswitch_domain_models::payment_address::PaymentAddress::default(), + address: payment_data.payment_address.clone(), auth_type: payment_data.payment_attempt.authentication_type, connector_meta_data: None, connector_wallets_details: None, @@ -433,7 +433,7 @@ pub async fn construct_router_data_for_psync<'a>( sync_type: types::SyncRequestType::SinglePaymentSync, payment_method_type: Some(attempt.payment_method_subtype), currency: payment_intent.amount_details.currency, - // TODO: Get the charges object from + // TODO: Get the charges object from feature metadata charges: None, payment_experience: None, }; @@ -655,30 +655,6 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>( Ok(router_data) } -#[cfg(feature = "v2")] -#[instrument(skip_all)] -#[allow(clippy::too_many_arguments)] -pub async fn construct_payment_router_data<'a, F, T>( - state: &'a SessionState, - payment_data: PaymentData, - connector_id: &str, - merchant_account: &domain::MerchantAccount, - _key_store: &domain::MerchantKeyStore, - customer: &'a Option, - merchant_connector_account: &helpers::MerchantConnectorAccountType, - merchant_recipient_data: Option, - header_payload: Option, -) -> RouterResult> -where - T: TryFrom>, - types::RouterData: Feature, - F: Clone, - error_stack::Report: - From<>>::Error>, -{ - todo!() -} - #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] @@ -1109,6 +1085,7 @@ where Ok(services::ApplicationResponse::JsonWithHeaders(( Self { id: payment_intent.id.clone(), + profile_id: payment_intent.profile_id.clone(), status: payment_intent.status, amount_details: api_models::payments::AmountDetailsResponse::foreign_from( payment_intent.amount_details.clone(), @@ -1211,6 +1188,17 @@ where .clone() .map(api_models::payments::ErrorDetails::foreign_from); + let payment_address = payment_data.get_address(); + + let payment_method_data = + Some(api_models::payments::PaymentMethodDataResponseWithBilling { + payment_method_data: None, + billing: payment_address + .get_request_payment_method_billing() + .cloned() + .map(From::from), + }); + // TODO: Add support for other next actions, currently only supporting redirect to url let redirect_to_url = payment_intent .create_start_redirection_url(base_url, merchant_account.publishable_key.clone())?; @@ -1226,7 +1214,7 @@ where connector, client_secret: payment_intent.client_secret.clone(), created: payment_intent.created_at, - payment_method_data: None, + payment_method_data, payment_method_type: payment_attempt.payment_method_type, payment_method_subtype: payment_attempt.payment_method_subtype, next_action, @@ -1281,14 +1269,30 @@ where .and_then(|payment_attempt| payment_attempt.error.clone()) .map(api_models::payments::ErrorDetails::foreign_from); + let payment_address = payment_data.get_address(); + + let payment_method_data = + Some(api_models::payments::PaymentMethodDataResponseWithBilling { + payment_method_data: None, + billing: payment_address + .get_request_payment_method_billing() + .cloned() + .map(From::from), + }); + let response = Self { id: payment_intent.id.clone(), status: payment_intent.status, amount, connector, + billing: payment_address + .get_payment_billing() + .cloned() + .map(From::from), + shipping: payment_address.get_shipping().cloned().map(From::from), client_secret: payment_intent.client_secret.clone(), created: payment_intent.created_at, - payment_method_data: None, + payment_method_data, payment_method_type: payment_attempt.map(|attempt| attempt.payment_method_type), payment_method_subtype: payment_attempt.map(|attempt| attempt.payment_method_subtype), connector_transaction_id: payment_attempt @@ -1631,7 +1635,8 @@ where billing: payment_data .get_address() .get_request_payment_method_billing() - .cloned(), + .cloned() + .map(From::from), }); let mut headers = connector_http_status_code @@ -1993,8 +1998,16 @@ where payment_method: payment_attempt.payment_method, payment_method_data: payment_method_data_response, payment_token: payment_attempt.payment_token, - shipping: payment_data.get_address().get_shipping().cloned(), - billing: payment_data.get_address().get_payment_billing().cloned(), + shipping: payment_data + .get_address() + .get_shipping() + .cloned() + .map(From::from), + billing: payment_data + .get_address() + .get_payment_billing() + .cloned() + .map(From::from), order_details: payment_intent.order_details, email: customer .as_ref() @@ -3513,10 +3526,10 @@ impl currency: intent_amount_details.currency, shipping_cost: attempt_amount_details.shipping_cost, order_tax_amount: attempt_amount_details.order_tax_amount, - skip_external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( + external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( intent_amount_details.skip_external_tax_calculation, ), - skip_surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( + surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( intent_amount_details.skip_surcharge_calculation, ), surcharge_amount: attempt_amount_details.surcharge_amount, @@ -3556,10 +3569,10 @@ impl .tax_details .as_ref() .and_then(|tax_details| tax_details.get_default_tax_amount())), - skip_external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( + external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( intent_amount_details.skip_external_tax_calculation, ), - skip_surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( + surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( intent_amount_details.skip_surcharge_calculation, ), surcharge_amount: attempt_amount_details @@ -3616,10 +3629,10 @@ impl ForeignFrom order_tax_amount: amount_details.tax_details.and_then(|tax_details| { tax_details.default.map(|default| default.order_tax_amount) }), - skip_external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( + external_tax_calculation: common_enums::TaxCalculationOverride::foreign_from( amount_details.skip_external_tax_calculation, ), - skip_surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( + surcharge_calculation: common_enums::SurchargeCalculationOverride::foreign_from( amount_details.skip_surcharge_calculation, ), surcharge_amount: amount_details.surcharge_amount, diff --git a/crates/router/src/core/payout_link.rs b/crates/router/src/core/payout_link.rs index 31e65e8e0a79..223db5b9f908 100644 --- a/crates/router/src/core/payout_link.rs +++ b/crates/router/src/core/payout_link.rs @@ -214,7 +214,10 @@ pub async fn initiate_payout_link( }); let required_field_override = api::RequiredFieldsOverrideRequest { - billing: address.as_ref().map(From::from), + billing: address + .as_ref() + .map(hyperswitch_domain_models::address::Address::from) + .map(From::from), }; let enabled_payment_methods_with_required_fields = ForeignFrom::foreign_from(( diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs index adf3c51fd80b..d239638c0c60 100644 --- a/crates/router/src/core/payouts.rs +++ b/crates/router/src/core/payouts.rs @@ -852,7 +852,9 @@ pub async fn payouts_list_core( logger::warn!(?err, err_msg); }) .ok() - .map(payment_enums::Address::foreign_from) + .as_ref() + .map(hyperswitch_domain_models::address::Address::from) + .map(payment_enums::Address::from) }); pi_pa_tuple_vec.push(( @@ -2354,7 +2356,10 @@ pub async fn response_handler( let billing_address = payout_data.billing_address.to_owned(); let customer_details = payout_data.customer_details.to_owned(); let customer_id = payouts.customer_id; - let billing = billing_address.as_ref().map(From::from); + let billing = billing_address + .as_ref() + .map(hyperswitch_domain_models::address::Address::from) + .map(From::from); let translated_unified_message = helpers::get_translated_unified_code_and_message( state, diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index 776692d6bec1..99f93f685dfc 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -108,7 +108,7 @@ pub async fn construct_payout_router_data<'a, F>( } }); - let address = PaymentAddress::new(None, billing_address, None, None); + let address = PaymentAddress::new(None, billing_address.map(From::from), None, None); let test_mode: Option = merchant_connector_account.is_test_mode_on(); let payouts = &payout_data.payouts; diff --git a/crates/router/src/core/webhooks/incoming_v2.rs b/crates/router/src/core/webhooks/incoming_v2.rs index c1734794fcc7..b91a6f0e9a01 100644 --- a/crates/router/src/core/webhooks/incoming_v2.rs +++ b/crates/router/src/core/webhooks/incoming_v2.rs @@ -614,12 +614,32 @@ where } api_models::payments::PaymentIdType::PreprocessingId(ref _id) => todo!(), }; + + // We need the address here to send it in the response + // In case we need to send an outgoing webhook, we might have to send the billing address and shipping address + let payment_address = hyperswitch_domain_models::payment_address::PaymentAddress::new( + payment_intent + .shipping_address + .clone() + .map(|address| address.into_inner()), + payment_intent + .billing_address + .clone() + .map(|address| address.into_inner()), + payment_attempt + .payment_method_billing_address + .clone() + .map(|address| address.into_inner()), + Some(true), + ); + Ok(payments::operations::GetTrackerResponse { payment_data: PaymentStatusData { flow: PhantomData, payment_intent, payment_attempt: Some(payment_attempt), should_sync_with_connector: true, + payment_address, }, }) } diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 467ae31f7cf1..95728bd04bc1 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -258,6 +258,7 @@ pub trait Capturable { } } +#[cfg(feature = "v1")] impl Capturable for PaymentsAuthorizeData { fn get_captured_amount(&self, payment_data: &PaymentData) -> Option where @@ -306,6 +307,7 @@ impl Capturable for PaymentsAuthorizeData { } } +#[cfg(feature = "v1")] impl Capturable for PaymentsCaptureData { fn get_captured_amount(&self, _payment_data: &PaymentData) -> Option where @@ -338,6 +340,7 @@ impl Capturable for PaymentsCaptureData { } } +#[cfg(feature = "v1")] impl Capturable for CompleteAuthorizeData { fn get_captured_amount(&self, payment_data: &PaymentData) -> Option where @@ -386,6 +389,7 @@ impl Capturable for CompleteAuthorizeData { } } } + impl Capturable for SetupMandateRequestData {} impl Capturable for PaymentsTaxCalculationData {} impl Capturable for SdkPaymentsSessionUpdateData {} diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 210ae715202d..c16ead40d1f1 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -709,7 +709,7 @@ impl ForeignFrom<&api_types::ConfigUpdate> for storage::ConfigUpdate { } } -impl From<&domain::Address> for api_types::Address { +impl From<&domain::Address> for hyperswitch_domain_models::address::Address { fn from(address: &domain::Address) -> Self { // If all the fields of address are none, then pass the address as None let address_details = if address.city.is_none() @@ -724,7 +724,7 @@ impl From<&domain::Address> for api_types::Address { { None } else { - Some(api_types::AddressDetails { + Some(hyperswitch_domain_models::address::AddressDetails { city: address.city.clone(), country: address.country, line1: address.line1.clone().map(Encryptable::into_inner), @@ -741,7 +741,7 @@ impl From<&domain::Address> for api_types::Address { let phone_details = if address.phone_number.is_none() && address.country_code.is_none() { None } else { - Some(api_types::PhoneDetails { + Some(hyperswitch_domain_models::address::PhoneDetails { number: address.phone_number.clone().map(Encryptable::into_inner), country_code: address.country_code.clone(), }) @@ -1553,7 +1553,9 @@ impl field_name: "customer_details", })?; - let mut billing_address = billing.map(api_types::Address::from); + let mut billing_address = billing + .map(hyperswitch_domain_models::address::Address::from) + .map(api_types::Address::from); // This change is to fix a merchant integration // If billing.email is not passed by the merchant, and if the customer email is present, then use the `customer.email` as the billing email @@ -1582,7 +1584,9 @@ impl Ok(Self { currency: payment_attempt.map(|pa| pa.currency.unwrap_or_default()), - shipping: shipping.map(api_types::Address::from), + shipping: shipping + .map(hyperswitch_domain_models::address::Address::from) + .map(api_types::Address::from), billing: billing_address, amount: payment_attempt .map(|pa| api_types::Amount::from(pa.net_amount.get_order_amount())), diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs index 751359c77634..d8607946b500 100644 --- a/crates/router/tests/connectors/aci.rs +++ b/crates/router/tests/connectors/aci.rs @@ -2,8 +2,8 @@ use std::{borrow::Cow, marker::PhantomData, str::FromStr, sync::Arc}; -use api_models::payments::{Address, AddressDetails, PhoneDetails}; use common_utils::id_type; +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::{ configs::settings::Settings, diff --git a/crates/router/tests/connectors/adyen.rs b/crates/router/tests/connectors/adyen.rs index 2e8d4ab6862a..2146d9590020 100644 --- a/crates/router/tests/connectors/adyen.rs +++ b/crates/router/tests/connectors/adyen.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails, PhoneDetails}; +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, storage::enums, PaymentAddress}; diff --git a/crates/router/tests/connectors/airwallex.rs b/crates/router/tests/connectors/airwallex.rs index f46a0cf7597f..bbc387a0b226 100644 --- a/crates/router/tests/connectors/airwallex.rs +++ b/crates/router/tests/connectors/airwallex.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails}; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::{PeekInterface, Secret}; use router::types::{self, domain, storage::enums, AccessToken}; diff --git a/crates/router/tests/connectors/bitpay.rs b/crates/router/tests/connectors/bitpay.rs index 43959fa683cb..70af3b752127 100644 --- a/crates/router/tests/connectors/bitpay.rs +++ b/crates/router/tests/connectors/bitpay.rs @@ -1,3 +1,4 @@ +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, PaymentAddress}; @@ -40,8 +41,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -51,7 +52,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/bluesnap.rs b/crates/router/tests/connectors/bluesnap.rs index 73799693d74b..d6df20d7ee0e 100644 --- a/crates/router/tests/connectors/bluesnap.rs +++ b/crates/router/tests/connectors/bluesnap.rs @@ -1,7 +1,7 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails}; use common_utils::pii::Email; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, domain, storage::enums, ConnectorAuthType, PaymentAddress}; diff --git a/crates/router/tests/connectors/cashtocode.rs b/crates/router/tests/connectors/cashtocode.rs index 7656cd67de51..50c93f05a6b8 100644 --- a/crates/router/tests/connectors/cashtocode.rs +++ b/crates/router/tests/connectors/cashtocode.rs @@ -1,5 +1,5 @@ -use api_models::payments::{Address, AddressDetails}; use common_utils::id_type; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use router::types::{self, domain, storage::enums}; use crate::{ diff --git a/crates/router/tests/connectors/coinbase.rs b/crates/router/tests/connectors/coinbase.rs index 20be2e502baf..7320b875ca25 100644 --- a/crates/router/tests/connectors/coinbase.rs +++ b/crates/router/tests/connectors/coinbase.rs @@ -1,3 +1,4 @@ +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, PaymentAddress}; use serde_json::json; @@ -41,8 +42,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -52,7 +53,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/cryptopay.rs b/crates/router/tests/connectors/cryptopay.rs index b5f57f7d6f5c..2ecc7869bcd2 100644 --- a/crates/router/tests/connectors/cryptopay.rs +++ b/crates/router/tests/connectors/cryptopay.rs @@ -1,3 +1,4 @@ +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, PaymentAddress}; @@ -40,8 +41,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -51,7 +52,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/cybersource.rs b/crates/router/tests/connectors/cybersource.rs index 0116b52f4edc..411ff3ee2e35 100644 --- a/crates/router/tests/connectors/cybersource.rs +++ b/crates/router/tests/connectors/cybersource.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use common_utils::pii::Email; +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums}; @@ -37,8 +38,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -48,7 +49,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/dlocal.rs b/crates/router/tests/connectors/dlocal.rs index 62278d30ca75..3022f1f0b1d8 100644 --- a/crates/router/tests/connectors/dlocal.rs +++ b/crates/router/tests/connectors/dlocal.rs @@ -2,7 +2,7 @@ use std::str::FromStr; -use api_models::payments::Address; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, PaymentAddress}; @@ -426,7 +426,7 @@ pub fn get_payment_info() -> PaymentInfo { None, Some(Address { phone: None, - address: Some(api::AddressDetails { + address: Some(AddressDetails { city: None, country: Some(api_models::enums::CountryAlpha2::PA), line1: None, diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rs index fa084fc4b2c7..3c5cde492c0c 100644 --- a/crates/router/tests/connectors/forte.rs +++ b/crates/router/tests/connectors/forte.rs @@ -2,6 +2,7 @@ use std::{str::FromStr, time::Duration}; use cards::CardNumber; use common_utils::types::MinorUnit; +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums}; @@ -54,8 +55,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -65,7 +66,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/globalpay.rs b/crates/router/tests/connectors/globalpay.rs index 8879631d1e3d..cd7e6c6b7991 100644 --- a/crates/router/tests/connectors/globalpay.rs +++ b/crates/router/tests/connectors/globalpay.rs @@ -1,5 +1,6 @@ use std::str::FromStr; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, AccessToken, ConnectorAuthType}; use serde_json::json; @@ -59,8 +60,8 @@ impl Globalpay { Some(PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { country: Some(api_models::enums::CountryAlpha2::US), ..Default::default() }), diff --git a/crates/router/tests/connectors/iatapay.rs b/crates/router/tests/connectors/iatapay.rs index 577da6ce6852..d216f6063f6d 100644 --- a/crates/router/tests/connectors/iatapay.rs +++ b/crates/router/tests/connectors/iatapay.rs @@ -1,3 +1,4 @@ +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, storage::enums, AccessToken}; @@ -57,8 +58,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -68,7 +69,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::NL), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/multisafepay.rs b/crates/router/tests/connectors/multisafepay.rs index 0d5af818c358..1a81b00116fa 100644 --- a/crates/router/tests/connectors/multisafepay.rs +++ b/crates/router/tests/connectors/multisafepay.rs @@ -1,4 +1,4 @@ -use api_models::payments::{Address, AddressDetails}; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, domain, storage::enums, PaymentAddress}; diff --git a/crates/router/tests/connectors/opennode.rs b/crates/router/tests/connectors/opennode.rs index e8778f9f4233..d2629e287ca6 100644 --- a/crates/router/tests/connectors/opennode.rs +++ b/crates/router/tests/connectors/opennode.rs @@ -1,3 +1,4 @@ +use hyperswitch_domain_models::address::{Address, AddressDetails, PhoneDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums}; @@ -40,8 +41,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), @@ -51,7 +52,7 @@ fn get_default_payment_info() -> Option { country: Some(api_models::enums::CountryAlpha2::IN), ..Default::default() }), - phone: Some(api::PhoneDetails { + phone: Some(PhoneDetails { number: Some(Secret::new("9123456789".to_string())), country_code: Some("+91".to_string()), }), diff --git a/crates/router/tests/connectors/payeezy.rs b/crates/router/tests/connectors/payeezy.rs index 1bc81ebfe257..49f7085bda49 100644 --- a/crates/router/tests/connectors/payeezy.rs +++ b/crates/router/tests/connectors/payeezy.rs @@ -1,7 +1,7 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails}; use cards::CardNumber; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::{ core::errors, diff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rs index dbc3795e7f15..1994acb6a659 100644 --- a/crates/router/tests/connectors/payme.rs +++ b/crates/router/tests/connectors/payme.rs @@ -1,8 +1,8 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails}; use common_utils::{pii::Email, types::MinorUnit}; use diesel_models::types::OrderDetailsWithAmount; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, domain, storage::enums, PaymentAddress}; diff --git a/crates/router/tests/connectors/trustpay.rs b/crates/router/tests/connectors/trustpay.rs index bae62913a9a3..308bf5135855 100644 --- a/crates/router/tests/connectors/trustpay.rs +++ b/crates/router/tests/connectors/trustpay.rs @@ -1,5 +1,6 @@ use std::str::FromStr; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::types::{self, api, domain, storage::enums, BrowserInformation}; @@ -69,8 +70,8 @@ fn get_default_payment_info() -> Option { Some(utils::PaymentInfo { address: Some(types::PaymentAddress::new( None, - Some(api::Address { - address: Some(api::AddressDetails { + Some(Address { + address: Some(AddressDetails { first_name: Some(Secret::new("first".to_string())), last_name: Some(Secret::new("last".to_string())), line1: Some(Secret::new("line1".to_string())), diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index f8f71a98283a..c08139ae6fe0 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -78,8 +78,8 @@ impl PaymentInfo { address: Some(PaymentAddress::new( None, None, - Some(types::api::Address { - address: Some(types::api::AddressDetails { + Some(hyperswitch_domain_models::address::Address { + address: Some(hyperswitch_domain_models::address::AddressDetails { first_name: Some(Secret::new("John".to_string())), last_name: Some(Secret::new("Doe".to_string())), ..Default::default() diff --git a/crates/router/tests/connectors/wise.rs b/crates/router/tests/connectors/wise.rs index 984a43d48a76..2156cfb1476c 100644 --- a/crates/router/tests/connectors/wise.rs +++ b/crates/router/tests/connectors/wise.rs @@ -1,4 +1,4 @@ -use api_models::payments::{Address, AddressDetails}; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::{ types, diff --git a/crates/router/tests/connectors/worldline.rs b/crates/router/tests/connectors/worldline.rs index 73e710eb2f19..c1be90b59fde 100644 --- a/crates/router/tests/connectors/worldline.rs +++ b/crates/router/tests/connectors/worldline.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use api_models::payments::{Address, AddressDetails}; +use hyperswitch_domain_models::address::{Address, AddressDetails}; use masking::Secret; use router::{ connector::Worldline,