mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
fix(router): move payment token/method mandatory check to get trackers for payment update and confirm (#315)
This commit is contained in:
@ -1358,14 +1358,22 @@ pub(crate) fn authenticate_client_secret(
|
||||
}
|
||||
|
||||
pub(crate) fn validate_pm_or_token_given(
|
||||
payment_method: &Option<api_enums::PaymentMethodType>,
|
||||
payment_method_data: &Option<api::PaymentMethod>,
|
||||
mandate_type: &Option<api::MandateTxnType>,
|
||||
token: &Option<String>,
|
||||
pm_data: &Option<api::PaymentMethod>,
|
||||
) -> Result<(), errors::ApiErrorResponse> {
|
||||
utils::when(token.is_none() && pm_data.is_none(), || {
|
||||
Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: "A payment token or payment method data is required".to_string(),
|
||||
})
|
||||
})
|
||||
utils::when(
|
||||
!matches!(payment_method, Some(api_enums::PaymentMethodType::Paypal))
|
||||
&& !matches!(mandate_type, Some(api::MandateTxnType::RecurringMandateTxn))
|
||||
&& token.is_none()
|
||||
&& payment_method_data.is_none(),
|
||||
|| {
|
||||
Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: "A payment token or payment method data is required".to_string(),
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// A function to perform database lookup and then verify the client secret
|
||||
|
||||
Reference in New Issue
Block a user