Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(payment_link): add validation for return_url during payment link creation (#7802)
Kashif81eaf396c109
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex bdf7e9ec83..e606291b8d 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -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(())}diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 801c6844f9..f1b15be199 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -979,7 +979,7 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDatif let Some(payment_link) = &request.payment_link {if *payment_link {- helpers::validate_payment_link_request(request.confirm)?;+ helpers::validate_payment_link_request(request)?;}};