Skip to content

Commit eb900da

Browse files
committed
add config for changing button text for payment links
1 parent c154a38 commit eb900da

File tree

11 files changed

+57
-4
lines changed

11 files changed

+57
-4
lines changed

api-reference-v2/openapi_spec.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12725,7 +12725,8 @@
1272512725
"display_sdk_only",
1272612726
"enabled_saved_payment_method",
1272712727
"hide_card_nickname_field",
12728-
"show_card_form_by_default"
12728+
"show_card_form_by_default",
12729+
"payment_button_text"
1272912730
],
1273012731
"properties": {
1273112732
"theme": {
@@ -12797,6 +12798,11 @@
1279712798
"type": "boolean",
1279812799
"description": "Toggle for HyperSwitch branding visibility",
1279912800
"nullable": true
12801+
},
12802+
"payment_button_text":{
12803+
"type": "string",
12804+
"description": "Text for payment link's handle confirm button",
12805+
"nullable": true
1280012806
}
1280112807
}
1280212808
},
@@ -12882,6 +12888,11 @@
1288212888
}
1288312889
],
1288412890
"nullable": true
12891+
},
12892+
"payment_button_text":{
12893+
"type": "string",
12894+
"description": "Text for payment link's handle confirm button",
12895+
"nullable": true
1288512896
}
1288612897
}
1288712898
},

api-reference/openapi_spec.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15409,7 +15409,8 @@
1540915409
"display_sdk_only",
1541015410
"enabled_saved_payment_method",
1541115411
"hide_card_nickname_field",
15412-
"show_card_form_by_default"
15412+
"show_card_form_by_default",
15413+
"payment_button_text"
1541315414
],
1541415415
"properties": {
1541515416
"theme": {
@@ -15481,8 +15482,12 @@
1548115482
"type": "boolean",
1548215483
"description": "Toggle for HyperSwitch branding visibility",
1548315484
"nullable": true
15485+
},
15486+
"payment_button_text":{
15487+
"type": "string",
15488+
"description": "Text for payment link's handle confirm button",
15489+
"nullable": true
1548415490
}
15485-
}
1548615491
},
1548715492
"PaymentLinkConfigRequest": {
1548815493
"type": "object",
@@ -15566,6 +15571,11 @@
1556615571
}
1556715572
],
1556815573
"nullable": true
15574+
},
15575+
"payment_button_text":{
15576+
"type": "string",
15577+
"description": "Text for payment link's handle confirm button",
15578+
"nullable": true
1556915579
}
1557015580
}
1557115581
},

crates/api_models/src/admin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,8 @@ pub struct PaymentLinkConfigRequest {
27692769
/// Custom layout for details section
27702770
#[schema(value_type = Option<PaymentLinkDetailsLayout>, example = "layout1")]
27712771
pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
2772+
/// Text for payment link's handle confirm button
2773+
pub payment_button_text: Option<String>,
27722774
}
27732775

27742776
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
@@ -2838,6 +2840,8 @@ pub struct PaymentLinkConfig {
28382840
pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
28392841
/// Toggle for HyperSwitch branding visibility
28402842
pub branding_visibility: Option<bool>,
2843+
/// Text for payment link's handle confirm button
2844+
pub payment_button_text: Option<String>,
28412845
}
28422846

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

crates/api_models/src/payments.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6863,6 +6863,7 @@ pub struct PaymentLinkDetails {
68636863
pub background_image: Option<admin::PaymentLinkBackgroundImageConfig>,
68646864
pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
68656865
pub branding_visibility: Option<bool>,
6866+
pub payment_button_text: Option<String>,
68666867
}
68676868

68686869
#[derive(Debug, serde::Serialize, Clone)]
@@ -6872,6 +6873,7 @@ pub struct SecurePaymentLinkDetails {
68726873
pub show_card_form_by_default: bool,
68736874
#[serde(flatten)]
68746875
pub payment_link_details: PaymentLinkDetails,
6876+
pub payment_button_text: Option<String>,
68756877
}
68766878

68776879
#[derive(Debug, serde::Serialize)]

crates/diesel_models/src/business_profile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ pub struct PaymentLinkConfigRequest {
571571
pub show_card_form_by_default: Option<bool>,
572572
pub background_image: Option<PaymentLinkBackgroundImageConfig>,
573573
pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,
574+
pub payment_button_text: Option<String>,
574575
}
575576

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

crates/diesel_models/src/payment_intent.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ pub struct PaymentLinkConfigRequestForPayments {
167167
pub background_image: Option<PaymentLinkBackgroundImageConfig>,
168168
/// Custom layout for details section
169169
pub details_layout: Option<common_enums::PaymentLinkDetailsLayout>,
170+
/// Text for payment link's handle confirm button
171+
pub payment_button_text: Option<String>,
170172
}
171173

172174
common_utils::impl_to_sql_from_sql_json!(PaymentLinkConfigRequestForPayments);

crates/hyperswitch_domain_models/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
209209
background_image,
210210
)
211211
}),
212+
payment_button_text: item.payment_button_text,
212213
}
213214
}
214215
fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {
@@ -224,6 +225,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
224225
transaction_details,
225226
background_image,
226227
details_layout,
228+
payment_button_text,
227229
} = self;
228230
api_models::admin::PaymentLinkConfigRequest {
229231
theme,
@@ -243,6 +245,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
243245
}),
244246
background_image: background_image
245247
.map(|background_image| background_image.convert_back()),
248+
payment_button_text,
246249
}
247250
}
248251
}

crates/router/src/core/payment_link.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub async fn form_payment_link_data(
132132
background_image: None,
133133
details_layout: None,
134134
branding_visibility: None,
135+
payment_button_text: None,
135136
}
136137
};
137138

@@ -277,6 +278,7 @@ pub async fn form_payment_link_data(
277278
background_image: payment_link_config.background_image.clone(),
278279
details_layout: payment_link_config.details_layout,
279280
branding_visibility: payment_link_config.branding_visibility,
281+
payment_button_text: payment_link_config.payment_button_text.clone(),
280282
};
281283

282284
Ok((
@@ -335,6 +337,7 @@ pub async fn initiate_secure_payment_link_flow(
335337
hide_card_nickname_field: payment_link_config.hide_card_nickname_field,
336338
show_card_form_by_default: payment_link_config.show_card_form_by_default,
337339
payment_link_details: *link_details.to_owned(),
340+
payment_button_text: payment_link_config.payment_button_text,
338341
};
339342
let js_script = format!(
340343
"window.__PAYMENT_DETAILS = {}",
@@ -680,6 +683,18 @@ pub fn get_payment_link_config_based_on_priority(
680683
.map(|background_image| background_image.clone().foreign_into())
681684
})
682685
}),
686+
payment_button_text: payment_create_link_config
687+
.as_ref()
688+
.and_then(|payment_link_config| {
689+
payment_link_config.theme_config.payment_button_text.clone()
690+
})
691+
.or_else(|| {
692+
business_theme_configs
693+
.as_ref()
694+
.and_then(|business_theme_config| {
695+
business_theme_config.payment_button_text.clone()
696+
})
697+
}),
683698
};
684699

685700
Ok((payment_link_config, domain_name))
@@ -786,6 +801,7 @@ pub async fn get_payment_link_status(
786801
background_image: None,
787802
details_layout: None,
788803
branding_visibility: None,
804+
payment_button_text: None,
789805
}
790806
};
791807

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function initializeEventListeners(paymentDetails) {
303303
var payNowButtonText = document.createElement("div");
304304
var payNowButtonText = document.getElementById('submit-button-text');
305305
if (payNowButtonText) {
306-
payNowButtonText.textContent = translations.payNow;
306+
payNowButtonText.textContent = paymentDetails.payment_button_text || translations.payNow;
307307
}
308308

309309
if (submitButtonNode instanceof HTMLButtonElement) {

crates/router/src/core/payments/transformers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,7 @@ impl ForeignFrom<api_models::admin::PaymentLinkConfigRequest>
36363636
background_image.clone(),
36373637
)
36383638
}),
3639+
payment_button_text: config.payment_button_text,
36393640
}
36403641
}
36413642
}
@@ -3698,6 +3699,7 @@ impl ForeignFrom<diesel_models::PaymentLinkConfigRequestForPayments>
36983699
background_image.clone(),
36993700
)
37003701
}),
3702+
payment_button_text: config.payment_button_text,
37013703
}
37023704
}
37033705
}

0 commit comments

Comments
 (0)