mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(core): add server base_url in server config (#12)
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
port = 8080
|
port = 8080
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
request_body_limit = 16_384 # Post request body is limited to 16k.
|
request_body_limit = 16_384 # Post request body is limited to 16k.
|
||||||
|
base_url = "http://localhost:8080"
|
||||||
|
|
||||||
[proxy]
|
[proxy]
|
||||||
# http_url = ""
|
# http_url = ""
|
||||||
|
|||||||
@ -62,6 +62,7 @@ pub struct Server {
|
|||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub request_body_limit: usize,
|
pub request_body_limit: usize,
|
||||||
|
pub base_url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
|||||||
@ -291,32 +291,24 @@ fn validate_new_mandate_request(req: &api::PaymentsRequest) -> RouterResult<()>
|
|||||||
Ok(())
|
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(
|
pub fn create_startpay_url(
|
||||||
server: &Server,
|
server: &Server,
|
||||||
payment_attempt: &storage::PaymentAttempt,
|
payment_attempt: &storage::PaymentAttempt,
|
||||||
payment_intent: &storage::PaymentIntent,
|
payment_intent: &storage::PaymentIntent,
|
||||||
) -> String {
|
) -> String {
|
||||||
let server_url = create_server_url(server);
|
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"{}/payments/start/{}/{}/{}",
|
"{}/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 {
|
pub fn create_redirect_url(server: &Server, payment_attempt: &storage::PaymentAttempt) -> String {
|
||||||
let server_url = create_server_url(server);
|
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"{}/payments/{}/{}/response/{}",
|
"{}/payments/{}/{}/response/{}",
|
||||||
server_url,
|
server.base_url,
|
||||||
payment_attempt.payment_id,
|
payment_attempt.payment_id,
|
||||||
payment_attempt.merchant_id,
|
payment_attempt.merchant_id,
|
||||||
payment_attempt.connector
|
payment_attempt.connector
|
||||||
|
|||||||
Reference in New Issue
Block a user