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_links): Verify payment method mapping for custom tnc (#10562)
Sayak Bhattacharya9d18b0d22081
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex b66f17bf7c..84c96ca471 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -16289,13 +16289,38 @@}}},- "CustomTermsByPaymentMethodTypes": {+ "CustomMessage": {"type": "object",- "description": "Custom T&C Message to be shown per payment method type",- "additionalProperties": {- "type": "string"- },- "nullable": true+ "description": "Custom T&C message content and display mode",+ "required": [+ "value"+ ],+ "properties": {+ "value": {+ "type": "string",+ "description": "The text to be shown per payment method type",+ "example": "I authorize Novalnet AG to debit my account."+ },+ "display_mode": {+ "$ref": "#/components/schemas/SdkDisplayMode"+ }+ }+ },+ "CustomTerms": {+ "type": "object",+ "description": "Custom T&C message for a specific payment method type",+ "required": [+ "payment_method_type",+ "message"+ ],+ "properties": {+ "payment_method_type": {+ "$ref": "#/components/schemas/PaymentMethodType"+ },+ "message": {+ "$ref": "#/components/schemas/CustomMessage"+ }+ }},"CustomerAcceptance": {"type": "object",@@ -24583,7 +24608,7 @@"custom_message_for_payment_method_types": {"allOf": [{- "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"+ "$ref": "#/components/schemas/PaymentMethodsConfig"}],"nullable": true@@ -24763,7 +24788,7 @@"custom_message_for_payment_method_types": {"allOf": [{- "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"+ "$ref": "#/components/schemas/PaymentMethodsConfig"}],"nullable": true@@ -25168,6 +25193,35 @@}]},+ "PaymentMethodConfig": {+ "type": "object",+ "description": "Custom T&C messages for a specific payment method",+ "required": [+ "payment_method",+ "payment_method_types"+ ],+ "properties": {+ "payment_method": {+ "$ref": "#/components/schemas/PaymentMethod"+ },+ "payment_method_types": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/CustomTerms"+ },+ "description": "Payment Method Types",+ "example": [+ {+ "message": {+ "display_mode": "custom",+ "value": "Sample message"+ },+ "payment_method_type": "credit"+ }+ ]+ }+ }+ },"PaymentMethodCreate": {"type": "object","required": [@@ -26179,6 +26233,13 @@},"additionalProperties": false},+ "PaymentMethodsConfig": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PaymentMethodConfig"+ },+ "description": "List of custom T&C messages grouped by payment method"+ },"PaymentMethodsEnabled": {"type": "object","description": "Details of all the payment methods enabled for the connector for the given merchant account",@@ -35326,6 +35387,15 @@"transaction_risk_analysis"]},+ "SdkDisplayMode": {+ "type": "string",+ "description": "Display mode options for controlling how messages are shown.",+ "enum": [+ "default_sdk_message",+ "custom_message",+ "hidden"+ ]+ },"SdkInformation": {"type": "object","description": "SDK Information if request is from SDK",diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 609af081a6..040df77c8a 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -10341,13 +10341,38 @@}}},- "CustomTermsByPaymentMethodTypes": {+ "CustomMessage": {"type": "object",- "description": "Custom T&C Message to be shown per payment method type",- "additionalProperties": {- "type": "string"- },- "nullable": true+ "description": "Custom T&C message content and display mode",+ "required": [+ "value"+ ],+ "properties": {+ "value": {+ "type": "string",+ "description": "The text to be shown per payment method type",+ "example": "I authorize Novalnet AG to debit my account."+ },+ "display_mode": {+ "$ref": "#/components/schemas/SdkDisplayMode"+ }+ }+ },+ "CustomTerms": {+ "type": "object",+ "description": "Custom T&C message for a specific payment method type",+ "required": [+ "payment_method_type",+ "message"+ ],+ "properties": {+ "payment_method_type": {+ "$ref": "#/components/schemas/PaymentMethodType"+ },+ "message": {+ "$ref": "#/components/schemas/CustomMessage"+ }+ }},"CustomerAcceptance": {"type": "object",@@ -17887,7 +17912,7 @@"custom_message_for_payment_method_types": {"allOf": [{- "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"+ "$ref": "#/components/schemas/PaymentMethodsConfig"}],"nullable": true@@ -18067,7 +18092,7 @@"custom_message_for_payment_method_types": {"allOf": [{- "$ref": "#/components/schemas/CustomTermsByPaymentMethodTypes"+ "$ref": "#/components/schemas/PaymentMethodsConfig"}],"nullable": true@@ -18410,6 +18435,35 @@}]},+ "PaymentMethodConfig": {+ "type": "object",+ "description": "Custom T&C messages for a specific payment method",+ "required": [+ "payment_method",+ "payment_method_types"+ ],+ "properties": {+ "payment_method": {+ "$ref": "#/components/schemas/PaymentMethod"+ },+ "payment_method_types": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/CustomTerms"+ },+ "description": "Payment Method Types",+ "example": [+ {+ "message": {+ "display_mode": "custom",+ "value": "Sample message"+ },+ "payment_method_type": "credit"+ }+ ]+ }+ }+ },"PaymentMethodCreate": {"type": "object","required": [@@ -19692,6 +19746,13 @@}]},+ "PaymentMethodsConfig": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PaymentMethodConfig"+ },+ "description": "List of custom T&C messages grouped by payment method"+ },"PaymentMethodsEnabled": {"type": "object","description": "Details of all the payment methods enabled for the connector for the given merchant account",@@ -25548,6 +25609,15 @@"transaction_risk_analysis"]},+ "SdkDisplayMode": {+ "type": "string",+ "description": "Display mode options for controlling how messages are shown.",+ "enum": [+ "default_sdk_message",+ "custom_message",+ "hidden"+ ]+ },"SdkInformation": {"type": "object","description": "SDK Information if request is from SDK",diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 58e9f01e5e..d7d09b6f10 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -3295,14 +3295,14 @@ pub struct BusinessPaymentLinkConfig {}impl BusinessPaymentLinkConfig {- pub fn validate(&self) -> Result<(), &str> {+ pub fn validate(&self) -> Result<(), String> {let host_domain_valid = self.domain_name.clone().map(|host_domain| link_utils::validate_strict_domain(&host_domain)).unwrap_or(true);if !host_domain_valid {- return Err("Invalid host domain name received in payment_link_config");+ return Err("Invalid host domain name received in payment_link_config".to_string());}let are_allowed_domains_valid = self@@ -3315,7 +3315,17 @@ impl BusinessPaymentLinkConfig {}).unwrap_or(true);if !are_allowed_domains_valid {- return Err("Invalid allowed domain names received in payment_link_config");+ return Err("Invalid allowed domain names received in payment_link_config".to_string());+ }++ if let Some(default_cfg) = self.default_config.as_ref() {+ default_cfg.validate()?;+ }++ if let Some(biz_cfgs) = self.business_specific_configs.as_ref() {+ for config in biz_cfgs.values() {+ config.validate()?;+ }}Ok(())@@ -3360,9 +3370,9 @@ pub struct PaymentLinkConfigRequest {/// Text for customizing message for card termspub custom_message_for_card_terms: Option<String>,/// Text for customizing message for different Payment Method Types- #[schema(value_type = Option<CustomTermsByPaymentMethodTypes>)]+ #[schema(value_type = Option<PaymentMethodsConfig>)]pub custom_message_for_payment_method_types:- Option<common_enums::CustomTermsByPaymentMethodTypes>,+ Option<common_types::payments::PaymentMethodsConfig>,/// Custom background colour for payment link's handle confirm buttonpub payment_button_colour: Option<String>,/// Skip the status screen after payment completion@@ -3393,6 +3403,15 @@ pub struct PaymentLinkConfigRequest {pub payment_test_mode: Option<bool>,}+impl PaymentLinkConfigRequest {+ pub fn validate(&self) -> Result<(), String> {+ if let Some(custom_message) = self.custom_message_for_payment_method_types.as_ref() {+ custom_message.validate().map_err(|e| e.to_string())?;+ }+ Ok(())+ }+}+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]pub struct PaymentLinkTransactionDetails {/// Key for the transaction details@@ -3465,9 +3484,9 @@ pub struct PaymentLinkConfig {/// Text for customizing message for card termspub custom_message_for_card_terms: Option<String>,/// Text for customizing message for different Payment Method Types- #[schema(value_type = Option<CustomTermsByPaymentMethodTypes>)]+ #[schema(value_type = Option<PaymentMethodsConfig>)]pub custom_message_for_payment_method_types:- Option<common_enums::CustomTermsByPaymentMethodTypes>,+ Option<common_types::payments::PaymentMethodsConfig>,/// Custom background colour for payment link's handle confirm buttonpub payment_button_colour: Option<String>,/// Skip the status screen after payment completiondiff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex c89864755b..150e908d62 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -11267,7 +11267,7 @@ pub struct PaymentLinkDetails {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>,+ Option<common_types::payments::PaymentMethodsConfig>,pub payment_button_colour: Option<String>,pub payment_button_text_colour: Option<String>,pub background_colour: Option<String>,@@ -11294,7 +11294,7 @@ pub struct SecurePaymentLinkDetails {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>,+ Option<common_types::payments::PaymentMethodsConfig>,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.rsindex a418e782de..03352586d9 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -2125,13 +2125,6 @@ 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/common_types/src/payments.rs b/crates/common_types/src/payments.rsindex 68fc8a00e5..ccc0d66c07 100644--- a/crates/common_types/src/payments.rs+++ b/crates/common_types/src/payments.rs@@ -952,3 +952,104 @@ pub struct PartnerMerchantIdentifierDetails {}impl_to_sql_from_sql_json!(PartnerMerchantIdentifierDetails);++/// List of custom T&C messages grouped by payment method+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, utoipa::ToSchema)]+pub struct PaymentMethodsConfig(+ #[schema(example = json!([+ {+ "payment_method": "card",+ "payment_method_types": [+ {+ "payment_method_type": "credit",+ "message": {+ "value": "I authorize this payment",+ "display_mode": "default_sdk_message"+ }+ }+ ]+ }+ ]))]+ pub Vec<PaymentMethodConfig>,+);++/// Custom T&C messages for a specific payment method+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, utoipa::ToSchema)]+pub struct PaymentMethodConfig {+ /// Payment Method+ #[schema(value_type = PaymentMethod, example = "card")]+ pub payment_method: common_enums::PaymentMethod,++ /// Payment Method Types+ #[schema(example = json!([+ {+ "payment_method_type": "credit",+ "message": {+ "value": "Sample message",+ "display_mode": "custom"+ }+ }+ ]))]+ #[schema(value_type = Vec<CustomTerms>)]+ pub payment_method_types: Vec<CustomTerms>,+}++/// Custom T&C message for a specific payment method type+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, utoipa::ToSchema)]+pub struct CustomTerms {+ /// Payment Method Type+ #[schema(value_type = PaymentMethodType, example = "sepa")]+ pub payment_method_type: common_enums::PaymentMethodType,++ /// The message to be shown+ #[schema(value_type = CustomMessage)]+ pub message: CustomMessage,+}++/// Custom T&C message content and display mode+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, utoipa::ToSchema)]+pub struct CustomMessage {+ /// The text to be shown per payment method type+ #[schema(value_type = String, example = "I authorize Novalnet AG to debit my account.")]+ pub value: String,++ /// The display mode for terms and conditions+ #[schema(value_type = SdkDisplayMode , example = "custom")]+ #[serde(default)]+ pub display_mode: SdkDisplayMode,+}++/// Display mode options for controlling how messages are shown.+#[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, utoipa::ToSchema)]+#[serde(rename_all = "snake_case")]+pub enum SdkDisplayMode {+ /// Display the default terms and conditions in sdk+ #[default]+ DefaultSdkMessage,+ /// Display the custom configured by the merchant+ CustomMessage,+ /// No terms and conditions to be shown+ Hidden,+}++impl PaymentMethodsConfig {+ /// Validation function for custom terms and conditions+ pub fn validate(&self) -> Result<(), errors::ValidationError> {+ for pm_config in &self.0 {+ let parent_pm = pm_config.payment_method;++ for pm_type_config in &pm_config.payment_method_types {+ let pm_type = pm_type_config.payment_method_type;++ // Check if the payment_method_type belongs to the parent payment_method+ if common_enums::PaymentMethod::from(pm_type) != parent_pm {+ return Err(errors::ValidationError::InvalidValue {+ message: "Payment Method Type '{pm_type}' does not belong to Payment Method '{parent_pm}'".to_string(),+ }+ .into());+ }+ }+ }+ Ok(())+ }+}diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex 28b54a38f7..59102aaef7 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -864,7 +864,7 @@ pub struct PaymentLinkConfigRequest {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>,+ Option<common_types::payments::PaymentMethodsConfig>,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.rsindex f8f6f4ea93..c64bd7bc0b 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -229,7 +229,7 @@ pub struct PaymentLinkConfigRequestForPayments {pub custom_message_for_card_terms: Option<String>,/// Text for customizing message for different Payment Method Typespub custom_message_for_payment_method_types:- Option<common_enums::CustomTermsByPaymentMethodTypes>,+ Option<common_types::payments::PaymentMethodsConfig>,/// Custom background colour for payment link's handle confirm buttonpub payment_button_colour: Option<String>,/// Custom text colour for payment link's handle confirm buttondiff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 70add4d845..f5fa8b4c3f 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -362,7 +362,6 @@ 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,@@ -984,6 +983,11 @@ Never share your secret api keys. Keep them guarded and secure.api_models::subscription::CancelSubscriptionRequest,api_models::subscription::CancelSubscriptionResponse,api_models::subscription::SubscriptionItemType,+ common_types::payments::SdkDisplayMode,+ common_types::payments::CustomMessage,+ common_types::payments::CustomTerms,+ common_types::payments::PaymentMethodConfig,+ common_types::payments::PaymentMethodsConfig,)),modifiers(&SecurityAddon))]diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex c9e3e5c06f..0cf67c7ba3 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -284,7 +284,6 @@ 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,@@ -850,6 +849,11 @@ Never share your secret api keys. Keep them guarded and secure.api_models::tokenization::GenericTokenizationResponse,api_models::tokenization::DeleteTokenDataRequest,api_models::tokenization::DeleteTokenDataResponse,+ common_types::payments::PaymentMethodsConfig,+ common_types::payments::PaymentMethodConfig,+ common_types::payments::CustomTerms,+ common_types::payments::CustomMessage,+ common_types::payments::SdkDisplayMode,)),modifiers(&SecurityAddon))]diff --git a/crates/payment_link/src/js_generator.rs b/crates/payment_link/src/js_generator.rsindex 4c637576c9..1b9f0dcd7b 100644--- a/crates/payment_link/src/js_generator.rs+++ b/crates/payment_link/src/js_generator.rs@@ -1,5 +1,5 @@-use api_models::payments::PaymentLinkData;-use error_stack::{Result, ResultExt};+use error_stack::Result;+use serde_json::Value;#[derive(Debug, thiserror::Error)]pub enum PaymentLinkError {@@ -7,10 +7,65 @@ pub enum PaymentLinkError {SerializationFailed,}-pub fn get_js_script(payment_details: &PaymentLinkData) -> Result<String, PaymentLinkError> {- let payment_details_str = serde_json::to_string(payment_details)- .change_context(PaymentLinkError::SerializationFailed)- .attach_printable("Failed to serialize PaymentLinkData")?;+/// Convert snake_case to camelCase+fn camel_case_key(key: &str) -> String {+ let mut out = String::new();+ let mut uppercase = false;++ for c in key.chars() {+ if c == '_' {+ uppercase = true;+ } else if uppercase {+ out.push(c.to_ascii_uppercase());+ uppercase = false;+ } else {+ out.push(c);+ }+ }++ out+}++/// Convert JSON keys to camelCase+fn camel_case_json(value: &mut Value) {+ match value {+ Value::Object(map) => {+ let keys: Vec<String> = map.keys().cloned().collect();+ for k in keys {+ if let Some(mut v) = map.remove(&k) {+ camel_case_json(&mut v);+ map.insert(camel_case_key(&k), v);+ }+ }+ }+ Value::Array(arr) => {+ for v in arr {+ camel_case_json(v);+ }+ }+ _ => {}+ }+}++/// Only convert the `custom_message_for_payment_method_types` field to camelCase+pub fn convert_custom_message_keys_to_camel(value: &mut Value) {+ if let Some(custom_msg) = value.get_mut("custom_message_for_payment_method_types") {+ camel_case_json(custom_msg);+ }+}++pub fn get_js_script(+ payment_details: &api_models::payments::PaymentLinkData,+) -> Result<String, PaymentLinkError> {+ let mut json =+ serde_json::to_value(payment_details).map_err(|_| PaymentLinkError::SerializationFailed)?;++ // Apply camelCase only on the custom_message_for_payment_method_types field+ convert_custom_message_keys_to_camel(&mut json);++ let payment_details_str =+ serde_json::to_string(&json).map_err(|_| PaymentLinkError::SerializationFailed)?;let url_encoded_str = urlencoding::encode(&payment_details_str);- Ok(format!("window.__PAYMENT_DETAILS = '{url_encoded_str}';"))++ Ok(format!("window.__PAYMENT_DETAILS = '{}';", url_encoded_str))}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 e927076c3a..b7a61e6111 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,7 +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,+ paymentMethodsConfig: 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.jsindex e0a3abb6db..967ef3c8c9 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,7 +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,+ paymentMethodsConfig: 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/routes/payments.rs b/crates/router/src/routes/payments.rsindex 3dff5b8182..f62096103d 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -48,6 +48,19 @@ pub async fn payments_create(return api::log_and_return_error_response(err.into());};+ if let Err(err) = payload+ .payment_link_config+ .as_ref()+ .map(|cfg| {+ cfg.theme_config+ .validate()+ .map_err(|message| errors::ApiErrorResponse::InvalidRequestData { message })+ })+ .transpose()+ {+ return api::log_and_return_error_response(err.into());+ };+if let Some(api_enums::CaptureMethod::Scheduled) = payload.capture_method {return http_not_implemented();};diff --git a/crates/router/src/routes/profiles.rs b/crates/router/src/routes/profiles.rsindex 6b201fc1df..640c72f274 100644--- a/crates/router/src/routes/profiles.rs+++ b/crates/router/src/routes/profiles.rs@@ -19,6 +19,18 @@ pub async fn profile_create(let flow = Flow::ProfileCreate;let payload = json_payload.into_inner();let merchant_id = path.into_inner();+ if let Err(api_error) = payload+ .payment_link_config+ .as_ref()+ .map(|config| {+ config+ .validate()+ .map_err(|err| errors::ApiErrorResponse::InvalidRequestData { message: err })+ })+ .transpose()+ {+ return api::log_and_return_error_response(api_error.into());+ }if let Err(api_error) = payload.webhook_details.as_ref()@@ -202,6 +214,19 @@ pub async fn profile_update(let flow = Flow::ProfileUpdate;let (merchant_id, profile_id) = path.into_inner();let payload = json_payload.into_inner();+ if let Err(api_error) = payload+ .payment_link_config+ .as_ref()+ .map(|config| {+ config+ .validate()+ .map_err(|err| errors::ApiErrorResponse::InvalidRequestData { message: err })+ })+ .transpose()+ {+ return api::log_and_return_error_response(api_error.into());+ }+if let Err(api_error) = payload.webhook_details.as_ref()