mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +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(
|
pub fn validate_payment_link_request(
|
||||||
confirm: Option<bool>,
|
request: &api::PaymentsRequest,
|
||||||
) -> Result<(), errors::ApiErrorResponse> {
|
) -> Result<(), errors::ApiErrorResponse> {
|
||||||
if let Some(cnf) = confirm {
|
#[cfg(feature = "v1")]
|
||||||
if !cnf {
|
if request.confirm == Some(true) {
|
||||||
return Ok(());
|
|
||||||
} else {
|
|
||||||
return Err(errors::ApiErrorResponse::InvalidRequestData {
|
return Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||||
message: "cannot confirm a payment while creating a payment link".to_string(),
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -979,7 +979,7 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDat
|
|||||||
|
|
||||||
if let Some(payment_link) = &request.payment_link {
|
if let Some(payment_link) = &request.payment_link {
|
||||||
if *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