Problem/Motivation
The administration UI allows switching between Sandbox and Live credentials (radio), but you can only EITHER store the live credentials OR the sandbox credentials.
Instead of only having the two input fields for client ID and secret, there should be two for sandbox and two for live.
Switching could then show / hide them via form states API.
In all payment provider implementations I know allows to store both. For good reasons :)
Steps to reproduce
Proposed resolution
Remaining tasks
Check if 8.x-1.x has the same implementation
User interface changes
API changes
Data model changes
Issue fork commerce_paypal-3321915
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyDoes anyone know if the same issue exists for the Drupal 8 version? Then it should also be fixed there.
Comment #3
anybodyLooks like 8.x-1.x has the same flaw, so perhaps we should implement it for 8.x-1.x first and backport it then, if needed.
See https://git.drupalcode.org/project/commerce_paypal/-/blob/8.x-1.x/src/Pl...
Comment #6
anybodyHappy about first reviews, but please note that this is still WIP for both branches. Just some first implementations to show the idea behind.
Comment #7
jsacksick commentedThis probably isn't going to happen. We usually don't recommend storing plain credentials in the database... Often times credentials are set from either settings.php or via the https://www.drupal.org/project/key module.
Comment #8
jsacksick commentedWell actually, having extra config keys would also allow to override both from config.
However, the form should be smart and just toggle the fields based on the selected mode so the sandbox fields are only shown when the sandbox mode is selected.
Also... You're missing changes to the schema.yml file and code in submitForm() to actually store the submitted values for the sandbox client ID and secret.
Comment #9
anybodyHi @jsacksick, thank you very much for the review! I much appreciate your comment in #7 about storing the credentials in the settings.php or the key module. So I've opened a separate issue to add this important information to the configuration form: #3322047: In the UI inform the user about safely storing API credentials
Perhaps you'd like to help working on that then?
Also I very much appreciate your decision to reopen the issue and see the benefit in this. This makes the existing switch between "Live" and "Sandbox" even more useful (where ever credentials are stored). So thank you! :)
As written in the issue summary:
I agree and already started the implementation, but didn't have the time yet to finish and test that.
Thanks for the heads up, you're absolutely right. I didn't make it yesterday evening, but will proceed working on this.
#6
I'll keep you updated :) Thanks a lot!
Comment #10
anybodyComment #11
jsacksick commentedBy the way, in the 8.x version there is also no need to add a "server" setting as there is a "mode" for that.
The mode has 2 possible values "test" or "live".
Comment #12
anybodyCan you explain that in detail? I didn't add something like that, see https://git.drupalcode.org/project/commerce_paypal/-/merge_requests/15/d...
In 7.x I just moved the setting above the inputs. It was below before. Nothing added.
Comment #13
jsacksick commentedSo I think I was checking the 7.x by mistake... I think it's best to do this in 2 separate issues to avoid confusion. One for each version.
Comment #14
grevil commentedComment #15
grevil commentedI opened a seperate 7.x issue here in #3327419: [7.x] Allow to store live and sandbox credentials for easy switching.
Comment #17
anybodyThanks @Grevil! :)
Comment #18
anybodyI'll further work on this asap.
Comment #19
grevil commentedComment #20
grevil commentedOk, this is it! Done!
Comment #21
damienmckennaWouldn't it be better to clearly document how to override the credentials via settings.php?
Comment #22
anybody@damienmckenna thanks for your reply. In my eyes both is true.
Currently the issue is, that theres a "Live" vs. "Sandbox" switch, but you can only store public / private key for one of them. This combination doesn't make much sense in our eyes.
When switching the radio, you have to exchange the keys and enter the opposite ones and when switching back, same again...
The goal here is to add separate fields & config values for live and sandbox credentials, so you can switch at any time, if you need to, by just switching the radio.
Of course it should also be documented how to set these values in settings.php.
Comment #23
anybodySo let's wait for final feedback how to finish this then, or any additions @damienmckenna?
Comment #24
rgpublicFWIW just some encouragement to go head with this: Overriding is certainly an alternative, but far less discoverable. The UI is already there and other payment modules use it correctly, so this is currently quite counter-intuitive. It should therefore be implemented IMHO. It's useful!