mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(router): add organization_id in authentication table and add it in authentication events (#7168)
				
					
				
			This commit is contained in:
		 Sai Harsha Vardhan
					Sai Harsha Vardhan
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							9b1b245564
						
					
				
				
					commit
					f2117542a7
				
			| @ -124,6 +124,7 @@ pub async fn perform_post_authentication( | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(clippy::too_many_arguments)] | ||||
| pub async fn perform_pre_authentication( | ||||
|     state: &SessionState, | ||||
|     key_store: &domain::MerchantKeyStore, | ||||
| @ -132,6 +133,7 @@ pub async fn perform_pre_authentication( | ||||
|     business_profile: &domain::Profile, | ||||
|     acquirer_details: Option<types::AcquirerDetails>, | ||||
|     payment_id: Option<common_utils::id_type::PaymentId>, | ||||
|     organization_id: common_utils::id_type::OrganizationId, | ||||
| ) -> CustomResult<storage::Authentication, ApiErrorResponse> { | ||||
|     let (authentication_connector, three_ds_connector_account) = | ||||
|         utils::get_authentication_connector_data(state, key_store, business_profile).await?; | ||||
| @ -147,6 +149,7 @@ pub async fn perform_pre_authentication( | ||||
|             .get_mca_id() | ||||
|             .ok_or(ApiErrorResponse::InternalServerError) | ||||
|             .attach_printable("Error while finding mca_id from merchant_connector_account")?, | ||||
|         organization_id, | ||||
|     ) | ||||
|     .await?; | ||||
|  | ||||
|  | ||||
| @ -174,6 +174,7 @@ impl ForeignFrom<common_enums::AuthenticationStatus> for common_enums::AttemptSt | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[allow(clippy::too_many_arguments)] | ||||
| pub async fn create_new_authentication( | ||||
|     state: &SessionState, | ||||
|     merchant_id: common_utils::id_type::MerchantId, | ||||
| @ -182,6 +183,7 @@ pub async fn create_new_authentication( | ||||
|     profile_id: common_utils::id_type::ProfileId, | ||||
|     payment_id: Option<common_utils::id_type::PaymentId>, | ||||
|     merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId, | ||||
|     organization_id: common_utils::id_type::OrganizationId, | ||||
| ) -> RouterResult<storage::Authentication> { | ||||
|     let authentication_id = | ||||
|         common_utils::generate_id_with_default_len(consts::AUTHENTICATION_ID_PREFIX); | ||||
| @ -220,6 +222,7 @@ pub async fn create_new_authentication( | ||||
|         directory_server_id: None, | ||||
|         acquirer_country_code: None, | ||||
|         service_details: None, | ||||
|         organization_id, | ||||
|     }; | ||||
|     state | ||||
|         .store | ||||
|  | ||||
| @ -983,6 +983,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for | ||||
|                     business_profile, | ||||
|                     Some(acquirer_details), | ||||
|                     Some(payment_data.payment_attempt.payment_id.clone()), | ||||
|                     payment_data.payment_attempt.organization_id.clone(), | ||||
|                 ) | ||||
|                 .await?; | ||||
|                 if authentication.is_separate_authn_required() | ||||
| @ -1175,6 +1176,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for | ||||
|                     &authentication_id, | ||||
|                     payment_data.service_details.clone(), | ||||
|                     authentication_status, | ||||
|                     payment_data.payment_attempt.organization_id.clone(), | ||||
|                 ) | ||||
|                 .await?; | ||||
|             }, | ||||
| @ -1197,6 +1199,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for | ||||
|                         .get_mca_id() | ||||
|                         .ok_or(errors::ApiErrorResponse::InternalServerError) | ||||
|                         .attach_printable("Error while finding mca_id from merchant_connector_account")?, | ||||
|                     payment_data.payment_attempt.organization_id.clone(), | ||||
|                 ) | ||||
|                 .await?; | ||||
|  | ||||
|  | ||||
| @ -410,6 +410,7 @@ pub async fn create_new_authentication( | ||||
|     authentication_id: &str, | ||||
|     service_details: Option<payments::CtpServiceDetails>, | ||||
|     authentication_status: common_enums::AuthenticationStatus, | ||||
|     organization_id: common_utils::id_type::OrganizationId, | ||||
| ) -> RouterResult<Authentication> { | ||||
|     let service_details_value = service_details | ||||
|         .map(serde_json::to_value) | ||||
| @ -453,6 +454,7 @@ pub async fn create_new_authentication( | ||||
|         directory_server_id: None, | ||||
|         acquirer_country_code: None, | ||||
|         service_details: service_details_value, | ||||
|         organization_id, | ||||
|     }; | ||||
|     state | ||||
|         .store | ||||
|  | ||||
| @ -151,6 +151,7 @@ impl AuthenticationInterface for MockDb { | ||||
|             directory_server_id: authentication.directory_server_id, | ||||
|             acquirer_country_code: authentication.acquirer_country_code, | ||||
|             service_details: authentication.service_details, | ||||
|             organization_id: authentication.organization_id, | ||||
|         }; | ||||
|         authentications.push(authentication.clone()); | ||||
|         Ok(authentication) | ||||
|  | ||||
| @ -41,6 +41,7 @@ pub struct KafkaAuthentication<'a> { | ||||
|     pub ds_trans_id: Option<&'a String>, | ||||
|     pub directory_server_id: Option<&'a String>, | ||||
|     pub acquirer_country_code: Option<&'a String>, | ||||
|     pub organization_id: &'a common_utils::id_type::OrganizationId, | ||||
| } | ||||
|  | ||||
| impl<'a> KafkaAuthentication<'a> { | ||||
| @ -82,6 +83,7 @@ impl<'a> KafkaAuthentication<'a> { | ||||
|             ds_trans_id: authentication.ds_trans_id.as_ref(), | ||||
|             directory_server_id: authentication.directory_server_id.as_ref(), | ||||
|             acquirer_country_code: authentication.acquirer_country_code.as_ref(), | ||||
|             organization_id: &authentication.organization_id, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -42,6 +42,7 @@ pub struct KafkaAuthenticationEvent<'a> { | ||||
|     pub ds_trans_id: Option<&'a String>, | ||||
|     pub directory_server_id: Option<&'a String>, | ||||
|     pub acquirer_country_code: Option<&'a String>, | ||||
|     pub organization_id: &'a common_utils::id_type::OrganizationId, | ||||
| } | ||||
|  | ||||
| impl<'a> KafkaAuthenticationEvent<'a> { | ||||
| @ -83,6 +84,7 @@ impl<'a> KafkaAuthenticationEvent<'a> { | ||||
|             ds_trans_id: authentication.ds_trans_id.as_ref(), | ||||
|             directory_server_id: authentication.directory_server_id.as_ref(), | ||||
|             acquirer_country_code: authentication.acquirer_country_code.as_ref(), | ||||
|             organization_id: &authentication.organization_id, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user