-
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
Conversation
.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 comment
The reason will be displayed to describe this comment to others. Learn more.
can we log the error, instead of ignoring it!
.get(actix_web::http::header::ACCEPT_LANGUAGE) | ||
.and_then(|header_value| header_value.to_str().ok()) | ||
.map(|str| str.to_owned()); |
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.
+1
@@ -92,6 +99,7 @@ pub async fn initiate_secure_payment_link( | |||
let payload = api_models::payments::PaymentLinkInitiateRequest { | |||
payment_id, | |||
merchant_id: merchant_id.clone(), | |||
locale: None, |
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.
is the locale only for open payment links, and not iframe embeded links?
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.
PaymentLinkRequest
is used for both payment links and secure payment links. In the case of payment links and status routes, we pass the locale to the flow. However, secure links already pass headers to the initiate_secure_payment_link_flow
function. So I was consuming the locale from headers in secure_payment_link, and in all other cases, I am not passing headers to flows; instead, I am directly passing the locale.
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.
can we unify it, it looks confusing at first glance!
.get(actix_web::http::header::ACCEPT_LANGUAGE) | ||
.and_then(|header_value| header_value.to_str().ok()) | ||
.map(|str| str.to_owned()); | ||
let payload = api_models::payments::PaymentLinkInitiateRequest { |
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.
+1
@@ -92,6 +99,7 @@ pub async fn initiate_secure_payment_link( | |||
let payload = api_models::payments::PaymentLinkInitiateRequest { | |||
payment_id, | |||
merchant_id: merchant_id.clone(), | |||
locale: None, |
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.
can we unify it, it looks confusing at first glance!
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.
rest looks good
@@ -64,6 +65,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>, |
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.
…e-connector-label-cypress * 'main' of github.com:juspay/hyperswitch: feat(core): add support for payment links localization (#5530) refactor(router): refactor `merchant_connector_account` retrieve and delete v2 apis (#5528) feat(cypress): add core flow tests (#5546) feat(cypress): add mandates and refunds variation cases (#5513) feat(cypress): add configs for not overriding screenshots (#5524) refactor(business_profile): use concrete types for JSON fields (#5531) feat(customer_v2): add customer create v2 endpoint (#5444) refactor(connector): added amount conversion framework for Mifinity (#5460) refactor(connector): added amount conversion framework for Boku (#5459) chore(version): 2024.08.07.0
Type of Change
Description
Add support for payment link localization in backend.
Additional Changes
Motivation and Context
This pr also passed locale from backend to SDK from Accept-Language headers. Static strings in javascript are declared in key value pairs in js, Using locale we transform the language.
The available languages in the locales constant are:
How did you test it?
Create a payment link - you can choose any language from above, pass short form any language. below i choose
zh
(chinese).Step 1 :
after redirection everything should be chinese in payment link page.
Failure page :
Success page :
Test Case 2: Failed case , pass invalid Aceept-Language in header, it shoulb be able to default it to english.
Test Case 3: Enter pay now without redirecting after hitting payment link , error message should be in Accept-language
Test case 4: Test the same for secure payment links
Checklist
cargo +nightly fmt --all
cargo clippy