mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	fix(recovery): Populate connector request reference id in revenue recovery record attempt flow. (#8434)
Co-authored-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-V9P7D4K9V0.local> Co-authored-by: Nishanth Challa <nishanth.challa@Nishanth-Challa-C0WGKCFHLF.local> Co-authored-by: Aprabhat19 <amishaprabhat@gmail.com> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -646,7 +646,6 @@ impl PaymentAttempt { | ||||
|         let payment_method_type_data = payment_intent.get_payment_method_type(); | ||||
|  | ||||
|         let payment_method_subtype_data = payment_intent.get_payment_method_sub_type(); | ||||
|  | ||||
|         let authentication_type = payment_intent.authentication_type.unwrap_or_default(); | ||||
|         Ok(Self { | ||||
|             payment_id: payment_intent.id.clone(), | ||||
| @ -752,7 +751,10 @@ impl PaymentAttempt { | ||||
|             .as_ref() | ||||
|             .map(|txn_id| txn_id.get_id().clone()); | ||||
|         let connector = request.connector.map(|connector| connector.to_string()); | ||||
|  | ||||
|         let connector_request_reference_id = payment_intent | ||||
|             .merchant_reference_id | ||||
|             .as_ref() | ||||
|             .map(|id| id.get_string_repr().to_owned()); | ||||
|         Ok(Self { | ||||
|             payment_id: payment_intent.id.clone(), | ||||
|             merchant_id: payment_intent.merchant_id.clone(), | ||||
| @ -804,7 +806,7 @@ impl PaymentAttempt { | ||||
|             charges: None, | ||||
|             processor_merchant_id: payment_intent.merchant_id.clone(), | ||||
|             created_by: None, | ||||
|             connector_request_reference_id: None, | ||||
|             connector_request_reference_id, | ||||
|         }) | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -4044,6 +4044,16 @@ where | ||||
|             ) | ||||
|             .await?, | ||||
|         )); | ||||
|     operation | ||||
|         .to_domain()? | ||||
|         .populate_payment_data( | ||||
|             state, | ||||
|             payment_data, | ||||
|             merchant_context, | ||||
|             business_profile, | ||||
|             &connector, | ||||
|         ) | ||||
|         .await?; | ||||
|  | ||||
|     let mut router_data = payment_data | ||||
|         .construct_router_data( | ||||
|  | ||||
| @ -6,6 +6,7 @@ use error_stack::ResultExt; | ||||
| use hyperswitch_domain_models::{ | ||||
|     payment_method_data::PaymentMethodData, payments::PaymentConfirmData, | ||||
| }; | ||||
| use hyperswitch_interfaces::api::ConnectorSpecifications; | ||||
| use masking::PeekInterface; | ||||
| use router_env::{instrument, tracing}; | ||||
|  | ||||
| @ -15,7 +16,7 @@ use crate::{ | ||||
|         errors::{self, CustomResult, RouterResult, StorageErrorExt}, | ||||
|         payments::{ | ||||
|             operations::{self, ValidateStatusForOperation}, | ||||
|             OperationSessionGetters, | ||||
|             OperationSessionGetters, OperationSessionSetters, | ||||
|         }, | ||||
|     }, | ||||
|     routes::{app::ReqState, SessionState}, | ||||
| @ -303,6 +304,24 @@ impl<F: Clone + Send + Sync> Domain<F, ProxyPaymentsRequest, PaymentConfirmData< | ||||
|     )> { | ||||
|         Ok((Box::new(self), None, None)) | ||||
|     } | ||||
|     #[instrument(skip_all)] | ||||
|     async fn populate_payment_data<'a>( | ||||
|         &'a self, | ||||
|         _state: &SessionState, | ||||
|         payment_data: &mut PaymentConfirmData<F>, | ||||
|         _merchant_context: &domain::MerchantContext, | ||||
|         _business_profile: &domain::Profile, | ||||
|         connector_data: &api::ConnectorData, | ||||
|     ) -> CustomResult<(), errors::ApiErrorResponse> { | ||||
|         let connector_request_reference_id = connector_data | ||||
|             .connector | ||||
|             .generate_connector_request_reference_id( | ||||
|                 &payment_data.payment_intent, | ||||
|                 &payment_data.payment_attempt, | ||||
|             ); | ||||
|         payment_data.set_connector_request_reference_id(Some(connector_request_reference_id)); | ||||
|         Ok(()) | ||||
|     } | ||||
|  | ||||
|     async fn perform_routing<'a>( | ||||
|         &'a self, | ||||
|  | ||||
| @ -232,7 +232,7 @@ pub async fn payments_get_intent( | ||||
|                 header_payload.clone(), | ||||
|             ) | ||||
|         }, | ||||
|         auth::api_or_client_auth( | ||||
|         auth::api_or_client_or_jwt_auth( | ||||
|             &auth::V2ApiKeyAuth { | ||||
|                 is_connected_allowed: false, | ||||
|                 is_platform_allowed: false, | ||||
| @ -240,6 +240,9 @@ pub async fn payments_get_intent( | ||||
|             &auth::V2ClientAuth(common_utils::types::authentication::ResourceId::Payment( | ||||
|                 global_payment_id.clone(), | ||||
|             )), | ||||
|             &auth::JWTAuth { | ||||
|                 permission: Permission::ProfileRevenueRecoveryRead, | ||||
|             }, | ||||
|             req.headers(), | ||||
|         ), | ||||
|         api_locking::LockAction::NotApplicable, | ||||
|  | ||||
| @ -2698,7 +2698,27 @@ where | ||||
|         api_auth | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "v2")] | ||||
| pub fn api_or_client_or_jwt_auth<'a, T, A>( | ||||
|     api_auth: &'a dyn AuthenticateAndFetch<T, A>, | ||||
|     client_auth: &'a dyn AuthenticateAndFetch<T, A>, | ||||
|     jwt_auth: &'a dyn AuthenticateAndFetch<T, A>, | ||||
|     headers: &HeaderMap, | ||||
| ) -> &'a dyn AuthenticateAndFetch<T, A> | ||||
| where | ||||
| { | ||||
|     if let Ok(val) = HeaderMapStruct::new(headers).get_auth_string_from_header() { | ||||
|         if val.trim().starts_with("api-key=") { | ||||
|             api_auth | ||||
|         } else if is_jwt_auth(headers) { | ||||
|             jwt_auth | ||||
|         } else { | ||||
|             client_auth | ||||
|         } | ||||
|     } else { | ||||
|         api_auth | ||||
|     } | ||||
| } | ||||
| #[derive(Debug)] | ||||
| pub struct PublishableKeyAuth; | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 chikke srujan
					chikke srujan