-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(core): add support for payment links localization #5530
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
900bb4f
add middleware for adding accept language header
fcbe2b7
chore: run formatter
hyperswitch-bot[bot] 90b6e93
resolve comments
8d10fdb
add localization support for payment links
49b2d16
git rebase main
9b97f09
chore: run formatter
hyperswitch-bot[bot] ee4b889
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] 03df1d6
move locales to different file
e9b72ad
chore: run formatter
hyperswitch-bot[bot] 5f507a5
exclued typos for locale.js
b7a4a94
add locale
4625b7e
move get_translation function to locale.js
698ccfb
resolve comments
3d8f7a6
Merge branch 'main' into localization_for_payment_links
srujanchikke 854ef6a
resolve comments
ba44e50
remove log
55c4a0a
resolve comments
a61c407
remove try
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14034,6 +14034,10 @@ | |
}, | ||
"payment_id": { | ||
"type": "string" | ||
}, | ||
"locale": { | ||
"type": "string", | ||
"nullable": true | ||
} | ||
} | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ pub async fn form_payment_link_data( | |
key_store: domain::MerchantKeyStore, | ||
merchant_id: common_utils::id_type::MerchantId, | ||
payment_id: String, | ||
locale: Option<String>, | ||
) -> RouterResult<(PaymentLink, PaymentLinkData, PaymentLinkConfig)> { | ||
let db = &*state.store; | ||
let payment_intent = db | ||
|
@@ -214,6 +215,7 @@ pub async fn form_payment_link_data( | |
redirect: false, | ||
theme: payment_link_config.theme.clone(), | ||
return_url: return_url.clone(), | ||
locale: locale.clone(), | ||
}; | ||
|
||
return Ok(( | ||
|
@@ -240,6 +242,7 @@ pub async fn form_payment_link_data( | |
merchant_description: payment_intent.description, | ||
sdk_layout: payment_link_config.sdk_layout.clone(), | ||
display_sdk_only: payment_link_config.display_sdk_only, | ||
locale, | ||
}); | ||
|
||
Ok((payment_link, payment_link_details, payment_link_config)) | ||
|
@@ -253,9 +256,20 @@ pub async fn initiate_secure_payment_link_flow( | |
payment_id: String, | ||
request_headers: &header::HeaderMap, | ||
) -> RouterResponse<services::PaymentLinkFormData> { | ||
let (payment_link, payment_link_details, payment_link_config) = | ||
form_payment_link_data(&state, merchant_account, key_store, merchant_id, payment_id) | ||
.await?; | ||
let locale = request_headers | ||
.get(header::ACCEPT_LANGUAGE) | ||
.and_then(|header_value| header_value.to_str().ok()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we log the error, instead of ignoring it! |
||
.map(|str| str.to_owned()); | ||
|
||
let (payment_link, payment_link_details, payment_link_config) = form_payment_link_data( | ||
&state, | ||
merchant_account, | ||
key_store, | ||
merchant_id, | ||
payment_id, | ||
locale, | ||
) | ||
.await?; | ||
|
||
validator::validate_secure_payment_link_render_request( | ||
request_headers, | ||
|
@@ -341,10 +355,17 @@ pub async fn initiate_payment_link_flow( | |
key_store: domain::MerchantKeyStore, | ||
merchant_id: common_utils::id_type::MerchantId, | ||
payment_id: String, | ||
locale: Option<String>, | ||
) -> RouterResponse<services::PaymentLinkFormData> { | ||
let (_, payment_details, payment_link_config) = | ||
form_payment_link_data(&state, merchant_account, key_store, merchant_id, payment_id) | ||
.await?; | ||
let (_, payment_details, payment_link_config) = form_payment_link_data( | ||
&state, | ||
merchant_account, | ||
key_store, | ||
merchant_id, | ||
payment_id, | ||
locale, | ||
) | ||
.await?; | ||
|
||
let css_script = get_color_scheme_css(&payment_link_config); | ||
let js_script = get_js_script(&payment_details)?; | ||
|
@@ -617,6 +638,7 @@ pub async fn get_payment_link_status( | |
key_store: domain::MerchantKeyStore, | ||
merchant_id: common_utils::id_type::MerchantId, | ||
payment_id: String, | ||
locale: Option<String>, | ||
) -> RouterResponse<services::PaymentLinkFormData> { | ||
let db = &*state.store; | ||
let payment_intent = db | ||
|
@@ -726,6 +748,7 @@ pub async fn get_payment_link_status( | |
redirect: true, | ||
theme: payment_link_config.theme.clone(), | ||
return_url, | ||
locale, | ||
}; | ||
let js_script = get_js_script(&PaymentLinkData::PaymentLinkStatusDetails(payment_details))?; | ||
let payment_link_status_data = services::PaymentLinkStatusData { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be an enum for validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to throw an error incase if client passes invalid enum of accept headers, that's the reason it was Option.