Skip to content

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

fix(core): [Bluesnap] Add secondary_base_url for script (#2124)

Sakil Mostak1407049b56bd
diff --git a/config/config.example.toml b/config/config.example.toml
index 97a50672cf..2d84d4f384 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -159,6 +159,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api"
bambora.base_url = "https://api.na.bambora.com"
bitpay.base_url = "https://test.bitpay.com"
bluesnap.base_url = "https://sandbox.bluesnap.com/"
+bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/"
boku.base_url = "https://$-api4-stage.boku.com"
braintree.base_url = "https://api.sandbox.braintreegateway.com/"
braintree.secondary_base_url = "https://payments.sandbox.braintree-api.com/graphql"
diff --git a/config/development.toml b/config/development.toml
index f1363d2235..44eba5f93d 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -135,6 +135,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api"
bambora.base_url = "https://api.na.bambora.com"
bitpay.base_url = "https://test.bitpay.com"
bluesnap.base_url = "https://sandbox.bluesnap.com/"
+bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/"
boku.base_url = "https://$-api4-stage.boku.com"
braintree.base_url = "https://api.sandbox.braintreegateway.com/"
braintree.secondary_base_url = "https://payments.sandbox.braintree-api.com/graphql"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 66f7e7e8ac..adc41e1bb3 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -80,6 +80,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api"
bambora.base_url = "https://api.na.bambora.com"
bitpay.base_url = "https://test.bitpay.com"
bluesnap.base_url = "https://sandbox.bluesnap.com/"
+bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/"
boku.base_url = "https://$-api4-stage.boku.com"
braintree.base_url = "https://api.sandbox.braintreegateway.com/"
braintree.secondary_base_url = "https://payments.sandbox.braintree-api.com/graphql"
diff --git a/crates/router/src/compatibility/wrap.rs b/crates/router/src/compatibility/wrap.rs
index 890c9435ed..d8e84de2d5 100644
--- a/crates/router/src/compatibility/wrap.rs
+++ b/crates/router/src/compatibility/wrap.rs
@@ -110,14 +110,18 @@ where
),
}
}
- Ok(api::ApplicationResponse::Form(redirection_data)) => api::build_redirection_form(
- &redirection_data.redirect_form,
- redirection_data.payment_method_data,
- redirection_data.amount,
- redirection_data.currency,
- )
- .respond_to(request)
- .map_into_boxed_body(),
+ Ok(api::ApplicationResponse::Form(redirection_data)) => {
+ let config = state.conf();
+ api::build_redirection_form(
+ &redirection_data.redirect_form,
+ redirection_data.payment_method_data,
+ redirection_data.amount,
+ redirection_data.currency,
+ config,
+ )
+ .respond_to(request)
+ .map_into_boxed_body()
+ }
Err(error) => api::log_and_return_error_response(error),
};
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 20e33783e4..3739afc767 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -486,7 +486,7 @@ pub struct Connectors {
pub authorizedotnet: ConnectorParams,
pub bambora: ConnectorParams,
pub bitpay: ConnectorParams,
- pub bluesnap: ConnectorParams,
+ pub bluesnap: ConnectorParamsWithSecondaryBaseUrl,
pub boku: ConnectorParams,
pub braintree: ConnectorParams,
pub cashtocode: ConnectorParams,
@@ -551,7 +551,6 @@ pub struct ConnectorParamsWithFileUploadUrl {
pub base_url_file_upload: String,
}
-#[cfg(feature = "payouts")]
#[derive(Debug, Deserialize, Clone, Default, router_derive::ConfigValidate)]
#[serde(default)]
pub struct ConnectorParamsWithSecondaryBaseUrl {
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 2c844958fd..2f1f4323d8 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -23,7 +23,7 @@ use serde_json::json;
use self::request::{ContentType, HeaderExt, RequestBuilderExt};
pub use self::request::{Method, Request, RequestBuilder};
use crate::{
- configs::settings::Connectors,
+ configs::settings::{Connectors, Settings},
consts,
core::{
errors::{self, CustomResult},
@@ -802,14 +802,18 @@ where
),
}
}
- Ok(ApplicationResponse::Form(redirection_data)) => build_redirection_form(
- &redirection_data.redirect_form,
- redirection_data.payment_method_data,
- redirection_data.amount,
- redirection_data.currency,
- )
- .respond_to(request)
- .map_into_boxed_body(),
+ Ok(ApplicationResponse::Form(redirection_data)) => {
+ let config = state.conf();
+ build_redirection_form(
+ &redirection_data.redirect_form,
+ redirection_data.payment_method_data,
+ redirection_data.amount,
+ redirection_data.currency,
+ config,
+ )
+ .respond_to(request)
+ .map_into_boxed_body()
+ }
Ok(ApplicationResponse::JsonWithHeaders((response, headers))) => {
match serde_json::to_string(&response) {
Ok(res) => http_response_json_with_headers(res, headers),
@@ -980,6 +984,7 @@ pub fn build_redirection_form(
payment_method_data: Option<api_models::payments::PaymentMethodData>,
amount: String,
currency: String,
+ config: Settings,
) -> maud::Markup {
use maud::PreEscaped;
@@ -1062,12 +1067,14 @@ pub fn build_redirection_form(
} else {
"".to_string()
};
+
+ let bluesnap_url = config.connectors.bluesnap.secondary_base_url;
maud::html! {
(maud::DOCTYPE)
html {
head {
meta name="viewport" content="width=device-width, initial-scale=1";
- (PreEscaped(r#"<script src="https://sandpay.bluesnap.com/web-sdk/5/bluesnap.js"></script>"#))
+ (PreEscaped(format!("<script src=\"{bluesnap_url}web-sdk/5/bluesnap.js\"></script>")))
}
body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 62a3781ba4..32a602d4ff 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -66,6 +66,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api"
bambora.base_url = "https://api.na.bambora.com"
bitpay.base_url = "https://test.bitpay.com"
bluesnap.base_url = "https://sandbox.bluesnap.com/"
+bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/"
boku.base_url = "https://country-api4-stage.boku.com"
braintree.base_url = "https://api.sandbox.braintreegateway.com/"
braintree.secondary_base_url = "https://payments.sandbox.braintree-api.com/graphql"