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(core): payment links - add support for custom background image and layout in details section (#6725)
Kashifd11d87408d0c
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 6c3e9f5072..0f62f11127 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -5537,6 +5537,11 @@"description": "A list of allowed domains (glob patterns) where this link can be embedded / opened from","uniqueItems": true,"nullable": true+ },+ "branding_visibility": {+ "type": "boolean",+ "description": "Toggle for HyperSwitch branding visibility",+ "nullable": true}}}@@ -7882,6 +7887,61 @@}}},+ "ElementPosition": {+ "type": "string",+ "enum": [+ "left",+ "top left",+ "top",+ "top right",+ "right",+ "bottom right",+ "bottom",+ "bottom left",+ "center"+ ]+ },+ "ElementSize": {+ "oneOf": [+ {+ "type": "object",+ "required": [+ "Variants"+ ],+ "properties": {+ "Variants": {+ "$ref": "#/components/schemas/SizeVariants"+ }+ }+ },+ {+ "type": "object",+ "required": [+ "Percentage"+ ],+ "properties": {+ "Percentage": {+ "type": "integer",+ "format": "int32",+ "minimum": 0+ }+ }+ },+ {+ "type": "object",+ "required": [+ "Pixels"+ ],+ "properties": {+ "Pixels": {+ "type": "integer",+ "format": "int32",+ "minimum": 0+ }+ }+ }+ ]+ },"EnablePaymentLinkRequest": {"type": "string","description": "Whether payment link is requested to be enabled or not for this transaction",@@ -12540,6 +12600,35 @@}}},+ "PaymentLinkBackgroundImageConfig": {+ "type": "object",+ "required": [+ "url"+ ],+ "properties": {+ "url": {+ "type": "string",+ "description": "URL of the image",+ "example": "https://hyperswitch.io/favicon.ico"+ },+ "position": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ElementPosition"+ }+ ],+ "nullable": true+ },+ "size": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ElementSize"+ }+ ],+ "nullable": true+ }+ }+ },"PaymentLinkConfig": {"type": "object","required": [@@ -12601,6 +12690,27 @@},"description": "Dynamic details related to merchant to be rendered in payment link","nullable": true+ },+ "background_image": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkBackgroundImageConfig"+ }+ ],+ "nullable": true+ },+ "details_layout": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkDetailsLayout"+ }+ ],+ "nullable": true+ },+ "branding_visibility": {+ "type": "boolean",+ "description": "Toggle for HyperSwitch branding visibility",+ "nullable": true}}},@@ -12670,9 +12780,32 @@},"description": "Dynamic details related to merchant to be rendered in payment link","nullable": true+ },+ "background_image": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkBackgroundImageConfig"+ }+ ],+ "nullable": true+ },+ "details_layout": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkDetailsLayout"+ }+ ],+ "nullable": true}}},+ "PaymentLinkDetailsLayout": {+ "type": "string",+ "enum": [+ "layout1",+ "layout2"+ ]+ },"PaymentLinkInitiateRequest": {"type": "object","required": [@@ -20016,6 +20149,13 @@}]},+ "SizeVariants": {+ "type": "string",+ "enum": [+ "cover",+ "contain"+ ]+ },"StraightThroughAlgorithm": {"oneOf": [{diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex ce383f2406..8b06e167e2 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -7974,6 +7974,11 @@"description": "A list of allowed domains (glob patterns) where this link can be embedded / opened from","uniqueItems": true,"nullable": true+ },+ "branding_visibility": {+ "type": "boolean",+ "description": "Toggle for HyperSwitch branding visibility",+ "nullable": true}}}@@ -10268,6 +10273,61 @@"none"]},+ "ElementPosition": {+ "type": "string",+ "enum": [+ "left",+ "top left",+ "top",+ "top right",+ "right",+ "bottom right",+ "bottom",+ "bottom left",+ "center"+ ]+ },+ "ElementSize": {+ "oneOf": [+ {+ "type": "object",+ "required": [+ "Variants"+ ],+ "properties": {+ "Variants": {+ "$ref": "#/components/schemas/SizeVariants"+ }+ }+ },+ {+ "type": "object",+ "required": [+ "Percentage"+ ],+ "properties": {+ "Percentage": {+ "type": "integer",+ "format": "int32",+ "minimum": 0+ }+ }+ },+ {+ "type": "object",+ "required": [+ "Pixels"+ ],+ "properties": {+ "Pixels": {+ "type": "integer",+ "format": "int32",+ "minimum": 0+ }+ }+ }+ ]+ },"EnabledPaymentMethod": {"type": "object","description": "Object for EnabledPaymentMethod",@@ -15255,6 +15315,35 @@}}},+ "PaymentLinkBackgroundImageConfig": {+ "type": "object",+ "required": [+ "url"+ ],+ "properties": {+ "url": {+ "type": "string",+ "description": "URL of the image",+ "example": "https://hyperswitch.io/favicon.ico"+ },+ "position": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ElementPosition"+ }+ ],+ "nullable": true+ },+ "size": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ElementSize"+ }+ ],+ "nullable": true+ }+ }+ },"PaymentLinkConfig": {"type": "object","required": [@@ -15316,6 +15405,27 @@},"description": "Dynamic details related to merchant to be rendered in payment link","nullable": true+ },+ "background_image": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkBackgroundImageConfig"+ }+ ],+ "nullable": true+ },+ "details_layout": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkDetailsLayout"+ }+ ],+ "nullable": true+ },+ "branding_visibility": {+ "type": "boolean",+ "description": "Toggle for HyperSwitch branding visibility",+ "nullable": true}}},@@ -15385,9 +15495,32 @@},"description": "Dynamic details related to merchant to be rendered in payment link","nullable": true+ },+ "background_image": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkBackgroundImageConfig"+ }+ ],+ "nullable": true+ },+ "details_layout": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkDetailsLayout"+ }+ ],+ "nullable": true}}},+ "PaymentLinkDetailsLayout": {+ "type": "string",+ "enum": [+ "layout1",+ "layout2"+ ]+ },"PaymentLinkInitiateRequest": {"type": "object","required": [@@ -23934,6 +24067,13 @@}]},+ "SizeVariants": {+ "type": "string",+ "enum": [+ "cover",+ "contain"+ ]+ },"StraightThroughAlgorithm": {"oneOf": [{diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 82f9b65b27..d4432b7021 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -179,7 +179,7 @@ card.credit = { connector_list = "cybersource" } # Update Mandate supcard.debit = { connector_list = "cybersource" } # Update Mandate supported payment method type and connector for card[network_transaction_id_supported_connectors]-connector_list = "stripe,adyen,cybersource"+connector_list = "adyen"[payouts]payout_eligibility = true # Defaults the eligibility of a payout method to true in case connector does not provide checks for payout eligibilitydiff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 769ef59280..226d397405 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -2667,6 +2667,8 @@ pub struct BusinessPaymentLinkConfig {/// A list of allowed domains (glob patterns) where this link can be embedded / opened from#[schema(value_type = Option<HashSet<String>>)]pub allowed_domains: Option<HashSet<String>>,+ /// Toggle for HyperSwitch branding visibility+ pub branding_visibility: Option<bool>,}impl BusinessPaymentLinkConfig {@@ -2725,6 +2727,11 @@ pub struct PaymentLinkConfigRequest {pub show_card_form_by_default: Option<bool>,/// Dynamic details related to merchant to be rendered in payment linkpub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,+ /// Configurations for the background image for details section+ pub background_image: Option<PaymentLinkBackgroundImageConfig>,+ /// Custom layout for details section+ #[schema(value_type = Option<PaymentLinkDetailsLayout>, example = "layout1")]+ pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,}#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]@@ -2752,6 +2759,19 @@ pub struct TransactionDetailsUiConfiguration {pub is_value_bold: Option<bool>,}+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]+pub struct PaymentLinkBackgroundImageConfig {+ /// URL of the image+ #[schema(value_type = String, example = "https://hyperswitch.io/favicon.ico")]+ pub url: common_utils::types::Url,+ /// Position of the image in the UI+ #[schema(value_type = Option<ElementPosition>, example = "top-left")]+ pub position: Option<api_enums::ElementPosition>,+ /// Size of the image in the UI+ #[schema(value_type = Option<ElementSize>, example = "contain")]+ pub size: Option<api_enums::ElementSize>,+}+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, ToSchema)]pub struct PaymentLinkConfig {/// custom theme for the payment link@@ -2774,6 +2794,13 @@ pub struct PaymentLinkConfig {pub allowed_domains: Option<HashSet<String>>,/// Dynamic details related to merchant to be rendered in payment linkpub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,+ /// Configurations for the background image for details section+ pub background_image: Option<PaymentLinkBackgroundImageConfig>,+ /// Custom layout for details section+ #[schema(value_type = Option<PaymentLinkDetailsLayout>, example = "layout1")]+ pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,+ /// Toggle for HyperSwitch branding visibility+ pub branding_visibility: Option<bool>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 2114bc9f6c..83246d944a 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -6856,6 +6856,9 @@ pub struct PaymentLinkDetails {pub show_card_form_by_default: bool,pub locale: Option<String>,pub transaction_details: Option<Vec<admin::PaymentLinkTransactionDetails>>,+ pub background_image: Option<admin::PaymentLinkBackgroundImageConfig>,+ pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,+ pub branding_visibility: Option<bool>,}#[derive(Debug, serde::Serialize, Clone)]diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 88c3b68467..2a74983f25 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -1,8 +1,10 @@mod payments;+mod ui;use std::num::{ParseFloatError, TryFromIntError};pub use payments::ProductType;use serde::{Deserialize, Serialize};+pub use ui::*;use utoipa::ToSchema;pub use super::connector_enums::RoutableConnectors;diff --git a/crates/common_enums/src/enums/ui.rs b/crates/common_enums/src/enums/ui.rsnew file mode 100644index 0000000000..aec6c7ed64--- /dev/null+++ b/crates/common_enums/src/enums/ui.rs@@ -0,0 +1,149 @@+use std::fmt;++use serde::{de::Visitor, Deserialize, Deserializer, Serialize};+use utoipa::ToSchema;++#[derive(+ Clone,+ Copy,+ Debug,+ Default,+ Eq,+ Hash,+ PartialEq,+ Serialize,+ Deserialize,+ strum::Display,+ strum::EnumString,+ ToSchema,+)]+#[router_derive::diesel_enum(storage_type = "db_enum")]+#[serde(rename_all = "lowercase")]+pub enum ElementPosition {+ Left,+ #[default]+ #[serde(rename = "top left")]+ TopLeft,+ Top,+ #[serde(rename = "top right")]+ TopRight,+ Right,+ #[serde(rename = "bottom right")]+ BottomRight,+ Bottom,+ #[serde(rename = "bottom left")]+ BottomLeft,+ Center,+}++#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, strum::Display, strum::EnumString, ToSchema)]+#[router_derive::diesel_enum(storage_type = "db_enum")]+pub enum ElementSize {+ Variants(SizeVariants),+ Percentage(u32),+ Pixels(u32),+}++#[derive(+ Clone,+ Copy,+ Debug,+ Default,+ Eq,+ Hash,+ PartialEq,+ Serialize,+ Deserialize,+ strum::Display,+ strum::EnumString,+ ToSchema,+)]+#[router_derive::diesel_enum(storage_type = "db_enum")]+#[serde(rename_all = "lowercase")]+#[strum(serialize_all = "lowercase")]+pub enum SizeVariants {+ #[default]+ Cover,+ Contain,+}++#[derive(+ Clone,+ Copy,+ Debug,+ Default,+ Eq,+ Hash,+ PartialEq,+ Serialize,+ Deserialize,+ strum::Display,+ strum::EnumString,+ ToSchema,+)]+#[router_derive::diesel_enum(storage_type = "db_enum")]+#[serde(rename_all = "lowercase")]+#[strum(serialize_all = "lowercase")]+pub enum PaymentLinkDetailsLayout {+ #[default]+ Layout1,+ Layout2,+}++impl<'de> Deserialize<'de> for ElementSize {+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>+ where+ D: Deserializer<'de>,+ {+ struct ElementSizeVisitor;++ impl Visitor<'_> for ElementSizeVisitor {+ type Value = ElementSize;++ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {+ formatter.write_str("a string with possible values - contain, cover or values in percentage or pixels. For eg: 48px or 50%")+ }++ fn visit_str<E>(self, value: &str) -> Result<ElementSize, E>+ where+ E: serde::de::Error,+ {+ if let Some(percent) = value.strip_suffix('%') {+ percent+ .parse::<u32>()+ .map(ElementSize::Percentage)+ .map_err(E::custom)+ } else if let Some(px) = value.strip_suffix("px") {+ px.parse::<u32>()+ .map(ElementSize::Pixels)+ .map_err(E::custom)+ } else {+ match value {+ "cover" => Ok(ElementSize::Variants(SizeVariants::Cover)),+ "contain" => Ok(ElementSize::Variants(SizeVariants::Contain)),+ _ => Err(E::custom("invalid size variant")),+ }+ }+ }+ }++ deserializer.deserialize_str(ElementSizeVisitor)+ }+}++impl Serialize for ElementSize {+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>+ where+ S: serde::ser::Serializer,+ {+ match self {+ Self::Variants(variant) => serializer.serialize_str(variant.to_string().as_str()),+ Self::Pixels(pixel_count) => {+ serializer.serialize_str(format!("{}px", pixel_count).as_str())+ }+ Self::Percentage(pixel_count) => {+ serializer.serialize_str(format!("{}%", pixel_count).as_str())+ }+ }+ }+}diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex 0cae67873d..bafd189720 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -556,6 +556,7 @@ pub struct BusinessPaymentLinkConfig {pub default_config: Option<PaymentLinkConfigRequest>,pub business_specific_configs: Option<HashMap<String, PaymentLinkConfigRequest>>,pub allowed_domains: Option<HashSet<String>>,+ pub branding_visibility: Option<bool>,}#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]@@ -568,6 +569,15 @@ pub struct PaymentLinkConfigRequest {pub enabled_saved_payment_method: Option<bool>,pub hide_card_nickname_field: Option<bool>,pub show_card_form_by_default: Option<bool>,+ pub background_image: Option<PaymentLinkBackgroundImageConfig>,+ pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,+}++#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq)]+pub struct PaymentLinkBackgroundImageConfig {+ pub url: common_utils::types::Url,+ pub position: Option<common_enums::ElementPosition>,+ pub size: Option<common_enums::ElementSize>,}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.rsindex b29da50d0a..8d037c5356 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -4,13 +4,13 @@ use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;-use crate::enums as storage_enums;#[cfg(feature = "v1")]use crate::schema::payment_intent;#[cfg(feature = "v2")]use crate::schema_v2::payment_intent;#[cfg(feature = "v2")]use crate::types::{FeatureMetadata, OrderDetailsWithAmount};+use crate::{business_profile::PaymentLinkBackgroundImageConfig, enums as storage_enums};#[cfg(feature = "v2")]#[derive(Clone, Debug, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable)]@@ -161,6 +161,10 @@ pub struct PaymentLinkConfigRequestForPayments {pub show_card_form_by_default: Option<bool>,/// Dynamic details related to merchant to be rendered in payment linkpub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,+ /// Configurations for the background image for details section+ pub background_image: Option<PaymentLinkBackgroundImageConfig>,+ /// Custom layout for details section+ pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,}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 31732e1328..0e8722644b 100644--- a/crates/hyperswitch_domain_models/src/lib.rs+++ b/crates/hyperswitch_domain_models/src/lib.rs@@ -193,6 +193,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>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,+ details_layout: item.details_layout,transaction_details: item.transaction_details.map(|transaction_details| {transaction_details.into_iter()@@ -203,6 +204,11 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>}).collect()}),+ background_image: item.background_image.map(|background_image| {+ diesel_models::business_profile::PaymentLinkBackgroundImageConfig::convert_from(+ background_image,+ )+ }),}}fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {@@ -216,6 +222,8 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>hide_card_nickname_field,show_card_form_by_default,transaction_details,+ background_image,+ details_layout,} = self;api_models::admin::PaymentLinkConfigRequest {theme,@@ -226,12 +234,15 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>enabled_saved_payment_method,hide_card_nickname_field,show_card_form_by_default,+ details_layout,transaction_details: transaction_details.map(|transaction_details| {transaction_details.into_iter().map(|transaction_detail| transaction_detail.convert_back()).collect()}),+ background_image: background_image+ .map(|background_image| background_image.convert_back()),}}}@@ -264,6 +275,31 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkTransactionDet}}+#[cfg(feature = "v2")]+impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkBackgroundImageConfig>+ for diesel_models::business_profile::PaymentLinkBackgroundImageConfig+{+ fn convert_from(from: api_models::admin::PaymentLinkBackgroundImageConfig) -> Self {+ Self {+ url: from.url,+ position: from.position,+ size: from.size,+ }+ }+ fn convert_back(self) -> api_models::admin::PaymentLinkBackgroundImageConfig {+ let Self {+ url,+ position,+ size,+ } = self;+ api_models::admin::PaymentLinkBackgroundImageConfig {+ url,+ position,+ size,+ }+ }+}+#[cfg(feature = "v2")]impl ApiModelToDieselModelConvertor<api_models::admin::TransactionDetailsUiConfiguration>for diesel_models::TransactionDetailsUiConfigurationdiff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex d50bf863b5..68b0893bcc 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -286,6 +286,10 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::ReconStatus,api_models::enums::ConnectorStatus,api_models::enums::AuthorizationStatus,+ api_models::enums::ElementPosition,+ api_models::enums::ElementSize,+ api_models::enums::SizeVariants,+ api_models::enums::PaymentLinkDetailsLayout,api_models::enums::PaymentMethodStatus,api_models::enums::UIWidgetFormLayout,api_models::admin::MerchantConnectorCreate,@@ -305,6 +309,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::admin::ProfileCreate,api_models::admin::ProfileResponse,api_models::admin::BusinessPaymentLinkConfig,+ api_models::admin::PaymentLinkBackgroundImageConfig,api_models::admin::PaymentLinkConfigRequest,api_models::admin::PaymentLinkConfig,api_models::admin::PaymentLinkTransactionDetails,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 688d749d5d..e3c9ef0b01 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -247,6 +247,10 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::ReconStatus,api_models::enums::ConnectorStatus,api_models::enums::AuthorizationStatus,+ api_models::enums::ElementPosition,+ api_models::enums::ElementSize,+ api_models::enums::SizeVariants,+ api_models::enums::PaymentLinkDetailsLayout,api_models::enums::PaymentMethodStatus,api_models::enums::OrderFulfillmentTimeOrigin,api_models::enums::UIWidgetFormLayout,@@ -267,6 +271,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::admin::ProfileCreate,api_models::admin::ProfileResponse,api_models::admin::BusinessPaymentLinkConfig,+ api_models::admin::PaymentLinkBackgroundImageConfig,api_models::admin::PaymentLinkConfigRequest,api_models::admin::PaymentLinkConfig,api_models::admin::PaymentLinkTransactionDetails,diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex bc66461e81..f9522b04d9 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -35,7 +35,7 @@ use crate::{api::payment_link::PaymentLinkResponseExt,domain,storage::{enums as storage_enums, payment_link::PaymentLink},- transformers::ForeignFrom,+ transformers::{ForeignFrom, ForeignInto},},};@@ -129,6 +129,9 @@ pub async fn form_payment_link_data(show_card_form_by_default: DEFAULT_SHOW_CARD_FORM,allowed_domains: DEFAULT_ALLOWED_DOMAINS,transaction_details: None,+ background_image: None,+ details_layout: None,+ branding_visibility: None,}};@@ -271,6 +274,9 @@ pub async fn form_payment_link_data(show_card_form_by_default: payment_link_config.show_card_form_by_default,locale,transaction_details: payment_link_config.transaction_details.clone(),+ background_image: payment_link_config.background_image.clone(),+ details_layout: payment_link_config.details_layout,+ branding_visibility: payment_link_config.branding_visibility,};Ok((@@ -586,18 +592,16 @@ pub fn get_payment_link_config_based_on_priority(default_domain_name: String,payment_link_config_id: Option<String>,) -> Result<(PaymentLinkConfig, String), error_stack::Report<errors::ApiErrorResponse>> {- let (domain_name, business_theme_configs, allowed_domains) =+ let (domain_name, business_theme_configs, allowed_domains, branding_visibility) =if let Some(business_config) = business_link_config {- logger::info!(- "domain name set to custom domain https://{:?}",- business_config.domain_name- );-(business_config.domain_name.clone()- .map(|d_name| format!("https://{}", d_name))+ .map(|d_name| {+ logger::info!("domain name set to custom domain https://{:?}", d_name);+ format!("https://{}", d_name)+ }).unwrap_or_else(|| default_domain_name.clone()),payment_link_config_id.and_then(|id| {@@ -608,9 +612,10 @@ pub fn get_payment_link_config_based_on_priority(}).or(business_config.default_config),business_config.allowed_domains,+ business_config.branding_visibility,)} else {- (default_domain_name, None, None)+ (default_domain_name, None, None, None)};let (@@ -637,19 +642,45 @@ pub fn get_payment_link_config_based_on_priority((hide_card_nickname_field, DEFAULT_HIDE_CARD_NICKNAME_FIELD),(show_card_form_by_default, DEFAULT_SHOW_CARD_FORM));- let payment_link_config = PaymentLinkConfig {- theme,- logo,- seller_name,- sdk_layout,- 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),- };+ let payment_link_config =+ PaymentLinkConfig {+ theme,+ logo,+ seller_name,+ sdk_layout,+ display_sdk_only,+ enabled_saved_payment_method,+ hide_card_nickname_field,+ show_card_form_by_default,+ allowed_domains,+ branding_visibility,+ transaction_details: payment_create_link_config.as_ref().and_then(+ |payment_link_config| payment_link_config.theme_config.transaction_details.clone(),+ ),+ details_layout: payment_create_link_config+ .as_ref()+ .and_then(|payment_link_config| payment_link_config.theme_config.details_layout)+ .or_else(|| {+ business_theme_configs+ .as_ref()+ .and_then(|business_theme_config| business_theme_config.details_layout)+ }),+ background_image: payment_create_link_config+ .as_ref()+ .and_then(|payment_link_config| {+ payment_link_config.theme_config.background_image.clone()+ })+ .or_else(|| {+ business_theme_configs+ .as_ref()+ .and_then(|business_theme_config| {+ business_theme_config+ .background_image+ .as_ref()+ .map(|background_image| background_image.clone().foreign_into())+ })+ }),+ };Ok((payment_link_config, domain_name))}@@ -752,6 +783,9 @@ pub async fn get_payment_link_status(show_card_form_by_default: DEFAULT_SHOW_CARD_FORM,allowed_domains: DEFAULT_ALLOWED_DOMAINS,transaction_details: None,+ background_image: None,+ details_layout: None,+ branding_visibility: None,}};diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.css b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.cssindex 65a50e967f..b8ccdeba33 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.css+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.css@@ -71,6 +71,7 @@ body {#hyper-checkout-details {font-family: "Montserrat";+ background-repeat: no-repeat;}.hyper-checkout-payment {@@ -144,7 +145,7 @@ body {#hyper-checkout-merchant-image,#hyper-checkout-cart-image {height: 64px;- width: 64px;+ padding: 0 10px;border-radius: 4px;display: flex;align-self: flex-start;@@ -153,8 +154,7 @@ body {}#hyper-checkout-merchant-image > img {- height: 48px;- width: 48px;+ height: 40px;}#hyper-checkout-cart-image {@@ -279,7 +279,7 @@ body {#hyper-checkout-merchant-description {font-size: 13px;- color: #808080;+ margin: 10px 0 20px 0;}.powered-by-hyper {@@ -292,7 +292,6 @@ body {min-width: 584px;z-index: 2;background-color: var(--primary-color);- box-shadow: 0px 1px 10px #f2f2f2;display: flex;flex-flow: column;align-items: center;@@ -665,6 +664,12 @@ body {animation: loading 1s linear infinite;}+@media only screen and (min-width: 1199px) {+ #hyper-checkout-merchant-description {+ color: #808080;+ }+}+@media only screen and (max-width: 1199px) {body {overflow-y: scroll;diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.htmlindex 963b4d6083..9abcc44006 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html@@ -185,7 +185,7 @@<div></div></div></div>- <div class="hyper-checkout hide-scrollbar">+ <div id="hyper-checkout" class="hyper-checkout hide-scrollbar"><div class="main hidden" id="hyper-checkout-status-canvas"><div class="hyper-checkout-status-wrap"><div id="hyper-checkout-status-header"></div>@@ -270,18 +270,6 @@</svg></div><div id="hyper-checkout-cart-items" class="hide-scrollbar"></div>- <div id="hyper-checkout-merchant-description"></div>- <div class="powered-by-hyper">- <svg class="fill-current" height="18" width="130">- <use- xlink:href="#hyperswitch-brand"- x="0"- y="0"- height="18"- width="130"- ></use>- </svg>- </div></div></div><div class="hyper-checkout-sdk" id="hyper-checkout-sdk">@@ -313,17 +301,6 @@</div></div></div>- <div id="hyper-footer" class="hidden">- <svg class="fill-current" height="18" width="130">- <use- xlink:href="#hyperswitch-brand"- x="0"- y="0"- height="18"- width="130"- ></use>- </svg>- </div><script>{{logging_template}}{{locale_template}}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.jsindex 60cfad22ee..4bcdeed434 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@@ -139,8 +139,8 @@ function invertToBW(color, bw, asArr) {? hexToRgbArray(options.black): options.black: asArr- ? hexToRgbArray(options.white)- : options.white;+ ? hexToRgbArray(options.white)+ : options.white;}function invert(color, bw) {if (bw === void 0) {@@ -204,7 +204,7 @@ function boot() {}else {var orderDetails = paymentDetails.order_details;- if (orderDetails!==null) {+ if (orderDetails !== null) {var charges = 0;for (var i = 0; i < orderDetails.length; i++) {@@ -213,8 +213,8 @@ function boot() {orderDetails.push({"amount": (paymentDetails.amount - charges).toFixed(2),"product_img_link": "https://live.hyperswitch.io/payment-link-assets/cart_placeholder.png",- "product_name": translations.miscellaneousCharges+"\n" +- translations.miscellaneousChargesDetail,+ "product_name": translations.miscellaneousCharges + "\n" ++ translations.miscellaneousChargesDetail,"quantity": null});}@@ -233,13 +233,17 @@ function boot() {}// Render UI- if (paymentDetails.display_sdk_only){+ if (paymentDetails.display_sdk_only) {renderSDKHeader(paymentDetails);+ renderBranding(paymentDetails);}- else{+ else {+ renderBackgroundImage(paymentDetails);renderPaymentDetails(paymentDetails);renderDynamicMerchantDetails(paymentDetails);renderCart(paymentDetails);+ renderDescription(paymentDetails);+ renderBranding(paymentDetails);renderSDKHeader(paymentDetails);}@@ -295,12 +299,12 @@ function initializeEventListeners(paymentDetails) {submitButtonLoaderNode.style.borderBottomColor = contrastingTone;}- // Get locale for pay now- var payNowButtonText = document.createElement("div");- var payNowButtonText = document.getElementById('submit-button-text');- if (payNowButtonText) {- payNowButtonText.textContent = translations.payNow;- }+ // Get locale for pay now+ var payNowButtonText = document.createElement("div");+ var payNowButtonText = document.getElementById('submit-button-text');+ if (payNowButtonText) {+ payNowButtonText.textContent = translations.payNow;+ }if (submitButtonNode instanceof HTMLButtonElement) {submitButtonNode.style.color = contrastBWColor;@@ -473,12 +477,16 @@ function addText(id, msg) {function addClass(id, className) {var element = document.querySelector(id);- element.classList.add(className);+ if (element instanceof HTMLElement) {+ element.classList.add(className);+ }}function removeClass(id, className) {var element = document.querySelector(id);- element.classList.remove(className);+ if (element instanceof HTMLElement) {+ element.classList.remove(className);+ }}/**@@ -570,7 +578,6 @@ function renderPaymentDetails(paymentDetails) {// Create merchant logo's nodevar merchantLogoNode = document.createElement("img");merchantLogoNode.src = paymentDetails.merchant_logo;- merchantLogoNode.setAttribute("width", "48"); // Set width to 100 pixelsmerchantLogoNode.setAttribute("height", "48");// Create expiry node@@ -685,6 +692,113 @@ function appendMerchantDetails(paymentDetails, merchantDynamicDetails) {}}+/**+ * Uses+ * - Creates and appends description below the cart section (LAYOUT 1 / DEFAULT LAYOUT specification)+ * @param {String} merchantDescription+ */+function renderDefaultLayout(merchantDescription) {+ var cartItemNode = document.getElementById("hyper-checkout-cart");+ if (cartItemNode instanceof HTMLDivElement) {+ var merchantDescriptionNode = document.createElement("div");+ merchantDescriptionNode.id = "hyper-checkout-merchant-description";+ merchantDescriptionNode.innerText = merchantDescription;+ cartItemNode.appendChild(merchantDescriptionNode);+ show("#hyper-checkout-merchant-description");+ }+}++/**+ * Uses+ * - Renders description in the appropriate section based on the specified layout+ * @param {PaymentDetails} paymentDetails+ */+function renderDescription(paymentDetails) {+ var detailsLayout = paymentDetails.details_layout;+ if (typeof paymentDetails.merchant_description === "string" && paymentDetails.merchant_description.length > 0) {+ switch (detailsLayout) {+ case "layout1": {+ renderDefaultLayout(paymentDetails.merchant_description);+ break;+ }+ case "layout2": {+ var paymentContextNode = document.getElementById("hyper-checkout-payment-context");+ if (paymentContextNode instanceof HTMLDivElement) {+ var merchantDescriptionNode = document.createElement("div");+ merchantDescriptionNode.id = "hyper-checkout-merchant-description";+ merchantDescriptionNode.innerText = paymentDetails.merchant_description;+ var merchantDetailsNode = document.getElementById("hyper-checkout-payment-merchant-details");+ if (merchantDetailsNode instanceof HTMLDivElement) {+ paymentContextNode.insertBefore(merchantDescriptionNode, merchantDetailsNode);+ show("#hyper-checkout-merchant-description");+ }+ }+ break;+ }+ default: {+ renderDefaultLayout(paymentDetails.merchant_description);+ }+ }+ }+}++/**+ * Uses+ * - Creates and returns a div element with the HyperSwitch branding SVG+ * @param {String} wrapperId+ * @returns {HTMLDivElement} brandingWrapperNode+ */+function createHyperSwitchBrandingSVGElement(wrapperId) {+ var brandingWrapperNode = document.createElement("div");+ brandingWrapperNode.id = wrapperId;+ brandingWrapperNode.innerHTML = '<svg class="fill-current" height="18" width="130"><use xlink:href="#hyperswitch-brand" x="0" y="0" height="18" width="130"></use></svg>';+ return brandingWrapperNode;+}++/**+ * Uses+ * - Creates and appends HyperSwitch branding in appropriate sections based on the viewport dimensions (web vs mobile views)+ * @param {PaymentDetails} paymentDetails+ */+function renderBranding(paymentDetails) {+ if (paymentDetails.branding_visibility !== false) {+ // Append below cart section for web views+ var cartItemNode = document.getElementById("hyper-checkout-cart");+ if (cartItemNode instanceof HTMLDivElement) {+ var brandingWrapper = createHyperSwitchBrandingSVGElement("powered-by-hyper");+ cartItemNode.appendChild(brandingWrapper);+ }++ // Append in document's body for mobile views+ var mobileBrandingWrapper = createHyperSwitchBrandingSVGElement("hyper-footer");+ document.body.appendChild(mobileBrandingWrapper);+ if (!window.state.isMobileView) {+ hide("#hyper-footer");+ }+ }+}++/**+ * Uses+ * - Renders background image in the payment details section+ * @param {PaymentDetails} paymentDetails+ */+function renderBackgroundImage(paymentDetails) {+ var backgroundImage = paymentDetails.background_image;+ if (typeof backgroundImage === "object" && backgroundImage !== null) {+ var paymentDetailsNode = document.getElementById("hyper-checkout-details");+ if (paymentDetailsNode instanceof HTMLDivElement) {+ paymentDetailsNode.style.backgroundImage = "url(" + backgroundImage.url + ")";+ if (typeof backgroundImage.size === "string") {+ paymentDetailsNode.style.backgroundSize = backgroundImage.size;+ }+ if (typeof backgroundImage.position === "string") {+ paymentDetailsNode.style.backgroundPosition = backgroundImage.position;+ }+ }+ }+}+/*** Trigger - on boot* Uses@@ -737,7 +851,7 @@ function renderCart(paymentDetails) {buttonTextNode.id = "hyper-checkout-cart-button-text";var hiddenItemsCount =orderDetails.length - MAX_ITEMS_VISIBLE_AFTER_COLLAPSE;- buttonTextNode.innerText = translations.showMore+" (" + hiddenItemsCount + ")";+ buttonTextNode.innerText = translations.showMore + " (" + hiddenItemsCount + ")";expandButtonNode.append(buttonTextNode, buttonImageNode);if (cartNode instanceof HTMLDivElement) {cartNode.insertBefore(expandButtonNode, cartNode.lastElementChild);@@ -747,18 +861,6 @@ function renderCart(paymentDetails) {hide("#hyper-checkout-cart-header");hide("#hyper-checkout-cart-items");hide("#hyper-checkout-cart-image");- if (- typeof paymentDetails.merchant_description === "string" &&- paymentDetails.merchant_description.length > 0- ) {- var merchantDescriptionNode = document.getElementById(- "hyper-checkout-merchant-description"- );- if (merchantDescriptionNode instanceof HTMLDivElement) {- merchantDescriptionNode.innerText = paymentDetails.merchant_description;- }- show("#hyper-checkout-merchant-description");- }}}@@ -801,8 +903,8 @@ function renderCartItem(if (item.quantity !== null) {var quantityNode = document.createElement("div");quantityNode.className = "hyper-checkout-card-item-quantity";- quantityNode.innerText = translations.quantity+": " + item.quantity;- }+ quantityNode.innerText = translations.quantity + ": " + item.quantity;+ }// Product pricevar priceNode = document.createElement("div");priceNode.className = "hyper-checkout-card-item-price";@@ -869,9 +971,9 @@ function handleCartView(paymentDetails) {);});}- if (cartItemsNode instanceof HTMLDivElement){+ if (cartItemsNode instanceof HTMLDivElement) {cartItemsNode.style.maxHeight = cartItemsNode.scrollHeight + "px";-+cartItemsNode.style.height = cartItemsNode.scrollHeight + "px";}@@ -914,7 +1016,7 @@ function handleCartView(paymentDetails) {var hiddenItemsCount =orderDetails.length - MAX_ITEMS_VISIBLE_AFTER_COLLAPSE;if (cartButtonTextNode instanceof HTMLSpanElement) {- cartButtonTextNode.innerText = translations.showMore+" (" + hiddenItemsCount + ")";+ cartButtonTextNode.innerText = translations.showMore + " (" + hiddenItemsCount + ")";}var arrowDownImage = document.getElementById("arrow-down");if (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 ab46223df1..d45a72b5e5 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@@ -27,6 +27,7 @@ function initializeSDK() {// @ts-ignorehyper = window.Hyper(pub_key, {isPreloadEnabled: false,+ shouldUseTopRedirection: true,});// @ts-ignorewidgets = hyper.widgets({diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 1a635b097e..668de68318 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -3647,6 +3647,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>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,+ details_layout: config.details_layout,transaction_details: config.transaction_details.map(|transaction_details| {transaction_details.iter()@@ -3655,6 +3656,11 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>}).collect()}),+ background_image: config.background_image.map(|background_image| {+ diesel_models::business_profile::PaymentLinkBackgroundImageConfig::foreign_from(+ background_image.clone(),+ )+ }),}}}@@ -3701,6 +3707,7 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>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,+ details_layout: config.details_layout,transaction_details: config.transaction_details.map(|transaction_details| {transaction_details.iter()@@ -3711,6 +3718,11 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>}).collect()}),+ background_image: config.background_image.map(|background_image| {+ api_models::admin::PaymentLinkBackgroundImageConfig::foreign_from(+ background_image.clone(),+ )+ }),}}}diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex a3c3da0462..269eb831fc 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -1921,6 +1921,7 @@ impl ForeignFrom<api_models::admin::BusinessPaymentLinkConfig>.collect()}),allowed_domains: item.allowed_domains,+ branding_visibility: item.branding_visibility,}}}@@ -1938,6 +1939,7 @@ impl ForeignFrom<diesel_models::business_profile::BusinessPaymentLinkConfig>.collect()}),allowed_domains: item.allowed_domains,+ branding_visibility: item.branding_visibility,}}}@@ -1955,6 +1957,10 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>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,+ details_layout: item.details_layout,+ background_image: item+ .background_image+ .map(|background_image| background_image.foreign_into()),}}}@@ -1973,6 +1979,36 @@ impl ForeignFrom<diesel_models::business_profile::PaymentLinkConfigRequest>hide_card_nickname_field: item.hide_card_nickname_field,show_card_form_by_default: item.show_card_form_by_default,transaction_details: None,+ details_layout: item.details_layout,+ background_image: item+ .background_image+ .map(|background_image| background_image.foreign_into()),+ }+ }+}++impl ForeignFrom<diesel_models::business_profile::PaymentLinkBackgroundImageConfig>+ for api_models::admin::PaymentLinkBackgroundImageConfig+{+ fn foreign_from(+ item: diesel_models::business_profile::PaymentLinkBackgroundImageConfig,+ ) -> Self {+ Self {+ url: item.url,+ position: item.position,+ size: item.size,+ }+ }+}++impl ForeignFrom<api_models::admin::PaymentLinkBackgroundImageConfig>+ for diesel_models::business_profile::PaymentLinkBackgroundImageConfig+{+ fn foreign_from(item: api_models::admin::PaymentLinkBackgroundImageConfig) -> Self {+ Self {+ url: item.url,+ position: item.position,+ size: item.size,}}}