mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	refactor(router): add domain type for merchant_connector_account id (#5685)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
		 Sai Harsha Vardhan
					Sai Harsha Vardhan
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							f33e1bb65c
						
					
				
				
					commit
					771f48cfe0
				
			| @ -670,16 +670,18 @@ pub struct MerchantId { | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "merchant_connector_account_v2") | ||||
| ))] | ||||
| #[derive(Default, Debug, Deserialize, ToSchema, Serialize)] | ||||
| #[derive(Debug, Deserialize, ToSchema, Serialize)] | ||||
| pub struct MerchantConnectorId { | ||||
|     #[schema(value_type = String)] | ||||
|     pub merchant_id: id_type::MerchantId, | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(value_type = String)] | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
| #[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))] | ||||
| #[derive(Default, Debug, Deserialize, ToSchema, Serialize)] | ||||
| #[derive(Debug, Deserialize, ToSchema, Serialize)] | ||||
| pub struct MerchantConnectorId { | ||||
|     pub id: String, | ||||
|     #[schema(value_type = String)] | ||||
|     pub id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
|  | ||||
| #[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))] | ||||
| @ -757,10 +759,6 @@ pub struct MerchantConnectorCreate { | ||||
|     #[schema(example = json!(consts::FRM_CONFIGS_EG))] | ||||
|     pub frm_configs: Option<Vec<FrmConfigs>>, | ||||
|  | ||||
|     /// Unique ID of the connector | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|  | ||||
|     /// pm_auth_config will relate MCA records to their respective chosen auth services, based on payment_method and pmt | ||||
|     #[schema(value_type = Option<Object>)] | ||||
|     pub pm_auth_config: Option<pii::SecretSerdeValue>, | ||||
| @ -904,8 +902,8 @@ pub struct MerchantConnectorCreate { | ||||
|     pub business_sub_label: Option<String>, | ||||
|  | ||||
|     /// Unique ID of the connector | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = Option<String>)] | ||||
|     pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>, | ||||
|  | ||||
|     #[schema(value_type = Option<Object>)] | ||||
|     pub pm_auth_config: Option<pii::SecretSerdeValue>, | ||||
| @ -1031,11 +1029,15 @@ pub struct MerchantConnectorWebhookDetails { | ||||
| #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, ToSchema)] | ||||
| pub struct MerchantConnectorInfo { | ||||
|     pub connector_label: String, | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(value_type = String)] | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
|  | ||||
| impl MerchantConnectorInfo { | ||||
|     pub fn new(connector_label: String, merchant_connector_id: String) -> Self { | ||||
|     pub fn new( | ||||
|         connector_label: String, | ||||
|         merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
|     ) -> Self { | ||||
|         Self { | ||||
|             connector_label, | ||||
|             merchant_connector_id, | ||||
| @ -1060,8 +1062,8 @@ pub struct MerchantConnectorResponse { | ||||
|     pub connector_label: Option<String>, | ||||
|  | ||||
|     /// Unique ID of the merchant connector account | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub id: id_type::MerchantConnectorAccountId, | ||||
|  | ||||
|     /// Identifier for the business profile, if not provided default will be chosen from merchant account | ||||
|     #[schema(max_length = 64, value_type = String)] | ||||
| @ -1167,8 +1169,8 @@ pub struct MerchantConnectorResponse { | ||||
|     pub connector_label: Option<String>, | ||||
|  | ||||
|     /// Unique ID of the merchant connector account | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
|  | ||||
|     /// Identifier for the business profile, if not provided default will be chosen from merchant account | ||||
|     #[schema(max_length = 64, value_type = String)] | ||||
| @ -1291,8 +1293,8 @@ pub struct MerchantConnectorListResponse { | ||||
|     pub connector_label: Option<String>, | ||||
|  | ||||
|     /// Unique ID of the merchant connector account | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
|  | ||||
|     /// Identifier for the business profile, if not provided default will be chosen from merchant account | ||||
|     #[schema(max_length = 64, value_type = String)] | ||||
| @ -1400,8 +1402,8 @@ pub struct MerchantConnectorListResponse { | ||||
|     pub connector_label: Option<String>, | ||||
|  | ||||
|     /// Unique ID of the merchant connector account | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub id: id_type::MerchantConnectorAccountId, | ||||
|  | ||||
|     /// Identifier for the business profile, if not provided default will be chosen from merchant account | ||||
|     #[schema(max_length = 64, value_type = String)] | ||||
| @ -1760,8 +1762,8 @@ pub struct MerchantConnectorDeleteResponse { | ||||
|     #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)] | ||||
|     pub merchant_id: id_type::MerchantId, | ||||
|     /// Unique ID of the connector | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
|     /// If the connector is deleted or not | ||||
|     #[schema(example = false)] | ||||
|     pub deleted: bool, | ||||
| @ -1774,8 +1776,8 @@ pub struct MerchantConnectorDeleteResponse { | ||||
|     #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)] | ||||
|     pub merchant_id: id_type::MerchantId, | ||||
|     /// Unique ID of the connector | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR")] | ||||
|     pub id: String, | ||||
|     #[schema(example = "mca_5apGeP94tMts6rg3U3kR", value_type = String)] | ||||
|     pub id: id_type::MerchantConnectorAccountId, | ||||
|     /// If the connector is deleted or not | ||||
|     #[schema(example = false)] | ||||
|     pub deleted: bool, | ||||
|  | ||||
| @ -1,9 +1,11 @@ | ||||
| use common_utils::id_type; | ||||
|  | ||||
| use super::{admin, enums}; | ||||
|  | ||||
| #[derive(serde::Deserialize, serde::Serialize, Debug, Clone)] | ||||
| pub struct ActionUrlRequest { | ||||
|     pub connector: enums::Connector, | ||||
|     pub connector_id: String, | ||||
|     pub connector_id: id_type::MerchantConnectorAccountId, | ||||
|     pub return_url: String, | ||||
| } | ||||
|  | ||||
| @ -15,8 +17,8 @@ pub enum ActionUrlResponse { | ||||
|  | ||||
| #[derive(serde::Deserialize, serde::Serialize, Debug, Clone)] | ||||
| pub struct OnboardingSyncRequest { | ||||
|     pub profile_id: common_utils::id_type::ProfileId, | ||||
|     pub connector_id: String, | ||||
|     pub profile_id: id_type::ProfileId, | ||||
|     pub connector_id: id_type::MerchantConnectorAccountId, | ||||
|     pub connector: enums::Connector, | ||||
| } | ||||
|  | ||||
| @ -45,7 +47,7 @@ pub enum PayPalOnboardingStatus { | ||||
|  | ||||
| #[derive(serde::Serialize, Debug, Clone)] | ||||
| pub struct PayPalOnboardingDone { | ||||
|     pub payer_id: common_utils::id_type::MerchantId, | ||||
|     pub payer_id: id_type::MerchantId, | ||||
| } | ||||
|  | ||||
| #[derive(serde::Serialize, Debug, Clone)] | ||||
| @ -55,6 +57,6 @@ pub struct PayPalIntegrationDone { | ||||
|  | ||||
| #[derive(serde::Deserialize, serde::Serialize, Debug, Clone)] | ||||
| pub struct ResetTrackingIdRequest { | ||||
|     pub connector_id: String, | ||||
|     pub connector_id: id_type::MerchantConnectorAccountId, | ||||
|     pub connector: enums::Connector, | ||||
| } | ||||
|  | ||||
| @ -47,7 +47,8 @@ pub struct DisputeResponse { | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub profile_id: Option<common_utils::id_type::ProfileId>, | ||||
|     /// The `merchant_connector_id` of the connector / processor through which the dispute was processed | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, | ||||
| } | ||||
|  | ||||
| #[derive(Clone, Debug, Serialize, ToSchema, Eq, PartialEq)] | ||||
|  | ||||
| @ -129,5 +129,6 @@ pub struct ProcessorPaymentToken { | ||||
|     pub processor_payment_token: String, | ||||
|     #[schema(value_type = Connector, example = "stripe")] | ||||
|     pub connector: api_enums::Connector, | ||||
|     pub merchant_connector_id: String, | ||||
|     #[schema(value_type = String)] | ||||
|     pub merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId, | ||||
| } | ||||
|  | ||||
| @ -215,7 +215,9 @@ pub struct PaymentMethodMigrate { | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct PaymentsMandateReference(pub HashMap<String, PaymentsMandateReferenceRecord>); | ||||
| pub struct PaymentsMandateReference( | ||||
|     pub HashMap<id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>, | ||||
| ); | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct PaymentsMandateReferenceRecord { | ||||
| @ -733,7 +735,7 @@ pub struct BankAccountTokenData { | ||||
| pub struct BankAccountConnectorDetails { | ||||
|     pub connector: String, | ||||
|     pub account_id: masking::Secret<String>, | ||||
|     pub mca_id: String, | ||||
|     pub mca_id: id_type::MerchantConnectorAccountId, | ||||
|     pub access_token: BankAccountAccessCreds, | ||||
| } | ||||
|  | ||||
| @ -1983,7 +1985,7 @@ pub struct PaymentMethodRecord { | ||||
|     pub billing_address_line2: Option<masking::Secret<String>>, | ||||
|     pub billing_address_line3: Option<masking::Secret<String>>, | ||||
|     pub raw_card_number: Option<masking::Secret<String>>, | ||||
|     pub merchant_connector_id: String, | ||||
|     pub merchant_connector_id: id_type::MerchantConnectorAccountId, | ||||
|     pub original_transaction_amount: Option<i64>, | ||||
|     pub original_transaction_currency: Option<common_enums::Currency>, | ||||
|     pub line_number: Option<i64>, | ||||
|  | ||||
| @ -3829,7 +3829,8 @@ pub struct PaymentsResponse { | ||||
|     pub merchant_decision: Option<String>, | ||||
|  | ||||
|     /// Identifier of the connector ( merchant connector account ) which was chosen to make the payment | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>, | ||||
|  | ||||
|     /// If true, incremental authorization can be performed on this payment, in case the funds authorized initially fall short. | ||||
|     pub incremental_authorization_allowed: Option<bool>, | ||||
| @ -4059,7 +4060,7 @@ pub struct PaymentListFilterConstraints { | ||||
|     /// The list of authentication types to filter payments list | ||||
|     pub authentication_type: Option<Vec<enums::AuthenticationType>>, | ||||
|     /// The list of merchant connector ids to filter payments list for selected label | ||||
|     pub merchant_connector_id: Option<Vec<String>>, | ||||
|     pub merchant_connector_id: Option<Vec<id_type::MerchantConnectorAccountId>>, | ||||
|     /// The order in which payments list should be sorted | ||||
|     #[serde(default)] | ||||
|     pub order: Order, | ||||
|  | ||||
| @ -473,7 +473,7 @@ pub struct PayoutCreateResponse { | ||||
|  | ||||
|     /// Unique identifier of the merchant connector account | ||||
|     #[schema(value_type = Option<String>, example = "mca_sAD3OZLATetvjLOYhUSy")] | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>, | ||||
|  | ||||
|     /// Current status of the Payout | ||||
|     #[schema(value_type = PayoutStatus, example = RequiresConfirmation)] | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| use common_enums::{PaymentMethod, PaymentMethodType}; | ||||
| use common_utils::{ | ||||
|     events::{ApiEventMetric, ApiEventsType}, | ||||
|     impl_api_event_type, | ||||
|     id_type, impl_api_event_type, | ||||
| }; | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||||
| @ -46,7 +46,7 @@ pub struct PaymentMethodAuthConnectorChoice { | ||||
|     pub payment_method: PaymentMethod, | ||||
|     pub payment_method_type: PaymentMethodType, | ||||
|     pub connector_name: String, | ||||
|     pub mca_id: String, | ||||
|     pub mca_id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
|  | ||||
| impl_api_event_type!( | ||||
|  | ||||
| @ -159,7 +159,8 @@ pub struct RefundResponse { | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub profile_id: Option<common_utils::id_type::ProfileId>, | ||||
|     /// The merchant_connector_id of the processor through which this payment went through | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, | ||||
|     /// Charge specific fields for controlling the revert of funds from either platform or connected account | ||||
|     #[schema(value_type = Option<ChargeRefunds>)] | ||||
|     pub charges: Option<ChargeRefunds>, | ||||
| @ -186,7 +187,8 @@ pub struct RefundListRequest { | ||||
|     /// The list of connectors to filter refunds list | ||||
|     pub connector: Option<Vec<String>>, | ||||
|     /// The list of merchant connector ids to filter the refunds list for selected label | ||||
|     pub merchant_connector_id: Option<Vec<String>>, | ||||
|     #[schema(value_type = Option<Vec<String>>)] | ||||
|     pub merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>, | ||||
|     /// The list of currencies to filter refunds list | ||||
|     #[schema(value_type = Option<Vec<Currency>>)] | ||||
|     pub currency: Option<Vec<enums::Currency>>, | ||||
|  | ||||
| @ -173,7 +173,8 @@ pub struct RoutableConnectorChoice { | ||||
|     #[serde(skip)] | ||||
|     pub choice_kind: RoutableChoiceKind, | ||||
|     pub connector: RoutableConnectors, | ||||
|     pub merchant_connector_id: Option<String>, | ||||
|     #[schema(value_type = Option<String>)] | ||||
|     pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)] | ||||
| @ -188,7 +189,7 @@ pub enum RoutableChoiceSerde { | ||||
|     OnlyConnector(Box<RoutableConnectors>), | ||||
|     FullStruct { | ||||
|         connector: RoutableConnectors, | ||||
|         merchant_connector_id: Option<String>, | ||||
|         merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, | ||||
|     }, | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| use common_enums::CountryAlpha2; | ||||
| use common_utils::pii; | ||||
| use common_utils::{id_type, pii}; | ||||
| use masking::Secret; | ||||
| use strum::EnumString; | ||||
|  | ||||
| @ -43,7 +43,7 @@ pub struct SetupProcessor { | ||||
|  | ||||
| #[derive(Debug, serde::Deserialize, serde::Serialize)] | ||||
| pub struct ProcessorConnected { | ||||
|     pub processor_id: String, | ||||
|     pub processor_id: id_type::MerchantConnectorAccountId, | ||||
|     pub processor_name: String, | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -1,3 +1,5 @@ | ||||
| use common_utils::id_type; | ||||
|  | ||||
| /// The request body for verification of merchant (everything except domain_names are prefilled) | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| #[serde(rename_all = "camelCase")] | ||||
| @ -13,7 +15,7 @@ pub struct ApplepayMerchantVerificationConfigs { | ||||
| #[serde(rename_all = "snake_case")] | ||||
| pub struct ApplepayMerchantVerificationRequest { | ||||
|     pub domain_names: Vec<String>, | ||||
|     pub merchant_connector_account_id: String, | ||||
|     pub merchant_connector_account_id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
|  | ||||
| /// Response to be sent for the verify/applepay api | ||||
| @ -27,8 +29,8 @@ pub struct ApplepayMerchantResponse { | ||||
| #[derive(Debug, serde::Deserialize)] | ||||
| #[serde(rename_all = "snake_case")] | ||||
| pub struct ApplepayGetVerifiedDomainsParam { | ||||
|     pub merchant_id: common_utils::id_type::MerchantId, | ||||
|     pub merchant_connector_account_id: String, | ||||
|     pub merchant_id: id_type::MerchantId, | ||||
|     pub merchant_connector_account_id: id_type::MerchantConnectorAccountId, | ||||
| } | ||||
| /// Response to be sent for derivation of the already verified domains | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user