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(payments): [Payment links] add configs for payment link (#7340)

Debarati Ghatak0dd62e86fd0a
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index 90cc3d4b6a..2e0d57d977 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -13953,6 +13953,21 @@
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
"nullable": true
+ },
+ "skip_status_screen": {
+ "type": "boolean",
+ "description": "Skip the status screen after payment completion",
+ "nullable": true
+ },
+ "payment_button_text_colour": {
+ "type": "string",
+ "description": "Custom text colour for payment link's handle confirm button",
+ "nullable": true
+ },
+ "background_colour": {
+ "type": "string",
+ "description": "Custom background colour for the payment link",
+ "nullable": true
}
}
},
@@ -14053,6 +14068,21 @@
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
"nullable": true
+ },
+ "skip_status_screen": {
+ "type": "boolean",
+ "description": "Skip the status screen after payment completion",
+ "nullable": true
+ },
+ "payment_button_text_colour": {
+ "type": "string",
+ "description": "Custom text colour for payment link's handle confirm button",
+ "nullable": true
+ },
+ "background_colour": {
+ "type": "string",
+ "description": "Custom background colour for the payment link",
+ "nullable": true
}
}
},
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index a16adf76c5..0473fec243 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -16505,6 +16505,21 @@
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
"nullable": true
+ },
+ "skip_status_screen": {
+ "type": "boolean",
+ "description": "Skip the status screen after payment completion",
+ "nullable": true
+ },
+ "payment_button_text_colour": {
+ "type": "string",
+ "description": "Custom text colour for payment link's handle confirm button",
+ "nullable": true
+ },
+ "background_colour": {
+ "type": "string",
+ "description": "Custom background colour for the payment link",
+ "nullable": true
}
}
},
@@ -16605,6 +16620,21 @@
"type": "string",
"description": "Custom background colour for payment link's handle confirm button",
"nullable": true
+ },
+ "skip_status_screen": {
+ "type": "boolean",
+ "description": "Skip the status screen after payment completion",
+ "nullable": true
+ },
+ "payment_button_text_colour": {
+ "type": "string",
+ "description": "Custom text colour for payment link's handle confirm button",
+ "nullable": true
+ },
+ "background_colour": {
+ "type": "string",
+ "description": "Custom background colour for the payment link",
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index ec69d7c8fd..d9ae29d4b3 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -2786,6 +2786,12 @@ pub struct PaymentLinkConfigRequest {
pub custom_message_for_card_terms: Option<String>,
/// Custom background colour for payment link's handle confirm button
pub payment_button_colour: Option<String>,
+ /// Skip the status screen after payment completion
+ pub skip_status_screen: Option<bool>,
+ /// Custom text colour for payment link's handle confirm button
+ pub payment_button_text_colour: Option<String>,
+ /// Custom background colour for the payment link
+ pub background_colour: Option<String>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
@@ -2861,6 +2867,12 @@ pub struct PaymentLinkConfig {
pub custom_message_for_card_terms: Option<String>,
/// Custom background colour for payment link's handle confirm button
pub payment_button_colour: Option<String>,
+ /// Skip the status screen after payment completion
+ pub skip_status_screen: Option<bool>,
+ /// Custom text colour for payment link's handle confirm button
+ pub payment_button_text_colour: Option<String>,
+ /// Custom background colour for the payment link
+ pub background_colour: Option<String>,
}
#[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 8f14dc8d86..c94193831f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -7818,8 +7818,11 @@ pub struct PaymentLinkDetails {
pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
pub branding_visibility: Option<bool>,
pub payment_button_text: Option<String>,
+ pub skip_status_screen: Option<bool>,
pub custom_message_for_card_terms: Option<String>,
pub payment_button_colour: Option<String>,
+ pub payment_button_text_colour: Option<String>,
+ pub background_colour: Option<String>,
}
#[derive(Debug, serde::Serialize, Clone)]
@@ -7830,8 +7833,11 @@ pub struct SecurePaymentLinkDetails {
#[serde(flatten)]
pub payment_link_details: PaymentLinkDetails,
pub payment_button_text: Option<String>,
+ pub skip_status_screen: Option<bool>,
pub custom_message_for_card_terms: Option<String>,
pub payment_button_colour: Option<String>,
+ pub payment_button_text_colour: Option<String>,
+ pub background_colour: Option<String>,
}
#[derive(Debug, serde::Serialize)]
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index d0ee9e8926..c5507d7800 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -629,6 +629,9 @@ pub struct PaymentLinkConfigRequest {
pub payment_button_text: Option<String>,
pub custom_message_for_card_terms: Option<String>,
pub payment_button_colour: Option<String>,
+ pub skip_status_screen: Option<bool>,
+ pub payment_button_text_colour: Option<String>,
+ pub background_colour: 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.rs
index 77cd5db77b..a2b3c406a2 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -177,10 +177,16 @@ pub struct PaymentLinkConfigRequestForPayments {
pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,
/// Text for payment link's handle confirm button
pub payment_button_text: Option<String>,
+ /// Skip the status screen after payment completion
+ pub skip_status_screen: Option<bool>,
/// Text for customizing message for card terms
pub custom_message_for_card_terms: Option<String>,
/// 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
+ pub payment_button_text_colour: Option<String>,
+ /// Custom background colour for the payment link
+ pub background_colour: 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.rs
index 011f9619cd..c97753a6dc 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -409,6 +409,9 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
payment_button_text: item.payment_button_text,
custom_message_for_card_terms: item.custom_message_for_card_terms,
payment_button_colour: item.payment_button_colour,
+ skip_status_screen: item.skip_status_screen,
+ background_colour: item.background_colour,
+ payment_button_text_colour: item.payment_button_text_colour,
}
}
fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {
@@ -427,6 +430,9 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
payment_button_text,
custom_message_for_card_terms,
payment_button_colour,
+ skip_status_screen,
+ background_colour,
+ payment_button_text_colour,
} = self;
api_models::admin::PaymentLinkConfigRequest {
theme,
@@ -449,6 +455,9 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
payment_button_text,
custom_message_for_card_terms,
payment_button_colour,
+ skip_status_screen,
+ background_colour,
+ payment_button_text_colour,
}
}
}
diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs
index ba63319aab..e62d994641 100644
--- a/crates/router/src/core/payment_link.rs
+++ b/crates/router/src/core/payment_link.rs
@@ -132,6 +132,9 @@ pub async fn form_payment_link_data(
payment_button_text: None,
custom_message_for_card_terms: None,
payment_button_colour: None,
+ skip_status_screen: None,
+ background_colour: None,
+ payment_button_text_colour: None,
}
};
@@ -280,6 +283,9 @@ pub async fn form_payment_link_data(
payment_button_text: payment_link_config.payment_button_text.clone(),
custom_message_for_card_terms: payment_link_config.custom_message_for_card_terms.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(),
+ payment_button_text_colour: payment_link_config.payment_button_text_colour.clone(),
};
Ok((
@@ -333,6 +339,9 @@ pub async fn initiate_secure_payment_link_flow(
payment_button_text: payment_link_config.payment_button_text,
custom_message_for_card_terms: payment_link_config.custom_message_for_card_terms,
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,
+ payment_button_text_colour: payment_link_config.payment_button_text_colour,
};
let js_script = format!(
"window.__PAYMENT_DETAILS = {}",
@@ -444,7 +453,10 @@ fn get_js_script(payment_details: &PaymentLinkData) -> RouterResult<String> {
}
fn get_color_scheme_css(payment_link_config: &PaymentLinkConfig) -> String {
- let background_primary_color = payment_link_config.theme.clone();
+ let background_primary_color = payment_link_config
+ .background_colour
+ .clone()
+ .unwrap_or(payment_link_config.theme.clone());
format!(
":root {{
--primary-color: {background_primary_color};
@@ -638,6 +650,9 @@ pub fn get_payment_link_config_based_on_priority(
payment_button_text,
custom_message_for_card_terms,
payment_button_colour,
+ skip_status_screen,
+ background_colour,
+ payment_button_text_colour,
) = get_payment_link_config_value!(
payment_create_link_config,
business_theme_configs,
@@ -647,6 +662,9 @@ pub fn get_payment_link_config_based_on_priority(
(payment_button_text),
(custom_message_for_card_terms),
(payment_button_colour),
+ (skip_status_screen),
+ (background_colour),
+ (payment_button_text_colour)
);
let payment_link_config =
@@ -661,6 +679,7 @@ pub fn get_payment_link_config_based_on_priority(
show_card_form_by_default,
allowed_domains,
branding_visibility,
+ skip_status_screen,
transaction_details: payment_create_link_config.as_ref().and_then(
|payment_link_config| payment_link_config.theme_config.transaction_details.clone(),
),
@@ -669,6 +688,8 @@ pub fn get_payment_link_config_based_on_priority(
payment_button_text,
custom_message_for_card_terms,
payment_button_colour,
+ background_colour,
+ payment_button_text_colour,
};
Ok((payment_link_config, domain_name))
@@ -774,6 +795,9 @@ pub async fn get_payment_link_status(
payment_button_text: None,
custom_message_for_card_terms: None,
payment_button_colour: None,
+ skip_status_screen: None,
+ background_colour: None,
+ payment_button_text_colour: None,
}
};
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 a73067a5bc..811ae799d0 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
@@ -307,8 +307,9 @@ function initializeEventListeners(paymentDetails) {
}
if (submitButtonNode instanceof HTMLButtonElement) {
- submitButtonNode.style.color = contrastBWColor;
- submitButtonNode.style.backgroundColor = paymentDetails.payment_button_colour || primaryColor;
+ var chosenColor = paymentDetails.payment_button_colour || primaryColor;
+ submitButtonNode.style.color = paymentDetails.payment_button_text_colour || invert(chosenColor, true);
+ submitButtonNode.style.backgroundColor = chosenColor;
}
if (hyperCheckoutCartImageNode instanceof HTMLDivElement) {
@@ -442,9 +443,25 @@ function handleSubmit(e) {
} else {
showMessage(translations.unexpectedError);
}
+ } else if (paymentDetails.skip_status_screen) {
+ // Form query params
+ var queryParams = {
+ payment_id: paymentDetails.payment_id,
+ status: result.status
+ };
+ var url = new URL(paymentDetails.return_url);
+ var params = new URLSearchParams(url.search);
+ // Attach query params to return_url
+ for (var key in queryParams) {
+ if (queryParams.hasOwnProperty(key)) {
+ params.set(key, queryParams[key]);
+ }
+ }
+ url.search = params.toString();
+ window.top.location.href = url.toString();
} else {
redirectToStatus();
- }
+ }
})
.catch(function (error) {
console.error("Error confirming payment_intent", error);
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index ff4e6fe56a..ad56394c5f 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -4410,6 +4410,9 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
payment_button_text: config.payment_button_text,
custom_message_for_card_terms: config.custom_message_for_card_terms,
payment_button_colour: config.payment_button_colour,
+ skip_status_screen: config.skip_status_screen,
+ background_colour: config.background_colour,
+ payment_button_text_colour: config.payment_button_text_colour,
}
}
}
@@ -4475,6 +4478,9 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>
payment_button_text: config.payment_button_text,
custom_message_for_card_terms: config.custom_message_for_card_terms,
payment_button_colour: config.payment_button_colour,
+ skip_status_screen: config.skip_status_screen,
+ background_colour: config.background_colour,
+ payment_button_text_colour: config.payment_button_text_colour,
}
}
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 4da26061e4..8938461eec 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -2156,8 +2156,11 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
.background_image
.map(|background_image| background_image.foreign_into()),
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,
payment_button_colour: item.payment_button_colour,
+ background_colour: item.background_colour,
+ payment_button_text_colour: item.payment_button_text_colour,
}
}
}
@@ -2181,8 +2184,11 @@ impl ForeignFrom<diesel_models::business_profile::PaymentLinkConfigRequest>
.background_image
.map(|background_image| background_image.foreign_into()),
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,
payment_button_colour: item.payment_button_colour,
+ background_colour: item.background_colour,
+ payment_button_text_colour: item.payment_button_text_colour,
}
}
}