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
refactor(address): change address to domain address in application (#6608)
Narayan Bhat938b2a898ea3
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 6eab5ed265..d9c27a2f01 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.rsindex f46fd450bd..603c0f7693 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<MinorUnit>,/// 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 merchantpub surcharge_amount: Option<MinorUnit>,/// tax on surcharge amount@@ -502,10 +506,10 @@ pub struct ConfirmIntentAmountDetailsResponse {pub order_tax_amount: Option<MinorUnit>,/// 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 merchantpub surcharge_amount: Option<MinorUnit>,/// tax on surcharge amount@@ -4729,6 +4733,12 @@ pub struct PaymentsRetrieveResponse {/// Error details for the payment if anypub error: Option<ErrorDetails>,++ /// The shipping address associated with the payment intent+ pub shipping: Option<Address>,++ /// The billing address associated with the payment intent+ pub billing: Option<Address>,}#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex cb4281ee45..844e9d0194 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -3341,6 +3341,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]@@ -3350,6 +3351,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.rsindex d5a7f981a1..433308059a 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<Secret<String>> {+fn get_payer_name(+ address: &hyperswitch_domain_models::address::AddressDetails,+) -> Option<Secret<String>> {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.rsindex cef3d684e7..bbfa0598cf 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<Option<Address>, 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.rsindex 540bcaebaa..1973e622be 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<Address> {+fn get_address_details(+ address_details: Option<&hyperswitch_domain_models::address::AddressDetails>,+) -> Option<Address> {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.rsindex 89ee8d1b29..e3ebcf490d 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<Email>,) -> Result<Customer, error_stack::Report<errors::ConnectorError>> {let (billing, address) =@@ -454,8 +456,8 @@ fn build_customer_info(})}-impl From<payments::AddressDetails> for BillingAddress {- fn from(value: payments::AddressDetails) -> Self {+impl From<hyperswitch_domain_models::address::AddressDetails> 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<payments::AddressDetails> for BillingAddress {}}-impl From<payments::AddressDetails> for Shipping {- fn from(value: payments::AddressDetails) -> Self {+impl From<hyperswitch_domain_models::address::AddressDetails> 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.rsindex 8ecc3ad792..781d364a59 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<Option<&pii::SecretSerdeValue>> for WorldpayConnectorMetadataObjectfn fetch_payment_instrument(payment_method: PaymentMethodData,- billing_address: Option<&Address>,+ billing_address: Option<&address::Address>,mandate_ids: Option<MandateIds>,) -> CustomResult<PaymentInstrument, errors::ConnectorError> {match payment_method {@@ -232,7 +233,7 @@ trait WorldpayPaymentsRequestData {fn get_off_session(&self) -> Option<bool>;fn get_mandate_id(&self) -> Option<MandateIds>;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<enums::PaymentMethodType>;@@ -278,7 +279,7 @@ impl WorldpayPaymentsRequestDataself.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 WorldpayPaymentsRequestDataself.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.rsindex 181f46a205..cef71610cb 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.rsindex 85595c1ad9..c9beb359c4 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+ .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.rsindex 548dd0c541..176bef0c88 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.rsindex 006d78e2f7..207668817e 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 @@ wherepub payment_intent: PaymentIntent,pub payment_attempt: PaymentAttempt,pub payment_method_data: Option<payment_method_data::PaymentMethodData>,+ pub payment_address: payment_address::PaymentAddress,}#[cfg(feature = "v2")]@@ -593,6 +594,7 @@ wherepub flow: PhantomData<F>,pub payment_intent: PaymentIntent,pub payment_attempt: Option<PaymentAttempt>,+ 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 requestpub 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.rsindex 289b1bab37..591ccc4ff9 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.rsindex c282afa9d0..b14e27e845 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<MinorUnit>,pub order_details: Option<Vec<OrderDetailsWithAmount>>,- 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.rsindex ab36deb425..067c6042ec 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<api_models::payments::Address>,+ pub billing_address: address::Address,+ pub shipping_address: Option<address::Address>,pub browser_details: Option<BrowserInformation>,pub amount: Option<i64>,pub currency: Option<common_enums::Currency>,diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex 55516eeb3b..545c058ce1 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<StripePaymentIntentRequest> 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 datafn get_pmd_based_on_payment_method_type(payment_method_type: Option<api_enums::PaymentMethodType>,- billing_details: Option<payments::Address>,+ billing_details: Option<hyperswitch_domain_models::address::Address>,) -> Option<payments::PaymentMethodData> {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.rsindex cae5f508a2..5309f5fa76 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<Result<Address, error_stack::Report<errors::ConnectorError>>> {address.and_then(|add| {add.address.as_ref().map(@@ -1817,7 +1817,9 @@ fn get_telephone_number(item: &types::PaymentsAuthorizeRouterData) -> Option<Sec})}-fn get_shopper_name(address: Option<&payments::Address>) -> Option<ShopperName> {+fn get_shopper_name(+ address: Option<&hyperswitch_domain_models::address::Address>,+) -> Option<ShopperName> {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<ShopperName>})}-fn get_country_code(address: Option<&payments::Address>) -> Option<api_enums::CountryAlpha2> {+fn get_country_code(+ address: Option<&hyperswitch_domain_models::address::Address>,+) -> Option<api_enums::CountryAlpha2> {address.and_then(|billing| billing.address.as_ref().and_then(|address| address.country))}@@ -4863,7 +4867,7 @@ impl<F> TryFrom<&AdyenRouterData<&types::PayoutsRouterData<F>>> 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<F> TryFrom<&AdyenRouterData<&types::PayoutsRouterData<F>>> 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.rsindex 1530cbd82f..71cc006700 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<F, T>// }fn build_bill_to(- address_details: Option<&payments::Address>,+ address_details: Option<&hyperswitch_domain_models::address::Address>,email: pii::Email,) -> Result<BillTo, error_stack::Report<errors::ConnectorError>> {let default_address = BillTo {diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rsindex 022512ea1c..d3fc0779e2 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<Option<BluesnapCardHolderInfo>, 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.rsindex 2ea36e3e35..af0c02ef2c 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<BillTo, error_stack::Report<errors::ConnectorError>> {let default_address = BillTo {diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rsindex c5c3457443..579bd77d4d 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<Option<Secret<String>>, error_stack::Report<errors::ConnectorError>> {match address_details.country {Some(CountryAlpha2::US) => {diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rsindex 62a5cef0bc..803dc4a428 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<Result<KlarnaShippingAddress, error_stack::Report<errors::ConnectorError>>> {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.rsindex 68a01b26fb..ac6aad8c13 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 {implTryFrom<(- api_models::payments::Address,- Option<api_models::payments::Address>,+ hyperswitch_domain_models::address::Address,+ Option<hyperswitch_domain_models::address::Address>,)> for Cardholder{type Error = error_stack::Report<errors::ConnectorError>;fn try_from((billing_address, shipping_address): (- api_models::payments::Address,- Option<api_models::payments::Address>,+ hyperswitch_domain_models::address::Address,+ Option<hyperswitch_domain_models::address::Address>,),) -> Result<Self, Self::Error> {Ok(Self {@@ -801,9 +801,11 @@ pub struct PhoneNumber {subscriber: Option<masking::Secret<String>>,}-impl TryFrom<api_models::payments::PhoneDetails> for PhoneNumber {+impl TryFrom<hyperswitch_domain_models::address::PhoneDetails> for PhoneNumber {type Error = error_stack::Report<errors::ConnectorError>;- fn try_from(value: api_models::payments::PhoneDetails) -> Result<Self, Self::Error> {+ fn try_from(+ value: hyperswitch_domain_models::address::PhoneDetails,+ ) -> Result<Self, Self::Error> {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.rsindex c350f151d7..11e01b78e1 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<Address> {+fn get_address_info(+ payment_address: Option<&hyperswitch_domain_models::address::Address>,+) -> Option<Address> {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.rsindex 2d519b3caa..e8c1b87441 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<Self, Self::Error> {+ fn try_from(+ address_info: &hyperswitch_domain_models::address::Address,+ ) -> Result<Self, Self::Error> {let address =address_info.clone()diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex b5901f56d3..c3d6806ff0 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<api_models::enums::CountryAlpha2, Error>;- 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<String, Error>;fn get_return_url(&self) -> Result<String, Error>;- 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<pii::SecretSerdeValue, Error>;fn get_session_token(&self) -> Result<String, Error>;fn get_billing_first_name(&self) -> Result<Secret<String>, Error>;@@ -112,8 +119,8 @@ pub trait RouterData {#[cfg(feature = "payouts")]fn get_quote_id(&self) -> Result<String, Error>;- 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<Secret<String>>;fn get_optional_shipping_line2(&self) -> Option<Secret<String>>;fn get_optional_shipping_city(&self) -> Option<String>;@@ -191,7 +198,7 @@ pub fn get_unimplemented_payment_method_error_message(connector: &str) -> String}impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Response> {- 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<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re))}- fn get_billing_phone(&self) -> 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<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re.clone().ok_or_else(missing_field_err("return_url"))}- fn get_billing_address(&self) -> 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<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Rematches!(self.auth_type, enums::AuthenticationType::ThreeDs)}- fn get_shipping_address(&self) -> 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<Secret<String>>;}-impl AddressData for api::Address {+impl AddressData for hyperswitch_domain_models::address::Address {fn get_email(&self) -> Result<Email, Error> {self.email.clone().ok_or_else(missing_field_err("email"))}@@ -1762,7 +1777,7 @@ pub trait PhoneDetailsData {fn extract_country_code(&self) -> Result<String, Error>;}-impl PhoneDetailsData for api::PhoneDetails {+impl PhoneDetailsData for hyperswitch_domain_models::address::PhoneDetails {fn get_country_code(&self) -> Result<String, Error> {self.country_code.clone()@@ -1811,7 +1826,7 @@ pub trait AddressDetailsData {fn get_optional_country(&self) -> Option<api_models::enums::CountryAlpha2>;}-impl AddressDetailsData for api::AddressDetails {+impl AddressDetailsData for hyperswitch_domain_models::address::AddressDetails {fn get_first_name(&self) -> Result<&Secret<String>, Error> {self.first_name.as_ref()diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rsindex 3a2e35190e..42ee4acade 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<Secret<String>> {+fn get_phone_number(+ item: Option<&hyperswitch_domain_models::address::Address>,+) -> Option<Secret<String>> {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<Secret<String>>}fn build_bill_to(- address_details: Option<&payments::Address>,+ address_details: Option<&hyperswitch_domain_models::address::Address>,email: pii::Email,) -> Result<BillTo, error_stack::Report<errors::ConnectorError>> {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.rsindex 94849f2b1c..513a762bfd 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<WiseAddressDetails> {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<WiseBankDetails, errors::ConnectorError> {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.rsindex b4718a64de..09cebda490 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<payments::Address>,+ billing_address: hyperswitch_domain_models::address::Address,+ shipping_address: Option<hyperswitch_domain_models::address::Address>,browser_details: Option<core_types::BrowserInformation>,merchant_connector_account: payments_core::helpers::MerchantConnectorAccountType,amount: Option<common_utils::types::MinorUnit>,diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rsindex bcbd148171..c4b35d5279 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<payments::Address>,+ billing_address: hyperswitch_domain_models::address::Address,+ shipping_address: Option<hyperswitch_domain_models::address::Address>,browser_details: Option<types::BrowserInformation>,amount: Option<common_utils::types::MinorUnit>,currency: Option<common_enums::Currency>,diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 599d696ec0..a7c4a4c4ad 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<storage_enums::PaymentMethodType>,customer_id: &Option<id_type::CustomerId>,billing_name: Option<Secret<String>>,- payment_method_billing_address: Option<&api_models::payments::Address>,+ payment_method_billing_address: Option<&hyperswitch_domain_models::address::Address>,) -> RouterResult<payment_methods::PaymentMethodCreate> {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.rsindex ff52799ed6..6a2b3198e9 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<payments::Address>,+ billing_address: Option<hyperswitch_domain_models::address::Address>,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<payments::Address>,+ billing_address: Option<hyperswitch_domain_models::address::Address>,payment_method_type_list: &Vec<common_enums::PaymentMethodType>,) -> ConditionalConfigResult<types::SurchargeMetadata> {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.rsindex 684293151e..fd9eaaa9c7 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<api_models::payments::Address>,+ _billing_address: Option<hyperswitch_domain_models::address::Address>,_session_connector_data: &[api::SessionConnectorData],) -> RouterResult<Option<api::SessionSurchargeDetails>> {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<api_models::payments::Address>,+ billing_address: Option<hyperswitch_domain_models::address::Address>,session_connector_data: &[api::SessionConnectorData],) -> RouterResult<Option<api::SessionSurchargeDetails>> {if let Some(surcharge_amount) = payment_attempt.net_amount.get_surcharge_amount() {@@ -1484,7 +1484,7 @@ whereF: Send + Clone + Sync,Req: Send + Sync,FData: Send + Sync + Clone,- Op: Operation<F, Req, Data = D> + Send + Sync + Clone,+ Op: Operation<F, Req, Data = D> + ValidateStatusForOperation + Send + Sync + Clone,Req: Debug,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,Res: transformers::ToResponse<F, D, Op>,@@ -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<F> {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<api_models::payments::Address>;+ fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address>;fn get_payment_method_data(&self) -> Option<&domain::PaymentMethodData>;fn get_sessions_token(&self) -> Vec<api::SessionToken>;fn get_token_data(&self) -> Option<&storage::PaymentTokenData>;@@ -6740,6 +6740,7 @@ pub trait OperationSessionSetters<F> {fn set_connector_in_payment_attempt(&mut self, connector: Option<String>);}+#[cfg(feature = "v1")]impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {fn get_payment_attempt(&self) -> &storage::PaymentAttempt {&self.payment_attempt@@ -6840,7 +6841,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {self.payment_attempt.connector.as_deref()}- fn get_billing_address(&self) -> Option<api_models::payments::Address> {+ fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {self.address.get_payment_method_billing().cloned()}@@ -6869,15 +6870,15 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {self.payment_attempt.capture_method}- #[cfg(feature = "v2")]- fn get_capture_method(&self) -> Option<enums::CaptureMethod> {- Some(self.payment_intent.capture_method)- }+ // #[cfg(feature = "v2")]+ // fn get_capture_method(&self) -> Option<enums::CaptureMethod> {+ // 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<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {todo!()}- fn get_billing_address(&self) -> Option<api_models::payments::Address> {+ fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {todo!()}@@ -7110,7 +7111,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {todo!()}- #[cfg(feature = "v2")]fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {todo!();}@@ -7219,9 +7219,8 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {todo!()}- // what is this address find out and not required remove thisfn get_address(&self) -> &PaymentAddress {- todo!()+ &self.payment_address}fn get_creds_identifier(&self) -> Option<&str> {@@ -7296,7 +7295,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {todo!()}- fn get_billing_address(&self) -> Option<api_models::payments::Address> {+ fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {todo!()}@@ -7324,9 +7323,8 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {todo!()}- #[cfg(feature = "v2")]fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {- todo!();+ Some(&self.payment_attempt)}}@@ -7435,9 +7433,8 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {todo!()}- // what is this address find out and not required remove thisfn get_address(&self) -> &PaymentAddress {- todo!()+ &self.payment_address}fn get_creds_identifier(&self) -> Option<&str> {@@ -7512,7 +7509,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {todo!()}- fn get_billing_address(&self) -> Option<api_models::payments::Address> {+ fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {todo!()}@@ -7540,7 +7537,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {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.rsindex b56260b407..4b4091b1c3 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<F: Send + Clone> GetTracker<F, PaymentData<F>, 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.rsindex 5965bdc885..05c9010256 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<F: Send + Clone> GetTracker<F, PaymentConfirmData<F>, 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.rsindex 697c06603d..30891e76e8 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<F: Send + Clone> GetTracker<F, PaymentData<F>, 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.rsindex a69c3187c7..f66186c7c5 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<F: Send + Clone> GetTracker<F, PaymentStatusData<F>, PaymentsRetrieveRequeslet 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.rsindex e3f9ad5d90..d77236c8a2 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<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SdkPaymentsSessionUpdlet 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.rsindex 2d4054a60b..c615e2eb17 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<F: Send + Clone> GetTracker<F, PaymentData<F>, 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<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsDynamicTaxCalculatilet 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.rsindex 2fb49c37d2..76456c8dbc 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.rsindex 14f64cab15..efee99bb7a 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<FData>(payment_method_type: Option<storage_enums::PaymentMethodType>,key_store: &domain::MerchantKeyStore,billing_name: Option<Secret<String>>,- 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<ConnectorMandateReferenceId>,) -> RouterResult<SavePaymentMethodDataResponse>diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 9e0557d5b3..fe70c3b710 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 metadatacharges: 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<F>,- connector_id: &str,- merchant_account: &domain::MerchantAccount,- _key_store: &domain::MerchantKeyStore,- customer: &'a Option<domain::Customer>,- merchant_connector_account: &helpers::MerchantConnectorAccountType,- merchant_recipient_data: Option<types::MerchantRecipientData>,- header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,-) -> RouterResult<types::RouterData<F, T, types::PaymentsResponseData>>-where- T: TryFrom<PaymentAdditionalData<'a, F>>,- types::RouterData<F, T, types::PaymentsResponseData>: Feature<F, T>,- F: Clone,- error_stack::Report<errors::ApiErrorResponse>:- From<<T as TryFrom<PaymentAdditionalData<'a, F>>>::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 @@ whereOk(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 urllet redirect_to_url = payment_intent.create_start_redirection_url(base_url, merchant_account.publishable_key.clone())?;@@ -1226,7 +1214,7 @@ whereconnector,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 @@ wherebilling: 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 @@ wherepayment_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 @@ implcurrency: 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<hyperswitch_domain_models::payments::AmountDetails>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.rsindex 31e65e8e0a..223db5b9f9 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.rsindex adf3c51fd8..d239638c0c 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.rsindex 776692d6be..99f93f685d 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<bool> = 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.rsindex c1734794fc..b91a6f0e9a 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.rsindex 467ae31f7c..95728bd04b 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<F>(&self, payment_data: &PaymentData<F>) -> Option<i64>where@@ -306,6 +307,7 @@ impl Capturable for PaymentsAuthorizeData {}}+#[cfg(feature = "v1")]impl Capturable for PaymentsCaptureData {fn get_captured_amount<F>(&self, _payment_data: &PaymentData<F>) -> Option<i64>where@@ -338,6 +340,7 @@ impl Capturable for PaymentsCaptureData {}}+#[cfg(feature = "v1")]impl Capturable for CompleteAuthorizeData {fn get_captured_amount<F>(&self, payment_data: &PaymentData<F>) -> Option<i64>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.rsindex 210ae71520..c16ead40d1 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 Nonelet 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 @@ implfield_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 @@ implOk(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.rsindex 751359c776..d8607946b5 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.rsindex 2e8d4ab686..2146d95900 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.rsindex f46a0cf759..bbc387a0b2 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.rsindex 43959fa683..70af3b7521 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 73799693d7..d6df20d7ee 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.rsindex 7656cd67de..50c93f05a6 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.rsindex 20be2e502b..7320b875ca 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex b5f57f7d6f..2ecc7869bc 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 0116b52f4e..411ff3ee2e 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 62278d30ca..3022f1f0b1 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.rsindex fa084fc4b2..3c5cde492c 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 8879631d1e..cd7e6c6b79 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.rsindex 577da6ce68..d216f6063f 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 0d5af818c3..1a81b00116 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.rsindex e8778f9f42..d2629e287c 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<utils::PaymentInfo> {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<utils::PaymentInfo> {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.rsindex 1bc81ebfe2..49f7085bda 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.rsindex dbc3795e7f..1994acb6a6 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.rsindex bae62913a9..308bf51358 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<utils::PaymentInfo> {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.rsindex f8f71a9828..c08139ae6f 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.rsindex 984a43d48a..2156cfb147 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.rsindex 73e710eb2f..c1be90b59f 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,