mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +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:
@ -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