diff --git a/crates/router/src/configs/defaults.toml b/crates/router/src/configs/defaults.toml index 75de8516d9..6cb5504031 100644 --- a/crates/router/src/configs/defaults.toml +++ b/crates/router/src/configs/defaults.toml @@ -4,6 +4,7 @@ port = 8080 host = "127.0.0.1" request_body_limit = 16_384 # Post request body is limited to 16k. +base_url = "http://localhost:8080" [proxy] # http_url = "" diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs index 07fb6a41a4..d4dfbfb360 100644 --- a/crates/router/src/configs/settings.rs +++ b/crates/router/src/configs/settings.rs @@ -62,6 +62,7 @@ pub struct Server { pub port: u16, pub host: String, pub request_body_limit: usize, + pub base_url: String, } #[derive(Debug, Deserialize, Clone)] diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 1b1f682c48..294b10da5a 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -291,32 +291,24 @@ fn validate_new_mandate_request(req: &api::PaymentsRequest) -> RouterResult<()> Ok(()) } -pub fn create_server_url(server: &Server) -> String { - if server.host.eq("127.0.0.1") || server.host.eq("localhost") { - format!("http://{}:{}", server.host, server.port) - } else { - format!("https://{}", server.host) - } -} pub fn create_startpay_url( server: &Server, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, ) -> String { - let server_url = create_server_url(server); - format!( "{}/payments/start/{}/{}/{}", - server_url, payment_intent.payment_id, payment_intent.merchant_id, payment_attempt.txn_id + server.base_url, + payment_intent.payment_id, + payment_intent.merchant_id, + payment_attempt.txn_id ) } pub fn create_redirect_url(server: &Server, payment_attempt: &storage::PaymentAttempt) -> String { - let server_url = create_server_url(server); - format!( "{}/payments/{}/{}/response/{}", - server_url, + server.base_url, payment_attempt.payment_id, payment_attempt.merchant_id, payment_attempt.connector