mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
fix(payment_link): add validation for return_url during payment link creation (#7802)
This commit is contained in:
@ -6338,16 +6338,19 @@ pub fn get_key_params_for_surcharge_details(
|
||||
}
|
||||
|
||||
pub fn validate_payment_link_request(
|
||||
confirm: Option<bool>,
|
||||
request: &api::PaymentsRequest,
|
||||
) -> Result<(), errors::ApiErrorResponse> {
|
||||
if let Some(cnf) = confirm {
|
||||
if !cnf {
|
||||
return Ok(());
|
||||
} else {
|
||||
return Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: "cannot confirm a payment while creating a payment link".to_string(),
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "v1")]
|
||||
if request.confirm == Some(true) {
|
||||
return Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: "cannot confirm a payment while creating a payment link".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
if request.return_url.is_none() {
|
||||
return Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: "return_url must be sent while creating a payment link".to_string(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -979,7 +979,7 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDat
|
||||
|
||||
if let Some(payment_link) = &request.payment_link {
|
||||
if *payment_link {
|
||||
helpers::validate_payment_link_request(request.confirm)?;
|
||||
helpers::validate_payment_link_request(request)?;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user