Skip to content

Commit a96e9f3

Browse files
authored
refactor(payment_links): Update API contract for dynamic transaction details and upgrade UI (#5849)
1 parent 1929f56 commit a96e9f3

File tree

10 files changed

+210
-42
lines changed

10 files changed

+210
-42
lines changed

api-reference-v2/openapi_spec.json

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10805,7 +10805,10 @@
1080510805
"nullable": true
1080610806
},
1080710807
"transaction_details": {
10808-
"type": "string",
10808+
"type": "array",
10809+
"items": {
10810+
"$ref": "#/components/schemas/PaymentLinkTransactionDetails"
10811+
},
1080910812
"description": "Dynamic details related to merchant to be rendered in payment link",
1081010813
"nullable": true
1081110814
}
@@ -10857,7 +10860,10 @@
1085710860
"nullable": true
1085810861
},
1085910862
"transaction_details": {
10860-
"type": "object",
10863+
"type": "array",
10864+
"items": {
10865+
"$ref": "#/components/schemas/PaymentLinkTransactionDetails"
10866+
},
1086110867
"description": "Dynamic details related to merchant to be rendered in payment link",
1086210868
"nullable": true
1086310869
}
@@ -10908,6 +10914,35 @@
1090810914
"expired"
1090910915
]
1091010916
},
10917+
"PaymentLinkTransactionDetails": {
10918+
"type": "object",
10919+
"required": [
10920+
"key",
10921+
"value"
10922+
],
10923+
"properties": {
10924+
"key": {
10925+
"type": "string",
10926+
"description": "Key for the transaction details",
10927+
"example": "Policy-Number",
10928+
"maxLength": 255
10929+
},
10930+
"value": {
10931+
"type": "string",
10932+
"description": "Value for the transaction details",
10933+
"example": "297472368473924",
10934+
"maxLength": 255
10935+
},
10936+
"ui_configuration": {
10937+
"allOf": [
10938+
{
10939+
"$ref": "#/components/schemas/TransactionDetailsUiConfiguration"
10940+
}
10941+
],
10942+
"nullable": true
10943+
}
10944+
}
10945+
},
1091110946
"PaymentListConstraints": {
1091210947
"type": "object",
1091310948
"properties": {
@@ -18094,6 +18129,32 @@
1809418129
"TouchNGoRedirection": {
1809518130
"type": "object"
1809618131
},
18132+
"TransactionDetailsUiConfiguration": {
18133+
"type": "object",
18134+
"properties": {
18135+
"position": {
18136+
"type": "integer",
18137+
"format": "int32",
18138+
"description": "Position of the key-value pair in the UI",
18139+
"example": 5,
18140+
"nullable": true
18141+
},
18142+
"is_key_bold": {
18143+
"type": "boolean",
18144+
"description": "Whether the key should be bold",
18145+
"default": false,
18146+
"example": true,
18147+
"nullable": true
18148+
},
18149+
"is_value_bold": {
18150+
"type": "boolean",
18151+
"description": "Whether the value should be bold",
18152+
"default": false,
18153+
"example": true,
18154+
"nullable": true
18155+
}
18156+
}
18157+
},
1809718158
"TransactionStatus": {
1809818159
"type": "string",
1809918160
"description": "Indicates the transaction status",

api-reference/openapi_spec.json

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14803,7 +14803,10 @@
1480314803
"nullable": true
1480414804
},
1480514805
"transaction_details": {
14806-
"type": "string",
14806+
"type": "array",
14807+
"items": {
14808+
"$ref": "#/components/schemas/PaymentLinkTransactionDetails"
14809+
},
1480714810
"description": "Dynamic details related to merchant to be rendered in payment link",
1480814811
"nullable": true
1480914812
}
@@ -14855,7 +14858,10 @@
1485514858
"nullable": true
1485614859
},
1485714860
"transaction_details": {
14858-
"type": "object",
14861+
"type": "array",
14862+
"items": {
14863+
"$ref": "#/components/schemas/PaymentLinkTransactionDetails"
14864+
},
1485914865
"description": "Dynamic details related to merchant to be rendered in payment link",
1486014866
"nullable": true
1486114867
}
@@ -14906,6 +14912,35 @@
1490614912
"expired"
1490714913
]
1490814914
},
14915+
"PaymentLinkTransactionDetails": {
14916+
"type": "object",
14917+
"required": [
14918+
"key",
14919+
"value"
14920+
],
14921+
"properties": {
14922+
"key": {
14923+
"type": "string",
14924+
"description": "Key for the transaction details",
14925+
"example": "Policy-Number",
14926+
"maxLength": 255
14927+
},
14928+
"value": {
14929+
"type": "string",
14930+
"description": "Value for the transaction details",
14931+
"example": "297472368473924",
14932+
"maxLength": 255
14933+
},
14934+
"ui_configuration": {
14935+
"allOf": [
14936+
{
14937+
"$ref": "#/components/schemas/TransactionDetailsUiConfiguration"
14938+
}
14939+
],
14940+
"nullable": true
14941+
}
14942+
}
14943+
},
1490914944
"PaymentListConstraints": {
1491014945
"type": "object",
1491114946
"properties": {
@@ -22543,6 +22578,32 @@
2254322578
"TouchNGoRedirection": {
2254422579
"type": "object"
2254522580
},
22581+
"TransactionDetailsUiConfiguration": {
22582+
"type": "object",
22583+
"properties": {
22584+
"position": {
22585+
"type": "integer",
22586+
"format": "int32",
22587+
"description": "Position of the key-value pair in the UI",
22588+
"example": 5,
22589+
"nullable": true
22590+
},
22591+
"is_key_bold": {
22592+
"type": "boolean",
22593+
"description": "Whether the key should be bold",
22594+
"default": false,
22595+
"example": true,
22596+
"nullable": true
22597+
},
22598+
"is_value_bold": {
22599+
"type": "boolean",
22600+
"description": "Whether the value should be bold",
22601+
"default": false,
22602+
"example": true,
22603+
"nullable": true
22604+
}
22605+
}
22606+
},
2254622607
"TransactionStatus": {
2254722608
"type": "string",
2254822609
"description": "Indicates the transaction status",

crates/api_models/src/admin.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use common_utils::{
99
};
1010
#[cfg(feature = "v1")]
1111
use common_utils::{crypto::OptionalEncryptableName, ext_traits::ValueExt};
12-
use indexmap::IndexMap;
1312
#[cfg(feature = "v2")]
1413
use masking::ExposeInterface;
1514
use masking::Secret;
@@ -2584,8 +2583,32 @@ pub struct PaymentLinkConfigRequest {
25842583
#[schema(default = false, example = true)]
25852584
pub enabled_saved_payment_method: Option<bool>,
25862585
/// Dynamic details related to merchant to be rendered in payment link
2587-
#[schema(value_type = Option<Object>, example = r#"{ "value1": "some-value", "value2": "some-value" }"#)]
2588-
pub transaction_details: Option<IndexMap<String, String>>,
2586+
pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
2587+
}
2588+
2589+
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
2590+
pub struct PaymentLinkTransactionDetails {
2591+
/// Key for the transaction details
2592+
#[schema(value_type = String, max_length = 255, example = "Policy-Number")]
2593+
pub key: String,
2594+
/// Value for the transaction details
2595+
#[schema(value_type = String, max_length = 255, example = "297472368473924")]
2596+
pub value: String,
2597+
/// UI configuration for the transaction details
2598+
pub ui_configuration: Option<TransactionDetailsUiConfiguration>,
2599+
}
2600+
2601+
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
2602+
pub struct TransactionDetailsUiConfiguration {
2603+
/// Position of the key-value pair in the UI
2604+
#[schema(value_type = Option<i8>, example = 5)]
2605+
pub position: Option<i8>,
2606+
/// Whether the key should be bold
2607+
#[schema(default = false, example = true)]
2608+
pub is_key_bold: Option<bool>,
2609+
/// Whether the value should be bold
2610+
#[schema(default = false, example = true)]
2611+
pub is_value_bold: Option<bool>,
25892612
}
25902613

25912614
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, ToSchema)]
@@ -2605,7 +2628,7 @@ pub struct PaymentLinkConfig {
26052628
/// A list of allowed domains (glob patterns) where this link can be embedded / opened from
26062629
pub allowed_domains: Option<HashSet<String>>,
26072630
/// Dynamic details related to merchant to be rendered in payment link
2608-
pub transaction_details: Option<String>,
2631+
pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
26092632
}
26102633

26112634
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]

crates/api_models/src/payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5616,7 +5616,7 @@ pub struct PaymentLinkDetails {
56165616
pub sdk_layout: String,
56175617
pub display_sdk_only: bool,
56185618
pub locale: Option<String>,
5619-
pub transaction_details: Option<String>,
5619+
pub transaction_details: Option<Vec<admin::PaymentLinkTransactionDetails>>,
56205620
}
56215621

56225622
#[derive(Debug, serde::Serialize, Clone)]
@@ -5642,7 +5642,7 @@ pub struct PaymentLinkStatusDetails {
56425642
pub theme: String,
56435643
pub return_url: String,
56445644
pub locale: Option<String>,
5645-
pub transaction_details: Option<String>,
5645+
pub transaction_details: Option<Vec<admin::PaymentLinkTransactionDetails>>,
56465646
pub unified_code: Option<String>,
56475647
pub unified_message: Option<String>,
56485648
}

crates/common_utils/src/consts.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ pub const DEFAULT_ENABLE_SAVED_PAYMENT_METHOD: bool = false;
8989
/// Default allowed domains for payment links
9090
pub const DEFAULT_ALLOWED_DOMAINS: Option<HashSet<String>> = None;
9191

92-
/// Default merchant details for payment links
93-
pub const DEFAULT_TRANSACTION_DETAILS: Option<String> = None;
94-
9592
/// Default ttl for Extended card info in redis (in seconds)
9693
pub const DEFAULT_TTL_FOR_EXTENDED_CARD_INFO: u16 = 15 * 60;
9794

crates/openapi/src/openapi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ Never share your secret api keys. Keep them guarded and secure.
285285
api_models::admin::BusinessPaymentLinkConfig,
286286
api_models::admin::PaymentLinkConfigRequest,
287287
api_models::admin::PaymentLinkConfig,
288+
api_models::admin::PaymentLinkTransactionDetails,
289+
api_models::admin::TransactionDetailsUiConfiguration,
288290
api_models::disputes::DisputeResponse,
289291
api_models::disputes::DisputeResponsePaymentsRetrieve,
290292
api_models::gsm::GsmCreateRequest,

crates/openapi/src/openapi_v2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ Never share your secret api keys. Keep them guarded and secure.
203203
api_models::admin::BusinessPaymentLinkConfig,
204204
api_models::admin::PaymentLinkConfigRequest,
205205
api_models::admin::PaymentLinkConfig,
206+
api_models::admin::PaymentLinkTransactionDetails,
207+
api_models::admin::TransactionDetailsUiConfiguration,
206208
api_models::disputes::DisputeResponse,
207209
api_models::disputes::DisputeResponsePaymentsRetrieve,
208210
api_models::gsm::GsmCreateRequest,

crates/router/src/core/payment_link.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use common_utils::{
99
DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY,
1010
DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_LOCALE, DEFAULT_MERCHANT_LOGO,
1111
DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SESSION_EXPIRY,
12-
DEFAULT_TRANSACTION_DETAILS,
1312
},
1413
ext_traits::{AsyncExt, OptionExt, ValueExt},
1514
types::{AmountConvertor, MinorUnit, StringMajorUnitForCore},
@@ -114,7 +113,7 @@ pub async fn form_payment_link_data(
114113
display_sdk_only: DEFAULT_DISPLAY_SDK_ONLY,
115114
enabled_saved_payment_method: DEFAULT_ENABLE_SAVED_PAYMENT_METHOD,
116115
allowed_domains: DEFAULT_ALLOWED_DOMAINS,
117-
transaction_details: DEFAULT_TRANSACTION_DETAILS,
116+
transaction_details: None,
118117
}
119118
};
120119

@@ -616,24 +615,8 @@ pub fn get_payment_link_config_based_on_priority(
616615
display_sdk_only,
617616
enabled_saved_payment_method,
618617
allowed_domains,
619-
transaction_details: payment_create_link_config.and_then(|payment_link_config| {
620-
payment_link_config
621-
.theme_config
622-
.transaction_details
623-
.and_then(|transaction_details| {
624-
match serde_json::to_string(&transaction_details).change_context(
625-
errors::ApiErrorResponse::InvalidDataValue {
626-
field_name: "transaction_details",
627-
},
628-
) {
629-
Ok(details) => Some(details),
630-
Err(err) => {
631-
logger::error!("Failed to serialize transaction details: {:?}", err);
632-
None
633-
}
634-
}
635-
})
636-
}),
618+
transaction_details: payment_create_link_config
619+
.and_then(|payment_link_config| payment_link_config.theme_config.transaction_details),
637620
};
638621

639622
Ok((payment_link_config, domain_name))
@@ -721,7 +704,7 @@ pub async fn get_payment_link_status(
721704
display_sdk_only: DEFAULT_DISPLAY_SDK_ONLY,
722705
enabled_saved_payment_method: DEFAULT_ENABLE_SAVED_PAYMENT_METHOD,
723706
allowed_domains: DEFAULT_ALLOWED_DOMAINS,
724-
transaction_details: DEFAULT_TRANSACTION_DETAILS,
707+
transaction_details: None,
725708
}
726709
};
727710

crates/router/src/core/payment_link/payment_link_initiate/payment_link.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ body {
9696

9797
#hyper-checkout-payment-merchant-dynamic-details {
9898
margin: 20px 20px 10px 20px;
99+
overflow-y: scroll;
100+
max-width: 35vw;
101+
max-height: 10vh;
102+
min-height: 80px;
99103
}
100104

101105
.hyper-checkout-payment-horizontal-line {
@@ -714,6 +718,10 @@ body {
714718
flex-flow: column;
715719
flex-direction: column-reverse;
716720
margin: 0;
721+
max-width: 100%;
722+
overflow-y: scroll;
723+
max-height: 10vh;
724+
min-height: 80px;
717725
}
718726

719727
.hyper-checkout-payment-horizontal-line {

0 commit comments

Comments
 (0)