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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payment_link): add configurable separator text between wallet and card sections (#13796)
Aniket Burmanda083c3d0f8b
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex e140d8229d..e481de7b45 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -29729,6 +29729,11 @@"type": "boolean","description": "Flag to display the merchant name in the payment link","nullable": true+ },+ "payment_methods_separator_text": {+ "type": "string",+ "description": "Custom text for the separator shown between wallet and card payment method sections",+ "nullable": true}}},@@ -29917,6 +29922,13 @@"default": true,"example": true,"nullable": true+ },+ "payment_methods_separator_text": {+ "type": "string",+ "description": "Custom text for the separator shown between wallet and card payment method sections",+ "example": "Or pay with",+ "nullable": true,+ "maxLength": 64}}},diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex e14ed7e375..9d7175c14c 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -21549,6 +21549,11 @@"type": "boolean","description": "Flag to display the merchant name in the payment link","nullable": true+ },+ "payment_methods_separator_text": {+ "type": "string",+ "description": "Custom text for the separator shown between wallet and card payment method sections",+ "nullable": true}}},@@ -21737,6 +21742,13 @@"default": true,"example": true,"nullable": true+ },+ "payment_methods_separator_text": {+ "type": "string",+ "description": "Custom text for the separator shown between wallet and card payment method sections",+ "example": "Or pay with",+ "nullable": true,+ "maxLength": 64}}},diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex ed4fb3fa6f..29ab275d67 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -3643,6 +3643,9 @@ pub struct PaymentLinkConfigRequest {/// Flag to display the merchant name in the payment link#[schema(default = true, example = true)]pub show_merchant_name: Option<bool>,+ /// Custom text for the separator shown between wallet and card payment method sections+ #[schema(value_type = Option<String>, max_length = 64, example = "Or pay with")]+ pub payment_methods_separator_text: Option<String>,}impl PaymentLinkConfigRequest {@@ -3776,6 +3779,8 @@ pub struct PaymentLinkConfig {pub color_icon_card_cvc_error: Option<String>,/// Flag to display the merchant name in the payment linkpub show_merchant_name: Option<bool>,+ /// Custom text for the separator shown between wallet and card payment method sections+ pub payment_methods_separator_text: Option<String>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]@@ -3888,6 +3893,7 @@ mod tests {is_setup_mandate_flow: None,color_icon_card_cvc_error: None,show_merchant_name: None,+ payment_methods_separator_text: None,};assert!(safe_request.validate().is_ok());diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 60652627d7..77e24106ac 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -12741,6 +12741,7 @@ pub struct PaymentLinkDetails {pub setup_future_usage_applied: Option<common_enums::FutureUsage>,pub color_icon_card_cvc_error: Option<String>,pub show_merchant_name: Option<bool>,+ pub payment_methods_separator_text: Option<String>,}#[derive(Debug, serde::Serialize, Clone)]@@ -12764,6 +12765,7 @@ pub struct SecurePaymentLinkDetails {pub payment_form_label_type: Option<api_enums::PaymentLinkSdkLabelType>,pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,pub color_icon_card_cvc_error: Option<String>,+ pub payment_methods_separator_text: Option<String>,}#[derive(Debug, serde::Serialize)]diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex 997a920ecf..3b80da7a39 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -645,6 +645,7 @@ pub struct PaymentLinkConfigRequest {pub is_setup_mandate_flow: Option<bool>,pub color_icon_card_cvc_error: Option<String>,pub show_merchant_name: Option<bool>,+ pub payment_methods_separator_text: Option<String>,}#[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.rsindex 0f8acaa8cd..f1b938f616 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -276,6 +276,8 @@ pub struct PaymentLinkConfigRequestForPayments {pub color_icon_card_cvc_error: Option<String>,/// Flag to display the merchant name in the payment linkpub show_merchant_name: Option<bool>,+ /// Custom text for the separator shown between wallet and card payment method sections+ pub payment_methods_separator_text: Option<String>,}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.rsindex e52f957cc4..24017e3a2a 100644--- a/crates/hyperswitch_domain_models/src/lib.rs+++ b/crates/hyperswitch_domain_models/src/lib.rs@@ -1155,6 +1155,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>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,+ payment_methods_separator_text: item.payment_methods_separator_text,}}fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {@@ -1186,6 +1187,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>is_setup_mandate_flow,color_icon_card_cvc_error,show_merchant_name,+ payment_methods_separator_text,} = self;api_models::admin::PaymentLinkConfigRequest {theme,@@ -1221,6 +1223,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>is_setup_mandate_flow,color_icon_card_cvc_error,show_merchant_name,+ payment_methods_separator_text,}}}diff --git a/crates/payment_link/src/wasm.rs b/crates/payment_link/src/wasm.rsindex 05042c4462..fa419c1397 100644--- a/crates/payment_link/src/wasm.rs+++ b/crates/payment_link/src/wasm.rs@@ -51,6 +51,7 @@ pub fn generate_payment_link_preview_impl(config_json: &str) -> Result<String, S.custom_message_for_payment_method_types.clone(),show_merchant_name: payment_link_details.show_merchant_name,+ payment_methods_separator_text: payment_link_details.payment_methods_separator_text.clone(),};if let Ok(config_from_json) = serde_json::from_str::<PaymentLinkConfig>(config_json) {diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex 75242ccd5b..465a68fbd9 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -155,6 +155,7 @@ pub async fn form_payment_link_data(is_setup_mandate_flow: None,color_icon_card_cvc_error: None,show_merchant_name: Some(DEFAULT_SHOW_MERCHANT_NAME),+ payment_methods_separator_text: None,}};@@ -337,6 +338,7 @@ pub async fn form_payment_link_data(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,+ payment_methods_separator_text: payment_link_config.payment_methods_separator_text.clone(),};Ok((@@ -401,6 +403,7 @@ pub async fn initiate_secure_payment_link_flow(payment_form_label_type: payment_link_config.payment_form_label_type,show_card_terms: payment_link_config.show_card_terms,color_icon_card_cvc_error: payment_link_config.color_icon_card_cvc_error,+ payment_methods_separator_text: payment_link_config.payment_methods_separator_text,};let payment_details_str = serde_json::to_string(&secure_payment_link_details).change_context(errors::ApiErrorResponse::InternalServerError)@@ -716,6 +719,7 @@ pub fn get_payment_link_config_based_on_priority(is_setup_mandate_flow,color_icon_card_cvc_error,show_merchant_name,+ payment_methods_separator_text,) = get_payment_link_config_value!(payment_create_link_config,business_theme_configs,@@ -737,6 +741,7 @@ pub fn get_payment_link_config_based_on_priority((is_setup_mandate_flow),(color_icon_card_cvc_error),(show_merchant_name),+ (payment_methods_separator_text),);let payment_link_config =@@ -772,6 +777,7 @@ pub fn get_payment_link_config_based_on_priority(is_setup_mandate_flow,color_icon_card_cvc_error,show_merchant_name,+ payment_methods_separator_text,};common_utils::validation::ValidateXSSOrSQLi::validate_xss_or_sqli(&payment_link_config)@@ -896,6 +902,7 @@ pub async fn get_payment_link_status(is_setup_mandate_flow: None,color_icon_card_cvc_error: None,show_merchant_name: Some(DEFAULT_SHOW_MERCHANT_NAME),+ payment_methods_separator_text: None,}};diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link_initiator.js b/crates/router/src/core/payment_link/payment_link_initiate/payment_link_initiator.jsindex e9aa1808fd..a3d5980c41 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link_initiator.js+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link_initiator.js@@ -82,13 +82,18 @@ function initializeSDK() {? "accordion": paymentDetails.sdk_layout;var hideCardNicknameField = paymentDetails.hide_card_nickname_field;+ var layoutOptions = {+ type: type, //accordion , tabs, spaced accordion+ spacedAccordionItems: paymentDetails.sdk_layout === "spaced_accordion",+ };+ var paymentMethodsSeparatorText = paymentDetails.payment_methods_separator_text;+ if (paymentMethodsSeparatorText !== null && typeof paymentMethodsSeparatorText === "string") {+ layoutOptions.separatorText = paymentMethodsSeparatorText;+ }var unifiedCheckoutOptions = {displaySavedPaymentMethodsCheckbox: false,displaySavedPaymentMethods: false,- layout: {- type: type, //accordion , tabs, spaced accordion- spacedAccordionItems: paymentDetails.sdk_layout === "spaced_accordion",- },+ layout: layoutOptions,branding: "never",wallets: {walletReturnUrl: paymentDetails.return_url,diff --git a/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js b/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.jsindex 967ef3c8c9..fc01e0fa79 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js+++ b/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js@@ -82,13 +82,18 @@ if (!isFramed) {var enableSavedPaymentMethod = paymentDetails.enabled_saved_payment_method;var hideCardNicknameField = paymentDetails.hide_card_nickname_field;+ var layoutOptions = {+ type: type, //accordion , tabs, spaced accordion+ spacedAccordionItems: paymentDetails.sdk_layout === "spaced_accordion",+ };+ var paymentMethodsSeparatorText = paymentDetails.payment_methods_separator_text;+ if (paymentMethodsSeparatorText !== null && typeof paymentMethodsSeparatorText === "string") {+ layoutOptions.separatorText = paymentMethodsSeparatorText;+ }var unifiedCheckoutOptions = {displaySavedPaymentMethodsCheckbox: enableSavedPaymentMethod,displaySavedPaymentMethods: enableSavedPaymentMethod,- layout: {- type: type, //accordion , tabs, spaced accordion- spacedAccordionItems: paymentDetails.sdk_layout === "spaced_accordion",- },+ layout: layoutOptions,branding: "never",wallets: {walletReturnUrl: paymentDetails.return_url,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 4c08e22469..67914b09a8 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -7781,6 +7781,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>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,+ payment_methods_separator_text: config.payment_methods_separator_text,}}}@@ -7859,6 +7860,7 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>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,+ payment_methods_separator_text: config.payment_methods_separator_text,}}}diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 8b21990544..b0fae9af29 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -2629,6 +2629,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>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,+ payment_methods_separator_text: item.payment_methods_separator_text,}}}@@ -2667,6 +2668,7 @@ impl ForeignFrom<diesel_models::business_profile::PaymentLinkConfigRequest>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,+ payment_methods_separator_text: item.payment_methods_separator_text,}}}