mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat(core): add server base_url in server config (#12)
This commit is contained in:
@ -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 = ""
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user