Closed (fixed)
Project:
Commerce Stripe
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Jun 2017 at 04:11 UTC
Updated:
13 Apr 2018 at 22:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
torgospizzaChanging the subject line since this issue is actually broader than any single currency.
Right now the currencies supported for payments varies by the country where the Stripe account was created (see #2822198: stripe_payment currencies list).
Attached is a patch which does the following:
- adds new function
commerce_stripe_payment_currencies()for retrieving currently supported Stripe currencies based on the account making the request;- updates the
hook_requirements()implementation to accommodate this, and show an error if the Commerce default currency is not supported by the store's Stripe account;- updates the Stripe payment methods configuration form to only include in the currency select list, currencies that are supported by the Stripe account.
I've tested the patch and it is working for me (even on an older API version) so give it a shot.
Comment #3
carrotandme commented@torgosPizza
Thank you for the patch.
I tried it for 7.x-3.0-alpha1 and 7.x-3.x-dev. And, I encountered the same error in both of them, when I click "Enable payment method: Stripe" in the payment method rules(/admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe).
Here is what the warning and error message say.
I also upload the capture of the error page.
Do you have any idea of what is wrong?
Thank you.
Comment #4
torgospizzaHello,
Yes - when you enable the payment method, you have to click the "Edit" link for the payment method's settings (it will be something like admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe/edit/3, and enter your API keys from your Stripe Dashboard.
You'll have to enter your Stripe API keys before you'll actually be able to accept payment in Stripe.
If you've already done so, then there is another issue, but I'd need to know more first.
Comment #5
torgospizza@carrotandme: Were you able to get this fixed? Clicking on the link found in that error message page should take you to where you'd need to go to update your configuration. That would include things like your integration type.
Please review this ASAP so I can commit to dev. Thanks!
Comment #6
carrotandme commented@torgosPizza
I'm sorry for being late.
Actually, those messages appear at
Enable payment method: Stripe, /admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe/edit/3.
(I'm so sorry that I didn't write exactly the place where the error messages appear.) So I have still have the same problem.
Comment #7
torgospizza@carrotandme: Can you confirm that you've entered your keys into the configuration settings form? The only reason I can see that message showing up is if you haven't entered your keys yet.
Comment #8
carrotandme commented@torgosPizza Thank you for your quick reply.
The error message still appears, but the warning one disappeared.
Here is what I did this time.
1. Istalled cleanly & enabled the module again(at this point, I did't applied your patch yet).
2. At "Enable payment method: Stripe"(/admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe/edit/3), input my stripe Publishable key & Secret key. And, of course, there is no error message then.
3. Applied your patch. And, replaced the files modified in server(So, Publishable key & Secret key are not deleted.).
4. Clicked "Enable payment method: Stripe". And, I found that the error message still appears.
Comment #9
torgospizzaOh, right, I see now. Problem is we're loading the library and calling Stripe API methods... and our current library does not have a global API config.
This is one of the reasons why having Stripe's focus narrowed down into a "per-payment method" config with Commerce Stripe is somewhat bad practice. Because _commerce_stripe_set_api_key() expects a payment method, and loading the library does not automatically mean we are setting a key (such as how we are with the main Stripe module).
However there is a solution for this - just have to load the default Commerce Stripe payment method and set the API Key using the _commerce_stripe_set_api_key() method. Attached is a new patch which does this, and the interdiff (which is just two additional lines). Please give the new patch a try.
Thanks for your step-by-step instructions on how to reproduce :)
Comment #10
carrotandme commented@torgosPizza Thank you for the new patch!
I tried it on the same steps I wrote at #8. Now, I can visit the "Enable payment method: Stripe" page.
But, new error messages appeared then.
And, the Select List at Currency becomes empty. Please refer to the uploaded image.
Comment #11
torgospizzaArgh. Sorry. Apparently some changes didn't make it into that patch, either. Please try this last one. (I've tested it and it works for me... )
Thanks and sorry again!
Comment #12
carrotandme commented@torgosPizza Thank you for the new patch!
I tried #11 on 7.x-3.x-dev with my test stripe account. It worked on the step of #8.
But, if I try to install the module after deleting sectet&puclick key by uninstalling it, it displays the warning&error message below at "Enable payment method: Stripe".
But, anyway, it works without deleting those key information. Thak you for the patch!
Comment #13
torgospizzaWell, that's progress anyway! And this last warning is an easy fix. Basically we call the the setApiKey() method without verifying a key exists - we're just kind of assuming that it's there, even if a payment method has just been enabled. (Those values will not exist until you enter them, which is why this error is being thrown.)
We might be able to test for this earlier on, but I think it makes sense to not try to set an API Key unless one is detected. Attached is a new patch including this change, and an interdiff from the previous patch :)
Thanks for your help in testing!
Comment #14
carrotandme commentedHi, thank you so much for the new patch!
I tested it after deleting public & secret key by uninstalling the module. A part of the message I wrote at #12 still remains.
Stripe\Error\Authentication: No API key provided. (HINT: set your API key using "Stripe::setApiKey(<API-KEY>)". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions. in Stripe\ApiRequestor->_requestRaw() (line 177 of /home/myserver/mydomain.com/public_html/sites/all/libraries/stripe-php/lib/ApiRequestor.php).Comment #15
torgospizzaOh! I was not thorough enough. New patch attached checks for a key to be set, before calling the Stripe API. Sorry I missed that.
New patch is a little more conservative in its expectations. Please give it another shot. Thanks!
Comment #16
carrotandme commentedHi, thank you for quick fixing!
I tried the patch. The error message disappear. And, now I can access "Enable payment method: Stripe" page.
But, the select list for Currency gets empty. It is the same problem as the on the image at #10.
Comment #17
torgospizzaComment #18
efpapado commented#15 works for me, tested in Norway with Norwegian Krone (NOK) currency.
Comment #19
millionleaves commentedJust applied this patch to the 7.x-3.x-dev from March 13, 2018, with the 5.6 Stripe PHP library, and it works for NZD.
Thanks!
Comment #20
torgospizzaAwesome, thanks for testing!
I'll mark this RTBC and see about getting it into dev quickly.
Comment #22
torgospizzaI've committed this to dev.
@carrotandme: I think that issue may be unrelated, so we can open that in another thread. I think I might actually have this fixed, but it is something that is in my current "in-progress" version that integrates with the Stripe module more cleanly. I'll be pushing that soon.
Comment #23
torgospizzaI'll set to fixed, but if any other errors regarding currency support pop up, please reopen or create a follow-up.