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

how to set the Zone for other endpoint than us? #57

Open
hefan opened this issue Jul 16, 2023 · 7 comments
Open

how to set the Zone for other endpoint than us? #57

hefan opened this issue Jul 16, 2023 · 7 comments

Comments

@hefan
Copy link
Contributor

hefan commented Jul 16, 2023

At the moment the extension seems to always connect with the default endpoint from klarna_proxy
https://api-na.klarna.com (production)
https://api-na.playground.klarna.com (test)
see here https://github.com/nebulab/klarna_proxy/blob/main/lib/klarna/configuration.rb#L9

Is there a possibility to add a zone parameter or something similar to be able to send to the europe or oceania servers?

@kennyadsl
Copy link
Member

Hey @hefan! Reading the code I think you can do:

klarna_config = Klarna::Configuration.new
klarna_config.zone = :europe

and this line will pick up the right endpoint.

Let me know if that's correct, please!

BTW, I think it's a good idea to make it configurable, so if you want to contribute for that, I guess it's a good change.

@kennyadsl
Copy link
Member

kennyadsl commented Jul 17, 2023

Also, reading this other piece, you can probably add to an initializer:

Klarna.configuration do |config|
  config.zone = :europe
end

cc @vassalloandrea (pinging you because you are among the authors of that extension)

@hefan
Copy link
Contributor Author

hefan commented Jul 17, 2023

Hello @kennyadsl

Adding

Klarna.configure do |config|
  config.zone = :europe
end

to an initializer went well in my case, thank you!

However, for being able to configure it, zone needs to be added at least to
https://github.com/solidusio-contrib/solidus_klarna_payments/blob/master/lib/active_merchant/billing/klarna_gateway.rb#L13
and
https://github.com/solidusio-contrib/solidus_klarna_payments/blob/master/app/services/solidus_klarna_payments/validate_klarna_credentials_service.rb#L7

The Zone should be added as a dropdown for the three zones in the payment method settings, i suppose.
Maybe it could also be a good idea to leave it as an initializer and tell about zones in the Readme.

If you tell me what is the way you would prefer, i am happy to open a pull request theses days.

@kennyadsl
Copy link
Member

I think the initializer is the best trade-off for now, and we can fix it immediately. If you have extra time for proposing to change it with something in the Admin UI, it would be great as well, but could come later. 🙏

@hefan
Copy link
Contributor Author

hefan commented Jul 17, 2023

so it would be best to mention in Readme, no?

@kennyadsl
Copy link
Member

Yes!

@hefan
Copy link
Contributor Author

hefan commented Jul 17, 2023

ok. i will open a respective pull request later or tomorrow..

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

No branches or pull requests

2 participants