diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 0edeb537dc1c..15103188df57 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -11993,7 +11993,8 @@ "sdk_layout", "display_sdk_only", "enabled_saved_payment_method", - "hide_card_nickname_field" + "hide_card_nickname_field", + "show_card_form_by_default" ], "properties": { "theme": { @@ -12024,6 +12025,10 @@ "type": "boolean", "description": "Hide card nickname field option for payment link" }, + "show_card_form_by_default": { + "type": "boolean", + "description": "Show card form by default for payment link" + }, "allowed_domains": { "type": "array", "items": { @@ -12095,6 +12100,13 @@ "example": true, "nullable": true }, + "show_card_form_by_default": { + "type": "boolean", + "description": "Show card form by default for payment link", + "default": true, + "example": true, + "nullable": true + }, "transaction_details": { "type": "array", "items": { diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index f624b4f68dda..ecce327d7ffb 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -15170,7 +15170,8 @@ "sdk_layout", "display_sdk_only", "enabled_saved_payment_method", - "hide_card_nickname_field" + "hide_card_nickname_field", + "show_card_form_by_default" ], "properties": { "theme": { @@ -15201,6 +15202,10 @@ "type": "boolean", "description": "Hide card nickname field option for payment link" }, + "show_card_form_by_default": { + "type": "boolean", + "description": "Show card form by default for payment link" + }, "allowed_domains": { "type": "array", "items": { @@ -15272,6 +15277,13 @@ "example": true, "nullable": true }, + "show_card_form_by_default": { + "type": "boolean", + "description": "Show card form by default for payment link", + "default": true, + "example": true, + "nullable": true + }, "transaction_details": { "type": "array", "items": { diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs index 8ba50649236b..7e1465c9d929 100644 --- a/crates/api_models/src/admin.rs +++ b/crates/api_models/src/admin.rs @@ -2673,6 +2673,9 @@ pub struct PaymentLinkConfigRequest { /// Hide card nickname field option for payment link #[schema(default = false, example = true)] pub hide_card_nickname_field: Option, + /// Show card form by default for payment link + #[schema(default = true, example = true)] + pub show_card_form_by_default: Option, /// Dynamic details related to merchant to be rendered in payment link pub transaction_details: Option>, } @@ -2718,6 +2721,8 @@ pub struct PaymentLinkConfig { pub enabled_saved_payment_method: bool, /// Hide card nickname field option for payment link pub hide_card_nickname_field: bool, + /// Show card form by default for payment link + pub show_card_form_by_default: bool, /// A list of allowed domains (glob patterns) where this link can be embedded / opened from pub allowed_domains: Option>, /// Dynamic details related to merchant to be rendered in payment link diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 45b9bac53acb..fb60937e9b13 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -6670,6 +6670,7 @@ pub struct PaymentLinkDetails { pub sdk_layout: String, pub display_sdk_only: bool, pub hide_card_nickname_field: bool, + pub show_card_form_by_default: bool, pub locale: Option, pub transaction_details: Option>, } @@ -6678,6 +6679,7 @@ pub struct PaymentLinkDetails { pub struct SecurePaymentLinkDetails { pub enabled_saved_payment_method: bool, pub hide_card_nickname_field: bool, + pub show_card_form_by_default: bool, #[serde(flatten)] pub payment_link_details: PaymentLinkDetails, } diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs index f4c7b86850eb..1f8209397ae1 100644 --- a/crates/diesel_models/src/business_profile.rs +++ b/crates/diesel_models/src/business_profile.rs @@ -543,6 +543,7 @@ pub struct PaymentLinkConfigRequest { pub display_sdk_only: Option, pub enabled_saved_payment_method: Option, pub hide_card_nickname_field: Option, + pub show_card_form_by_default: Option, } common_utils::impl_to_sql_from_sql_json!(BusinessPaymentLinkConfig); diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs index 7826e2dadd25..9f0bf17230da 100644 --- a/crates/diesel_models/src/payment_intent.rs +++ b/crates/diesel_models/src/payment_intent.rs @@ -156,6 +156,8 @@ pub struct PaymentLinkConfigRequestForPayments { pub enabled_saved_payment_method: Option, /// Hide card nickname field option for payment link pub hide_card_nickname_field: Option, + /// Show card form by default for payment link + pub show_card_form_by_default: Option, /// Dynamic details related to merchant to be rendered in payment link pub transaction_details: Option>, } diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs index 64c6c97a0fd0..d94e921c120b 100644 --- a/crates/hyperswitch_domain_models/src/lib.rs +++ b/crates/hyperswitch_domain_models/src/lib.rs @@ -192,6 +192,7 @@ impl ApiModelToDieselModelConvertor display_sdk_only: item.display_sdk_only, enabled_saved_payment_method: item.enabled_saved_payment_method, hide_card_nickname_field: item.hide_card_nickname_field, + show_card_form_by_default: item.show_card_form_by_default, transaction_details: item.transaction_details.map(|transaction_details| { transaction_details .into_iter() @@ -213,6 +214,7 @@ impl ApiModelToDieselModelConvertor display_sdk_only, enabled_saved_payment_method, hide_card_nickname_field, + show_card_form_by_default, transaction_details, } = self; api_models::admin::PaymentLinkConfigRequest { @@ -223,6 +225,7 @@ impl ApiModelToDieselModelConvertor display_sdk_only, enabled_saved_payment_method, hide_card_nickname_field, + show_card_form_by_default, transaction_details: transaction_details.map(|transaction_details| { transaction_details .into_iter() diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs index 51385593e9d1..9b02c67ce6a7 100644 --- a/crates/router/src/consts.rs +++ b/crates/router/src/consts.rs @@ -153,6 +153,9 @@ pub const DEFAULT_ALLOWED_DOMAINS: Option> = None; /// Default hide card nickname field pub const DEFAULT_HIDE_CARD_NICKNAME_FIELD: bool = false; +/// Show card form by default for payment links +pub const DEFAULT_SHOW_CARD_FORM: bool = true; + /// Default bool for Display sdk only pub const DEFAULT_DISPLAY_SDK_ONLY: bool = false; diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index 91829e56f2cc..3555eb1193e7 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -24,7 +24,7 @@ use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, - DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, + DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, @@ -126,6 +126,7 @@ pub async fn form_payment_link_data( display_sdk_only: DEFAULT_DISPLAY_SDK_ONLY, enabled_saved_payment_method: DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, hide_card_nickname_field: DEFAULT_HIDE_CARD_NICKNAME_FIELD, + show_card_form_by_default: DEFAULT_SHOW_CARD_FORM, allowed_domains: DEFAULT_ALLOWED_DOMAINS, transaction_details: None, } @@ -267,6 +268,7 @@ pub async fn form_payment_link_data( sdk_layout: payment_link_config.sdk_layout.clone(), display_sdk_only: payment_link_config.display_sdk_only, hide_card_nickname_field: payment_link_config.hide_card_nickname_field, + show_card_form_by_default: payment_link_config.show_card_form_by_default, locale, transaction_details: payment_link_config.transaction_details.clone(), }; @@ -325,6 +327,7 @@ pub async fn initiate_secure_payment_link_flow( let secure_payment_link_details = api_models::payments::SecurePaymentLinkDetails { enabled_saved_payment_method: payment_link_config.enabled_saved_payment_method, hide_card_nickname_field: payment_link_config.hide_card_nickname_field, + show_card_form_by_default: payment_link_config.show_card_form_by_default, payment_link_details: *link_details.to_owned(), }; let js_script = format!( @@ -618,6 +621,7 @@ pub fn get_payment_link_config_based_on_priority( display_sdk_only, enabled_saved_payment_method, hide_card_nickname_field, + show_card_form_by_default, ) = get_payment_link_config_value!( payment_create_link_config, business_theme_configs, @@ -630,7 +634,8 @@ pub fn get_payment_link_config_based_on_priority( enabled_saved_payment_method, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD ), - (hide_card_nickname_field, DEFAULT_HIDE_CARD_NICKNAME_FIELD) + (hide_card_nickname_field, DEFAULT_HIDE_CARD_NICKNAME_FIELD), + (show_card_form_by_default, DEFAULT_SHOW_CARD_FORM) ); let payment_link_config = PaymentLinkConfig { theme, @@ -640,6 +645,7 @@ pub fn get_payment_link_config_based_on_priority( display_sdk_only, enabled_saved_payment_method, hide_card_nickname_field, + show_card_form_by_default, allowed_domains, transaction_details: payment_create_link_config .and_then(|payment_link_config| payment_link_config.theme_config.transaction_details), @@ -743,6 +749,7 @@ pub async fn get_payment_link_status( display_sdk_only: DEFAULT_DISPLAY_SDK_ONLY, enabled_saved_payment_method: DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, hide_card_nickname_field: DEFAULT_HIDE_CARD_NICKNAME_FIELD, + show_card_form_by_default: DEFAULT_SHOW_CARD_FORM, allowed_domains: DEFAULT_ALLOWED_DOMAINS, transaction_details: 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 1264915592d6..b79e2284a567 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 @@ -56,6 +56,7 @@ function initializeSDK() { height: 55, }, }, + showCardFormByDefault: paymentDetails.show_card_form_by_default, hideCardNicknameField: false, }; // @ts-ignore 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 5080970ce3c5..4bddc6904be5 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 @@ -81,6 +81,7 @@ if (!isFramed) { }, }, hideCardNicknameField: hideCardNicknameField, + showCardFormByDefault: paymentDetails.show_card_form_by_default, }; // @ts-ignore unifiedCheckout = widgets.create("payment", unifiedCheckoutOptions); diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 4baeade05abf..9e0557d5b3eb 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -3699,6 +3699,7 @@ impl ForeignFrom display_sdk_only: config.display_sdk_only, enabled_saved_payment_method: config.enabled_saved_payment_method, hide_card_nickname_field: config.hide_card_nickname_field, + show_card_form_by_default: config.show_card_form_by_default, transaction_details: config.transaction_details.map(|transaction_details| { transaction_details .iter() @@ -3752,6 +3753,7 @@ impl ForeignFrom display_sdk_only: config.display_sdk_only, enabled_saved_payment_method: config.enabled_saved_payment_method, hide_card_nickname_field: config.hide_card_nickname_field, + show_card_form_by_default: config.show_card_form_by_default, transaction_details: config.transaction_details.map(|transaction_details| { transaction_details .iter() diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 2ff243ec4b92..4ae026689579 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -1945,6 +1945,7 @@ impl ForeignFrom display_sdk_only: item.display_sdk_only, enabled_saved_payment_method: item.enabled_saved_payment_method, hide_card_nickname_field: item.hide_card_nickname_field, + show_card_form_by_default: item.show_card_form_by_default, } } } @@ -1961,6 +1962,7 @@ impl ForeignFrom display_sdk_only: item.display_sdk_only, enabled_saved_payment_method: item.enabled_saved_payment_method, hide_card_nickname_field: item.hide_card_nickname_field, + show_card_form_by_default: item.show_card_form_by_default, transaction_details: None, } }