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

feat(payment_link): add profile-level config to display merchant name in payment link UI (#12594)

Aniket Burman67585f708f38
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 32e22aa51a..abda64c2f4 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -28110,6 +28110,11 @@
"type": "string",
"description": "Hex color for the CVC icon during error state",
"nullable": true
+ },
+ "show_merchant_name": {
+ "type": "boolean",
+ "description": "Flag to display the merchant name in the payment link",
+ "nullable": true
}
}
},
@@ -28291,6 +28296,13 @@
"type": "string",
"description": "Hex color for the CVC icon during error state",
"nullable": true
+ },
+ "show_merchant_name": {
+ "type": "boolean",
+ "description": "Flag to display the merchant name in the payment link",
+ "default": true,
+ "example": true,
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 77a184933c..549a9f85b6 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -21089,6 +21089,11 @@
"type": "string",
"description": "Hex color for the CVC icon during error state",
"nullable": true
+ },
+ "show_merchant_name": {
+ "type": "boolean",
+ "description": "Flag to display the merchant name in the payment link",
+ "nullable": true
}
}
},
@@ -21270,6 +21275,13 @@
"type": "string",
"description": "Hex color for the CVC icon during error state",
"nullable": true
+ },
+ "show_merchant_name": {
+ "type": "boolean",
+ "description": "Flag to display the merchant name in the payment link",
+ "default": true,
+ "example": true,
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index e1bdd8a631..3377019279 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -3540,6 +3540,9 @@ pub struct PaymentLinkConfigRequest {
pub is_setup_mandate_flow: Option<bool>,
/// Hex color for the CVC icon during error state
pub color_icon_card_cvc_error: Option<String>,
+ /// Flag to display the merchant name in the payment link
+ #[schema(default = true, example = true)]
+ pub show_merchant_name: Option<bool>,
}
impl PaymentLinkConfigRequest {
@@ -3652,6 +3655,8 @@ pub struct PaymentLinkConfig {
pub is_setup_mandate_flow: Option<bool>,
/// Hex color for the CVC icon during error state
pub color_icon_card_cvc_error: Option<String>,
+ /// Flag to display the merchant name in the payment link
+ pub show_merchant_name: Option<bool>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 4a51a240c9..878aa153c3 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -12351,6 +12351,7 @@ pub struct PaymentLinkDetails {
pub capture_method: Option<common_enums::CaptureMethod>,
pub setup_future_usage_applied: Option<common_enums::FutureUsage>,
pub color_icon_card_cvc_error: Option<String>,
+ pub show_merchant_name: Option<bool>,
}
#[derive(Debug, serde::Serialize, Clone)]
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index 429564eb05..dec99d6d7d 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -942,6 +942,7 @@ pub struct PaymentLinkConfigRequest {
pub show_card_terms: Option<common_enums::PaymentLinkShowSdkTerms>,
pub is_setup_mandate_flow: Option<bool>,
pub color_icon_card_cvc_error: Option<String>,
+ pub show_merchant_name: Option<bool>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq)]
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index c69dfde9f8..4f60004bc2 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -261,6 +261,8 @@ pub struct PaymentLinkConfigRequestForPayments {
pub is_setup_mandate_flow: Option<bool>,
/// Hex color for the CVC icon during error state
pub color_icon_card_cvc_error: Option<String>,
+ /// Flag to display the merchant name in the payment link
+ pub show_merchant_name: Option<bool>,
}
common_utils::impl_to_sql_from_sql_json!(PaymentLinkConfigRequestForPayments);
diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
index 65d0fcd356..4884cf5a82 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -812,6 +812,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
show_card_terms: item.show_card_terms,
is_setup_mandate_flow: item.is_setup_mandate_flow,
color_icon_card_cvc_error: item.color_icon_card_cvc_error,
+ show_merchant_name: item.show_merchant_name,
}
}
fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {
@@ -842,6 +843,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
show_card_terms,
is_setup_mandate_flow,
color_icon_card_cvc_error,
+ show_merchant_name,
} = self;
api_models::admin::PaymentLinkConfigRequest {
theme,
@@ -876,6 +878,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
show_card_terms,
is_setup_mandate_flow,
color_icon_card_cvc_error,
+ show_merchant_name,
}
}
}
diff --git a/crates/payment_link/src/wasm.rs b/crates/payment_link/src/wasm.rs
index 613e9c50cc..5523489628 100644
--- a/crates/payment_link/src/wasm.rs
+++ b/crates/payment_link/src/wasm.rs
@@ -46,6 +46,7 @@ pub fn generate_payment_link_preview_impl(config_json: &str) -> Result<String, S
custom_message_for_payment_method_types: payment_link_details
.custom_message_for_payment_method_types
.clone(),
+ show_merchant_name: payment_link_details.show_merchant_name,
};
if let Ok(config_from_json) = serde_json::from_str::<PaymentLinkConfig>(config_json) {
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index e449ae5dc9..bbb359188d 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -177,6 +177,9 @@ pub const DEFAULT_BACKGROUND_COLOR: &str = "#212E46";
pub const DEFAULT_PRODUCT_IMG: &str =
"https://live.hyperswitch.io/payment-link-assets/cart_placeholder.png";
+/// Show merchant name by default for payment links
+pub const DEFAULT_SHOW_MERCHANT_NAME: bool = true;
+
/// Default SDK Layout
pub const DEFAULT_SDK_LAYOUT: &str = "tabs";
diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs
index 0c677058de..ef198db2a4 100644
--- a/crates/router/src/core/payment_link.rs
+++ b/crates/router/src/core/payment_link.rs
@@ -25,7 +25,7 @@ use crate::{
self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY,
DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD,
DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG,
- DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM,
+ DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, DEFAULT_SHOW_MERCHANT_NAME,
},
errors::RouterResponse,
get_payment_link_config_value, get_payment_link_config_value_based_on_priority,
@@ -142,6 +142,7 @@ pub async fn form_payment_link_data(
show_card_terms: None,
is_setup_mandate_flow: None,
color_icon_card_cvc_error: None,
+ show_merchant_name: Some(DEFAULT_SHOW_MERCHANT_NAME),
}
};
@@ -323,6 +324,7 @@ pub async fn form_payment_link_data(
color_icon_card_cvc_error: payment_link_config.color_icon_card_cvc_error.clone(),
capture_method: payment_attempt.capture_method,
setup_future_usage_applied: payment_attempt.setup_future_usage_applied,
+ show_merchant_name: payment_link_config.show_merchant_name,
};
Ok((
@@ -694,6 +696,7 @@ pub fn get_payment_link_config_based_on_priority(
show_card_terms,
is_setup_mandate_flow,
color_icon_card_cvc_error,
+ show_merchant_name,
) = get_payment_link_config_value!(
payment_create_link_config,
business_theme_configs,
@@ -714,6 +717,7 @@ pub fn get_payment_link_config_based_on_priority(
(show_card_terms),
(is_setup_mandate_flow),
(color_icon_card_cvc_error),
+ (show_merchant_name),
);
let payment_link_config =
@@ -748,6 +752,7 @@ pub fn get_payment_link_config_based_on_priority(
show_card_terms,
is_setup_mandate_flow,
color_icon_card_cvc_error,
+ show_merchant_name,
};
Ok((payment_link_config, domain_name))
@@ -863,6 +868,7 @@ pub async fn get_payment_link_status(
show_card_terms: None,
is_setup_mandate_flow: None,
color_icon_card_cvc_error: None,
+ show_merchant_name: Some(DEFAULT_SHOW_MERCHANT_NAME),
}
};
diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
index 81bda59a0d..66cb33fe74 100644
--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
@@ -713,7 +713,9 @@ function renderPaymentDetails(paymentDetails) {
"hyper-checkout-payment-merchant-details"
);
if (paymentMerchantDetails instanceof HTMLDivElement) {
- paymentMerchantDetails.append(merchantNameNode);
+ if (paymentDetails.show_merchant_name !== false) {
+ paymentMerchantDetails.append(merchantNameNode);
+ }
paymentMerchantDetails.append(paymentIdNode);
}
var merchantImageNode = document.getElementById(
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 3771ac3481..2f7ca6e8c9 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -6961,6 +6961,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
show_card_terms: config.show_card_terms,
is_setup_mandate_flow: config.is_setup_mandate_flow,
color_icon_card_cvc_error: config.color_icon_card_cvc_error,
+ show_merchant_name: config.show_merchant_name,
}
}
}
@@ -7038,6 +7039,7 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>
show_card_terms: config.show_card_terms,
is_setup_mandate_flow: config.is_setup_mandate_flow,
color_icon_card_cvc_error: config.color_icon_card_cvc_error,
+ show_merchant_name: config.show_merchant_name,
}
}
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 405cc6a95e..e957db5424 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -2452,6 +2452,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
show_card_terms: item.show_card_terms,
is_setup_mandate_flow: item.is_setup_mandate_flow,
color_icon_card_cvc_error: item.color_icon_card_cvc_error,
+ show_merchant_name: item.show_merchant_name,
}
}
}
@@ -2489,6 +2490,7 @@ impl ForeignFrom<diesel_models::business_profile::PaymentLinkConfigRequest>
show_card_terms: item.show_card_terms,
is_setup_mandate_flow: item.is_setup_mandate_flow,
color_icon_card_cvc_error: item.color_icon_card_cvc_error,
+ show_merchant_name: item.show_merchant_name,
}
}
}