Skip to content

Restrict Affirm and Klarna to domestic and cross EEA border transactions #3108

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

Merged
merged 8 commits into from
May 5, 2024

Conversation

james-allan
Copy link
Contributor

@james-allan james-allan commented May 1, 2024

Fixes #3096

Changes proposed in this Pull Request:

Customers paying with Klarna, Affirm and Afterpay/Clearpay have specific cross border restrictions they must adhere to. ie Customers can only purchase from the same country the Stripe account is located. eg AU to AU. The one exception to this is Klarna where customers and merchants located in the European Economic Area (EEA) + the UK and Switzerland can also transact. eg a customer in the UK can transact with a merchant in Germany.

This is documented in Stripe docs:

This PR implements this restriction by ensuring that the payment method is only enabled on checkout if the transaction is considered domestic using their respective ruleset.

Testing instructions

Strictly Domestic - eg US.

  1. Add Stripe API credentials for a country that is eligible for Klarna eg US.
  2. Make sure to set your store currency to the matching currency.
  3. Enable Klarna as a payment method.
  4. Add a simple product to your cart.
  5. Go to the checkout.
  6. Change your billing country to a country that doesn't match your Stripe Account's base country. eg if your account is in the US, set it AU or something else.
  7. On this branch Klarna should not be available.
  8. Change your billing country to match the stripe accounts country.
  9. It should now be shown.

EEA

  1. Create a EU based Stripe Account
  2. Add Stripe API credentials for a country that is eligible for Klarna and located in the EU eg France.
  3. Make sure to set your store currency to the matching currency eg Euro.
  4. Enable Klarna as a payment method.
  5. Add a simple product to your cart.
  6. Go to the checkout.
  7. Change your billing country to a country any country in the EU that doesn't match your Stripe Account's base country. eg if your account is in the France, set it Germany or something else.
  8. Klarna should be available.
  9. Change your billing country to match the Stripe account's country.
  10. Klarna should be available.
  11. Change your billing country to the US or AU etc.
  12. Klarna shouldn't be available.

  • 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

@james-allan james-allan marked this pull request as ready for review May 1, 2024 06:56
@james-allan
Copy link
Contributor Author

Placing this one on-hold as I think there's a better way to approach this and it will fix it for the Block checkout too.

@james-allan james-allan added the status: on hold The issue is currently not prioritized. label May 1, 2024
@james-allan
Copy link
Contributor Author

@a-danae do you mind reviewing this one. I've tweaked your code that you introduced in #3040 so wanted to double check this is inline with your understanding of the code you introduced.

*/
public function get_countries() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was only used to populate the JS data with a list of eligible countries. Given I've changed it's purpose to return billing countries, I changed the name. Because this function is unreleased, there are no backwards compatibility concerns here.

@james-allan james-allan removed the status: on hold The issue is currently not prioritized. label May 1, 2024
Copy link
Contributor

@a-danae a-danae left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this, @james-allan ! Things look good to me 👍

I tested the following scenarios:

US Stripe account
✅ Domestic country - US
✅ Non-domestic, Klarna-supported country - AU
✅ Non-supported country - MX

France Stripe account
✅ Domestic country - FR
✅ Country from within the EEA - ES
✅ Non-domestic, Klarna-supported country - AU
✅ Non-supported country - MX

UK Stripe account
✅ Domestic country - UK
✅ Non-domestic, Klarna-supported country - AU
✅ Non-supported country - MX

🟡 Cross-border transactions where the currency of the Stripe account and the customer billing country don't match are failing. We could address that separately - #3118

This PR also fixed a console error we were getting when changing the billing country from a non-supported to a supported one 🎉

Glad to see this merged. Thanks again!

@a-danae
Copy link
Contributor

a-danae commented May 5, 2024

Merging this PR to create the test package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Klarna] Handle non-domestic transactions for shoppers from supported countries
2 participants