Skip to content

Commit fa46593

Browse files
feat(payment-link): alternate text for manual captures (#7574)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 69ba651 commit fa46593

File tree

12 files changed

+107
-11
lines changed

12 files changed

+107
-11
lines changed

api-reference-v2/openapi_spec.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14908,6 +14908,11 @@
1490814908
}
1490914909
],
1491014910
"nullable": true
14911+
},
14912+
"is_setup_mandate_flow": {
14913+
"type": "boolean",
14914+
"description": "Boolean to control payment button text for setup mandate calls",
14915+
"nullable": true
1491114916
}
1491214917
}
1491314918
},
@@ -15071,6 +15076,11 @@
1507115076
}
1507215077
],
1507315078
"nullable": true
15079+
},
15080+
"is_setup_mandate_flow": {
15081+
"type": "boolean",
15082+
"description": "Boolean to control payment button text for setup mandate calls",
15083+
"nullable": true
1507415084
}
1507515085
}
1507615086
},

api-reference/openapi_spec.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17340,6 +17340,11 @@
1734017340
}
1734117341
],
1734217342
"nullable": true
17343+
},
17344+
"is_setup_mandate_flow": {
17345+
"type": "boolean",
17346+
"description": "Boolean to control payment button text for setup mandate calls",
17347+
"nullable": true
1734317348
}
1734417349
}
1734517350
},
@@ -17503,6 +17508,11 @@
1750317508
}
1750417509
],
1750517510
"nullable": true
17511+
},
17512+
"is_setup_mandate_flow": {
17513+
"type": "boolean",
17514+
"description": "Boolean to control payment button text for setup mandate calls",
17515+
"nullable": true
1750617516
}
1750717517
}
1750817518
},

crates/api_models/src/admin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,6 +2903,8 @@ pub struct PaymentLinkConfigRequest {
29032903
/// Boolean for controlling whether or not to show the explicit consent for storing cards
29042904
#[schema(value_type = Option<PaymentLinkShowSdkTerms>, example = "always")]
29052905
pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,
2906+
/// Boolean to control payment button text for setup mandate calls
2907+
pub is_setup_mandate_flow: Option<bool>,
29062908
}
29072909

29082910
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
@@ -2998,6 +3000,8 @@ pub struct PaymentLinkConfig {
29983000
/// Boolean for controlling whether or not to show the explicit consent for storing cards
29993001
#[schema(value_type = Option<PaymentLinkShowSdkTerms>, example = "always")]
30003002
pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,
3003+
/// Boolean to control payment button text for setup mandate calls
3004+
pub is_setup_mandate_flow: Option<bool>,
30013005
}
30023006

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

crates/api_models/src/payments.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8081,6 +8081,9 @@ pub struct PaymentLinkDetails {
80818081
pub payment_form_header_text: Option<String>,
80828082
pub payment_form_label_type: Option<api_enums::PaymentLinkSdkLabelType>,
80838083
pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,
8084+
pub is_setup_mandate_flow: Option<bool>,
8085+
pub capture_method: Option<common_enums::CaptureMethod>,
8086+
pub setup_future_usage_applied: Option<common_enums::FutureUsage>,
80848087
}
80858088

80868089
#[derive(Debug, serde::Serialize, Clone)]
@@ -8123,6 +8126,8 @@ pub struct PaymentLinkStatusDetails {
81238126
pub transaction_details: Option<Vec<admin::PaymentLinkTransactionDetails>>,
81248127
pub unified_code: Option<String>,
81258128
pub unified_message: Option<String>,
8129+
pub capture_method: Option<common_enums::CaptureMethod>,
8130+
pub setup_future_usage_applied: Option<common_enums::FutureUsage>,
81268131
}
81278132

81288133
#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]

crates/diesel_models/src/business_profile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ pub struct PaymentLinkConfigRequest {
721721
pub payment_form_header_text: Option<String>,
722722
pub payment_form_label_type: Option<common_enums::PaymentLinkSdkLabelType>,
723723
pub show_card_terms: Option<common_enums::PaymentLinkShowSdkTerms>,
724+
pub is_setup_mandate_flow: Option<bool>,
724725
}
725726

726727
#[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
@@ -205,6 +205,8 @@ pub struct PaymentLinkConfigRequestForPayments {
205205
pub payment_form_label_type: Option<common_enums::PaymentLinkSdkLabelType>,
206206
/// Boolean for controlling whether or not to show the explicit consent for storing cards
207207
pub show_card_terms: Option<common_enums::PaymentLinkShowSdkTerms>,
208+
/// Boolean to control payment button text for setup mandate calls
209+
pub is_setup_mandate_flow: Option<bool>,
208210
}
209211

210212
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
@@ -427,6 +427,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
427427
payment_form_header_text: item.payment_form_header_text,
428428
payment_form_label_type: item.payment_form_label_type,
429429
show_card_terms: item.show_card_terms,
430+
is_setup_mandate_flow: item.is_setup_mandate_flow,
430431
}
431432
}
432433
fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {
@@ -454,6 +455,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
454455
payment_form_header_text,
455456
payment_form_label_type,
456457
show_card_terms,
458+
is_setup_mandate_flow,
457459
} = self;
458460
api_models::admin::PaymentLinkConfigRequest {
459461
theme,
@@ -485,6 +487,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
485487
payment_form_header_text,
486488
payment_form_label_type,
487489
show_card_terms,
490+
is_setup_mandate_flow,
488491
}
489492
}
490493
}

crates/router/src/core/payment_link.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub async fn form_payment_link_data(
142142
payment_form_header_text: None,
143143
payment_form_label_type: None,
144144
show_card_terms: None,
145+
is_setup_mandate_flow: None,
145146
}
146147
};
147148

@@ -207,6 +208,17 @@ pub async fn form_payment_link_data(
207208
storage_enums::IntentStatus::RequiresCustomerAction,
208209
],
209210
);
211+
212+
let attempt_id = payment_intent.active_attempt.get_id().clone();
213+
let payment_attempt = db
214+
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
215+
&payment_intent.payment_id,
216+
&merchant_id,
217+
&attempt_id.clone(),
218+
merchant_account.storage_scheme,
219+
)
220+
.await
221+
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
210222
if is_payment_link_terminal_state
211223
|| payment_link_status == api_models::payments::PaymentLinkStatus::Expired
212224
{
@@ -230,16 +242,6 @@ pub async fn form_payment_link_data(
230242
}
231243
};
232244

233-
let attempt_id = payment_intent.active_attempt.get_id().clone();
234-
let payment_attempt = db
235-
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
236-
&payment_intent.payment_id,
237-
&merchant_id,
238-
&attempt_id.clone(),
239-
merchant_account.storage_scheme,
240-
)
241-
.await
242-
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
243245
let payment_details = api_models::payments::PaymentLinkStatusDetails {
244246
amount,
245247
currency,
@@ -257,6 +259,8 @@ pub async fn form_payment_link_data(
257259
transaction_details: payment_link_config.transaction_details.clone(),
258260
unified_code: payment_attempt.unified_code,
259261
unified_message: payment_attempt.unified_message,
262+
capture_method: payment_attempt.capture_method,
263+
setup_future_usage_applied: payment_attempt.setup_future_usage_applied,
260264
};
261265

262266
return Ok((
@@ -302,6 +306,9 @@ pub async fn form_payment_link_data(
302306
payment_form_header_text: payment_link_config.payment_form_header_text.clone(),
303307
payment_form_label_type: payment_link_config.payment_form_label_type,
304308
show_card_terms: payment_link_config.show_card_terms,
309+
is_setup_mandate_flow: payment_link_config.is_setup_mandate_flow,
310+
capture_method: payment_attempt.capture_method,
311+
setup_future_usage_applied: payment_attempt.setup_future_usage_applied,
305312
};
306313

307314
Ok((
@@ -686,6 +693,7 @@ pub fn get_payment_link_config_based_on_priority(
686693
payment_form_header_text,
687694
payment_form_label_type,
688695
show_card_terms,
696+
is_setup_mandate_flow,
689697
) = get_payment_link_config_value!(
690698
payment_create_link_config,
691699
business_theme_configs,
@@ -703,6 +711,7 @@ pub fn get_payment_link_config_based_on_priority(
703711
(payment_form_header_text),
704712
(payment_form_label_type),
705713
(show_card_terms),
714+
(is_setup_mandate_flow),
706715
);
707716

708717
let payment_link_config =
@@ -734,6 +743,7 @@ pub fn get_payment_link_config_based_on_priority(
734743
payment_form_header_text,
735744
payment_form_label_type,
736745
show_card_terms,
746+
is_setup_mandate_flow,
737747
};
738748

739749
Ok((payment_link_config, domain_name))
@@ -848,6 +858,7 @@ pub async fn get_payment_link_status(
848858
payment_form_header_text: None,
849859
payment_form_label_type: None,
850860
show_card_terms: None,
861+
is_setup_mandate_flow: None,
851862
}
852863
};
853864

@@ -930,6 +941,8 @@ pub async fn get_payment_link_status(
930941
transaction_details: payment_link_config.transaction_details,
931942
unified_code: Some(unified_code),
932943
unified_message: unified_translated_message,
944+
capture_method: payment_attempt.capture_method,
945+
setup_future_usage_applied: payment_attempt.setup_future_usage_applied,
933946
};
934947
let js_script = get_js_script(&PaymentLinkData::PaymentLinkStatusDetails(Box::new(
935948
payment_details,

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const locales = {
2525
refId: "Ref Id: ",
2626
requestedBy: "Requested by ",
2727
payNow: "Pay now",
28+
addPaymentMethod: "Add Payment Method",
29+
authorizePayment: "Authorize Payment",
2830
yourCart: "Your Cart",
2931
quantity: "Quantity",
3032
showLess: "Show Less",
@@ -56,6 +58,8 @@ const locales = {
5658
refId: "מזהה הפניה: ",
5759
requestedBy: "ביקש על ידי ",
5860
payNow: "שלם עכשיו",
61+
addPaymentMethod: "הוסף אמצעי תשלום",
62+
authorizePayment: "אשר תשלום",
5963
yourCart: "העגלה שלך",
6064
quantity: "כמות",
6165
showLess: "הצג פחות",
@@ -87,6 +91,8 @@ const locales = {
8791
refId: "ID de référence: ",
8892
requestedBy: "Demandé par ",
8993
payNow: "Payer maintenant",
94+
addPaymentMethod: "Ajouter un mode de paiement",
95+
authorizePayment: "Autoriser le paiement",
9096
yourCart: "Votre panier",
9197
quantity: "Quantité",
9298
showLess: "Afficher moins",
@@ -118,6 +124,8 @@ const locales = {
118124
refId: "Ref Id: ",
119125
requestedBy: "Requested by ",
120126
payNow: "Pay now",
127+
addPaymentMethod: "Add Payment Method",
128+
authorizePayment: "Authorise Payment",
121129
yourCart: "Your Basket",
122130
quantity: "Quantity",
123131
showLess: "Show Less",
@@ -150,6 +158,8 @@ const locales = {
150158
refId: "معرف المرجع: ",
151159
requestedBy: "طلب بواسطة ",
152160
payNow: "ادفع الآن",
161+
addPaymentMethod: "إضافة طريقة دفع",
162+
authorizePayment: "تفويض الدفع",
153163
yourCart: "سلة التسوق الخاصة بك",
154164
quantity: "الكمية",
155165
showLess: "عرض أقل",
@@ -181,6 +191,8 @@ const locales = {
181191
refId: "参照 ID: ",
182192
requestedBy: "リクエスト者 ",
183193
payNow: "今すぐ支払う",
194+
addPaymentMethod: "支払い方法を追加",
195+
authorizePayment: "支払いを承認する",
184196
yourCart: "あなたのカート",
185197
quantity: "数量",
186198
showLess: "表示を減らす",
@@ -212,6 +224,8 @@ const locales = {
212224
refId: "Referenz-ID: ",
213225
requestedBy: "Angefordert von ",
214226
payNow: "Jetzt bezahlen",
227+
addPaymentMethod: "Zahlungsmethode hinzufügen",
228+
authorizePayment: "Zahlung autorisieren",
215229
yourCart: "Ihr Warenkorb",
216230
quantity: "Menge",
217231
showLess: "Weniger anzeigen",
@@ -243,6 +257,8 @@ const locales = {
243257
refId: "ID de référence: ",
244258
requestedBy: "Demandé par ",
245259
payNow: "Payer maintenant",
260+
addPaymentMethod: "Ajouter un mode de paiement",
261+
authorizePayment: "Autoriser le paiement",
246262
yourCart: "Votre panier",
247263
quantity: "Quantité",
248264
showLess: "Afficher moins",
@@ -275,6 +291,8 @@ const locales = {
275291
refId: "ID de referencia: ",
276292
requestedBy: "Solicitado por ",
277293
payNow: "Pagar ahora",
294+
addPaymentMethod: "Agregar método de pago",
295+
authorizePayment: "Autorizar pago",
278296
yourCart: "Tu carrito",
279297
quantity: "Cantidad",
280298
showLess: "Mostrar menos",
@@ -306,6 +324,8 @@ const locales = {
306324
refId: "ID de referència: ",
307325
requestedBy: "Sol·licitat per ",
308326
payNow: "Paga ara",
327+
addPaymentMethod: "Afegir mètode de pagament",
328+
authorizePayment: "Autoritza el pagament",
309329
yourCart: "El teu carret",
310330
quantity: "Quantitat",
311331
showLess: "Mostrar menys",
@@ -337,6 +357,8 @@ const locales = {
337357
refId: "ID de referência: ",
338358
requestedBy: "Solicitado por ",
339359
payNow: "Pagar agora",
360+
addPaymentMethod: "Adicionar método de pagamento",
361+
authorizePayment: "Autorizar pagamento",
340362
yourCart: "Seu Carrinho",
341363
quantity: "Quantidade",
342364
showLess: "Mostrar menos",
@@ -369,6 +391,8 @@ const locales = {
369391
refId: "ID di riferimento: ",
370392
requestedBy: "Richiesto da ",
371393
payNow: "Paga ora",
394+
addPaymentMethod: "Aggiungi metodo di pagamento",
395+
authorizePayment: "Autorizza il pagamento",
372396
yourCart: "Il tuo carrello",
373397
quantity: "Quantità",
374398
showLess: "Mostra meno",
@@ -400,6 +424,8 @@ const locales = {
400424
refId: "Identyfikator referencyjny: ",
401425
requestedBy: "Zażądane przez ",
402426
payNow: "Zapłać teraz",
427+
addPaymentMethod: "Dodaj metodę płatności",
428+
authorizePayment: "Autoryzuj płatność",
403429
yourCart: "Twój koszyk",
404430
quantity: "Ilość",
405431
showLess: "Pokaż mniej",
@@ -431,6 +457,8 @@ const locales = {
431457
refId: "Ref Id: ",
432458
requestedBy: "Aangevraagd door ",
433459
payNow: "Nu betalen",
460+
addPaymentMethod: "Betaalmethode toevoegen",
461+
authorizePayment: "Betaling autoriseren",
434462
yourCart: "Je winkelwagen",
435463
quantity: "Hoeveelheid",
436464
showLess: "Toon minder",
@@ -462,6 +490,8 @@ const locales = {
462490
refId: "Referens-ID: ",
463491
requestedBy: "Begärd av ",
464492
payNow: "Betala nu",
493+
addPaymentMethod: "Lägg till betalningsmetod",
494+
authorizePayment: "Auktorisera betalning",
465495
yourCart: "Din varukorg",
466496
quantity: "Antal",
467497
showLess: "Visa mindre",
@@ -493,6 +523,8 @@ const locales = {
493523
refId: "ID ссылки: ",
494524
requestedBy: "Запрошено ",
495525
payNow: "Оплатить сейчас",
526+
addPaymentMethod: "Добавить способ оплаты",
527+
authorizePayment: "Авторизовать платеж",
496528
yourCart: "Ваша корзина",
497529
quantity: "Количество",
498530
showLess: "Показать меньше",
@@ -524,6 +556,8 @@ const locales = {
524556
refId: "参考编号: ",
525557
requestedBy: "请求者: ",
526558
payNow: "立即付款",
559+
addPaymentMethod: "添加支付方式",
560+
authorizePayment: "授权付款",
527561
yourCart: "您的购物车",
528562
quantity: "数量",
529563
showLess: "显示较少",
@@ -555,6 +589,8 @@ const locales = {
555589
refId: "參考編號:",
556590
requestedBy: "請求者 ",
557591
payNow: "立即付款",
592+
addPaymentMethod: "新增付款方式",
593+
authorizePayment: "授權付款",
558594
yourCart: "你的購物車",
559595
quantity: "數量",
560596
showLess: "顯示較少",

0 commit comments

Comments
 (0)