Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Klarna's preferred locale #3428

Merged
merged 5 commits into from
Sep 13, 2024

Conversation

annemirasol
Copy link
Contributor

@annemirasol annemirasol commented Sep 10, 2024

Fixes #3087

Changes proposed in this Pull Request:

For a more consistent experience for the shopper, we would like to render the Klarna payments page in the store locale.

Stripe limits Klarna localization to the set of supported locales for the billing country. For cases where the exact store locale is not supported, we will use the closest one. For example, if the store locale is "fr_FR" and the billing country is "Canada", we will set the preferred locale to "fr-CA" instead of "fr-FR".

If the store locale's language is not supported for the billing country, e.g. "fr" for "US", we do not pass a preferred locale and let Klarna decide on the default behavior.

Testing instructions

  1. Assumption: your Stripe test account's country is USA.
  2. Enable Klarna as a payment method in WC Stripe.
  3. Choose "Español" as your store locale: wp-admin/options-general.php
  4. As a shopper, add a product and go to checkout.
  5. Choose "United States" as your billing country.
  6. Select Klarna as your payment option and click "Place Order".
  7. BEFORE THIS PR: The Klarna payment page is in English.
  8. AFTER THIS PR: The Klarna payment page is in Spanish.
  9. To test Klarna's expected default behavior: set the store locale to "Français" and the billing country to "United States". The Klarna page should be in English.

To test other combinations:

  • Choose a billing country for which Klarna supports at least two locales, e.g. Canada.
  • Make sure your Stripe test account country is the same as your billing country, and the currency requirements are met, in order for Klarna to show up as an option during checkout.
  • As your store locale, choose the locale that is not the default locale for the billing country. For example, for Canada, choose "Français du Canada" as your store locale. This is not a requirement; this is only so we can reasonably say that the behavior is because of our code, and not because of Klarna defaults.

Screenshots

With store locale as "es_ES", and billing country in "US", we set Klarna's preferred locale to "es-US"
Screenshot 2024-09-09 at 10 38 11 PM


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@annemirasol annemirasol self-assigned this Sep 10, 2024
@annemirasol annemirasol requested review from a team and james-allan and removed request for a team September 12, 2024 14:47
@annemirasol annemirasol marked this pull request as ready for review September 12, 2024 14:50
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR @annemirasol! 💯

I tested the example scenario you mentioned:

Develop This branch

Screenshot 2024-09-13 at 4 22 21 PM
Klarna shown in English on Español site

Screenshot 2024-09-13 at 4 26 59 PM
Klarna shown in Español on Español site

I tested a couple of other scenarios like a Australian Stripe Account with the locale set to "Australian" english. I tested a French account set to French => FR, English => EN and an ineligible locale (Spanish) => EN which I expect is the default for my account.

I also verified your mapping of Stripe's documentation on Klarna locales is correct to make sure none were missing or incorrect.

@annemirasol annemirasol merged commit 9db11ce into develop Sep 13, 2024
35 checks passed
@annemirasol annemirasol deleted the tweak/3087-set-klarna-preferred-locale branch September 13, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Klarna] Render the Klarna payments page in the store locale
2 participants