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_links): Allow Custom T&C messages to be passed for various Payment Method Types (#10252)

Sayak Bhattacharya5d39754eccf8
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 6c76450fe4..ede60dc545 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -16206,6 +16206,14 @@
}
}
},
+ "CustomTermsByPaymentMethodTypes": {
+ "type": "object",
+ "description": "Custom T&C Message to be shown per payment method type",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "nullable": true
+ },
"CustomerAcceptance": {
"type": "object",
"description": "This \"CustomerAcceptance\" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.",
@@ -24426,6 +24434,14 @@
"description": "Text for customizing message for card terms",
"nullable": true
},
+ "custom_message_for_payment_method_types": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"
+ }
+ ],
+ "nullable": true
+ },
"payment_button_colour": {
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
@@ -24598,6 +24614,14 @@
"description": "Text for customizing message for card terms",
"nullable": true
},
+ "custom_message_for_payment_method_types": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"
+ }
+ ],
+ "nullable": true
+ },
"payment_button_colour": {
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 5810c02628..7529ebd4ad 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -10322,6 +10322,14 @@
}
}
},
+ "CustomTermsByPaymentMethodTypes": {
+ "type": "object",
+ "description": "Custom T&C Message to be shown per payment method type",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "nullable": true
+ },
"CustomerAcceptance": {
"type": "object",
"description": "This \"CustomerAcceptance\" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.",
@@ -17787,6 +17795,14 @@
"description": "Text for customizing message for card terms",
"nullable": true
},
+ "custom_message_for_payment_method_types": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"
+ }
+ ],
+ "nullable": true
+ },
"payment_button_colour": {
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
@@ -17959,6 +17975,14 @@
"description": "Text for customizing message for card terms",
"nullable": true
},
+ "custom_message_for_payment_method_types": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"
+ }
+ ],
+ "nullable": true
+ },
"payment_button_colour": {
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index 2aa68bad3e..9bbcc9a45c 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -3359,6 +3359,10 @@ pub struct PaymentLinkConfigRequest {
pub payment_button_text: Option<String>,
/// Text for customizing message for card terms
pub custom_message_for_card_terms: Option<String>,
+ /// Text for customizing message for different Payment Method Types
+ #[schema(value_type = Option<CustomTermsByPaymentMethodTypes>)]
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
/// Custom background colour for payment link's handle confirm button
pub payment_button_colour: Option<String>,
/// Skip the status screen after payment completion
@@ -3458,6 +3462,10 @@ pub struct PaymentLinkConfig {
pub payment_button_text: Option<String>,
/// Text for customizing message for card terms
pub custom_message_for_card_terms: Option<String>,
+ /// Text for customizing message for different Payment Method Types
+ #[schema(value_type = Option<CustomTermsByPaymentMethodTypes>)]
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
/// Custom background colour for payment link's handle confirm button
pub payment_button_colour: Option<String>,
/// Skip the status screen after payment completion
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index ba9f81f72b..7588ee1d91 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -11166,6 +11166,8 @@ pub struct PaymentLinkDetails {
pub payment_button_text: Option<String>,
pub skip_status_screen: Option<bool>,
pub custom_message_for_card_terms: Option<String>,
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
pub payment_button_colour: Option<String>,
pub payment_button_text_colour: Option<String>,
pub background_colour: Option<String>,
@@ -11191,6 +11193,8 @@ pub struct SecurePaymentLinkDetails {
pub payment_button_text: Option<String>,
pub skip_status_screen: Option<bool>,
pub custom_message_for_card_terms: Option<String>,
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
pub payment_button_colour: Option<String>,
pub payment_button_text_colour: Option<String>,
pub background_colour: Option<String>,
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 03373f7943..7cc121897c 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -2074,6 +2074,13 @@ pub enum SamsungPayCardBrand {
Unknown,
}
+/// Custom T&C Message to be shown per payment method type
+#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, utoipa::ToSchema)]
+pub struct CustomTermsByPaymentMethodTypes(
+ #[schema(value_type = HashMap<String, Option<String>>)]
+ pub Option<std::collections::HashMap<PaymentMethodType, String>>,
+);
+
/// Indicates the sub type of payment method. Eg: 'google_pay' & 'apple_pay' for wallets.
#[derive(
Clone,
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index 630d632712..28b54a38f7 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -863,6 +863,8 @@ pub struct PaymentLinkConfigRequest {
pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,
pub payment_button_text: Option<String>,
pub custom_message_for_card_terms: Option<String>,
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
pub payment_button_colour: Option<String>,
pub skip_status_screen: Option<bool>,
pub payment_button_text_colour: Option<String>,
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index c44700c703..a0d186b745 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -227,6 +227,9 @@ pub struct PaymentLinkConfigRequestForPayments {
pub skip_status_screen: Option<bool>,
/// Text for customizing message for card terms
pub custom_message_for_card_terms: Option<String>,
+ /// Text for customizing message for different Payment Method Types
+ pub custom_message_for_payment_method_types:
+ Option<common_enums::CustomTermsByPaymentMethodTypes>,
/// Custom background colour for payment link's handle confirm button
pub payment_button_colour: Option<String>,
/// Custom text colour for payment link's handle confirm button
diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
index a8bad3585f..0b8ff3043b 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -519,6 +519,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
}),
payment_button_text: item.payment_button_text,
custom_message_for_card_terms: item.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: item.custom_message_for_payment_method_types,
payment_button_colour: item.payment_button_colour,
skip_status_screen: item.skip_status_screen,
background_colour: item.background_colour,
@@ -548,6 +549,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
details_layout,
payment_button_text,
custom_message_for_card_terms,
+ custom_message_for_payment_method_types,
payment_button_colour,
skip_status_screen,
background_colour,
@@ -581,6 +583,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
.map(|background_image| background_image.convert_back()),
payment_button_text,
custom_message_for_card_terms,
+ custom_message_for_payment_method_types,
payment_button_colour,
skip_status_screen,
background_colour,
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 9a1f1dc932..78cecaed5e 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -361,6 +361,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::customers::CustomerResponse,
api_models::admin::AcceptedCountries,
api_models::admin::AcceptedCurrencies,
+ api_models::enums::CustomTermsByPaymentMethodTypes,
api_models::enums::AdyenSplitType,
api_models::enums::PaymentType,
api_models::enums::MitCategory,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 07652ca621..c9e3e5c06f 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -284,6 +284,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payment_methods::NetworkTokenStatusCheckResponse,
api_models::payment_methods::NetworkTokenStatusCheckSuccessResponse,
api_models::payment_methods::NetworkTokenStatusCheckFailureResponse,
+ api_models::enums::CustomTermsByPaymentMethodTypes,
api_models::enums::TokenStatus,
api_models::poll::PollResponse,
api_models::poll::PollStatus,
diff --git a/crates/payment_link/src/wasm.rs b/crates/payment_link/src/wasm.rs
index 7a4911e714..4acbc1e12c 100644
--- a/crates/payment_link/src/wasm.rs
+++ b/crates/payment_link/src/wasm.rs
@@ -41,6 +41,9 @@ pub fn generate_payment_link_preview_impl(config_json: &str) -> Result<String, S
enabled_saved_payment_method: false,
allowed_domains: None,
payment_link_ui_rules: None,
+ custom_message_for_payment_method_types: payment_link_details
+ .custom_message_for_payment_method_types
+ .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.rs
index f55ec326d6..611bc45fbe 100644
--- a/crates/router/src/core/payment_link.rs
+++ b/crates/router/src/core/payment_link.rs
@@ -130,6 +130,7 @@ pub async fn form_payment_link_data(
branding_visibility: None,
payment_button_text: None,
custom_message_for_card_terms: None,
+ custom_message_for_payment_method_types: None,
payment_button_colour: None,
skip_status_screen: None,
background_colour: None,
@@ -308,6 +309,9 @@ pub async fn form_payment_link_data(
branding_visibility: payment_link_config.branding_visibility,
payment_button_text: payment_link_config.payment_button_text.clone(),
custom_message_for_card_terms: payment_link_config.custom_message_for_card_terms.clone(),
+ custom_message_for_payment_method_types: payment_link_config
+ .custom_message_for_payment_method_types
+ .clone(),
payment_button_colour: payment_link_config.payment_button_colour.clone(),
skip_status_screen: payment_link_config.skip_status_screen,
background_colour: payment_link_config.background_colour.clone(),
@@ -372,6 +376,8 @@ pub async fn initiate_secure_payment_link_flow(
payment_link_details: *link_details.to_owned(),
payment_button_text: payment_link_config.payment_button_text,
custom_message_for_card_terms: payment_link_config.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: payment_link_config
+ .custom_message_for_payment_method_types,
payment_button_colour: payment_link_config.payment_button_colour,
skip_status_screen: payment_link_config.skip_status_screen,
background_colour: payment_link_config.background_colour,
@@ -673,6 +679,7 @@ pub fn get_payment_link_config_based_on_priority(
background_image,
payment_button_text,
custom_message_for_card_terms,
+ custom_message_for_payment_method_types,
payment_button_colour,
skip_status_screen,
background_colour,
@@ -692,6 +699,7 @@ pub fn get_payment_link_config_based_on_priority(
.foreign_into()),
(payment_button_text),
(custom_message_for_card_terms),
+ (custom_message_for_payment_method_types),
(payment_button_colour),
(skip_status_screen),
(background_colour),
@@ -725,6 +733,7 @@ pub fn get_payment_link_config_based_on_priority(
background_image,
payment_button_text,
custom_message_for_card_terms,
+ custom_message_for_payment_method_types,
payment_button_colour,
background_colour,
payment_button_text_colour,
@@ -838,6 +847,7 @@ pub async fn get_payment_link_status(
branding_visibility: None,
payment_button_text: None,
custom_message_for_card_terms: None,
+ custom_message_for_payment_method_types: None,
payment_button_colour: None,
skip_status_screen: None,
background_colour: 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.js
index 3c4e0d2549..e927076c3a 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
@@ -78,6 +78,7 @@ function initializeSDK() {
showCardFormByDefault: paymentDetails.show_card_form_by_default,
hideCardNicknameField: hideCardNicknameField,
customMessageForCardTerms: paymentDetails.custom_message_for_card_terms,
+ customMessageForPaymentMethodTypes: paymentDetails.custom_message_for_payment_method_types,
};
var showCardTerms = paymentDetails.show_card_terms;
if (showCardTerms !== null && typeof showCardTerms === "string") {
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.js
index 3a9e7f6033..e0a3abb6db 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
@@ -101,6 +101,7 @@ if (!isFramed) {
hideCardNicknameField: hideCardNicknameField,
showCardFormByDefault: paymentDetails.show_card_form_by_default,
customMessageForCardTerms: paymentDetails.custom_message_for_card_terms,
+ customMessageForPaymentMethodTypes: paymentDetails.custom_message_for_payment_method_types,
};
var showCardTerms = paymentDetails.show_card_terms;
if (showCardTerms !== null && typeof showCardTerms === "string") {
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 25063afe1d..f23f075662 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -6564,6 +6564,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
}),
payment_button_text: config.payment_button_text,
custom_message_for_card_terms: config.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: config.custom_message_for_payment_method_types,
payment_button_colour: config.payment_button_colour,
skip_status_screen: config.skip_status_screen,
background_colour: config.background_colour,
@@ -6640,6 +6641,7 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>
}),
payment_button_text: config.payment_button_text,
custom_message_for_card_terms: config.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: config.custom_message_for_payment_method_types,
payment_button_colour: config.payment_button_colour,
skip_status_screen: config.skip_status_screen,
background_colour: config.background_colour,
diff --git a/crates/router/src/core/revenue_recovery.rs b/crates/router/src/core/revenue_recovery.rs
index 4c5a67d20d..a73e106b9b 100644
--- a/crates/router/src/core/revenue_recovery.rs
+++ b/crates/router/src/core/revenue_recovery.rs
@@ -1253,12 +1253,12 @@ pub async fn reset_connector_transmission_and_active_attempt_id_before_pushing_t
"Call made to payments update intent api , with the request body {:?}",
payment_update_req
);
- api::update_payment_intent_api(
+ Box::pin(api::update_payment_intent_api(
state,
payment_intent.id.clone(),
revenue_recovery_payment_data,
payment_update_req,
- )
+ ))
.await
.change_context(errors::RecoveryError::PaymentCallFailed)?;
diff --git a/crates/router/src/core/revenue_recovery/types.rs b/crates/router/src/core/revenue_recovery/types.rs
index 328b436380..242c76d618 100644
--- a/crates/router/src/core/revenue_recovery/types.rs
+++ b/crates/router/src/core/revenue_recovery/types.rs
@@ -697,12 +697,12 @@ impl Action {
"Call made to payments update intent api , with the request body {:?}",
payment_update_req
);
- revenue_recovery_core::api::update_payment_intent_api(
+ Box::pin(revenue_recovery_core::api::update_payment_intent_api(
state,
payment_intent.id.clone(),
revenue_recovery_payment_data,
payment_update_req,
- )
+ ))
.await
.change_context(errors::RecoveryError::PaymentCallFailed)?;
Ok(())
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index d7d4cbc662..befac790f1 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -2156,6 +2156,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
payment_button_text: item.payment_button_text,
skip_status_screen: item.skip_status_screen,
custom_message_for_card_terms: item.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: item.custom_message_for_payment_method_types,
payment_button_colour: item.payment_button_colour,
background_colour: item.background_colour,
payment_button_text_colour: item.payment_button_text_colour,
@@ -2192,6 +2193,7 @@ impl ForeignFrom<diesel_models::business_profile::PaymentLinkConfigRequest>
payment_button_text: item.payment_button_text,
skip_status_screen: item.skip_status_screen,
custom_message_for_card_terms: item.custom_message_for_card_terms,
+ custom_message_for_payment_method_types: item.custom_message_for_payment_method_types,
payment_button_colour: item.payment_button_colour,
background_colour: item.background_colour,
payment_button_text_colour: item.payment_button_text_colour,