-
Notifications
You must be signed in to change notification settings - Fork 27
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
Payment Setting: properly display payment methods based on a given Omise Account (for admin) #151
Conversation
…count_country' parameter has been set properly.
'status' => __( 'Enabled', 'omise' ), | ||
'setting' => '' | ||
); | ||
<?php if ($settings['account_country']) : ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note; this seems to be a lot of changes but it only is because of this line and another following line.
The rest is about the changing of its indent.
new Omise_Payment_Truemoney | ||
); | ||
foreach ( $available_gateways as $gateway ) : | ||
if ( $gateway->is_country_support( $settings['account_country'] ) ) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note; continue from https://github.com/omise/omise-woocommerce/pull/151/files#r368338668
Here is another line that has been added. The rest is code indentation.
Would this not be better achieved using the Capability API? This would make it more future proof by preventing the need to change the code should the country availability of a payment method change. Admittedly, the downside to this is that some payment methods still do not appear in the capability API, so we'd need to wait for that to be done before release (but I believe it should be done soon). Arguably, the best solution would be a combination of using the Capability API, and what you have done. We could show all the payment methods available for the merchant country overall, and grey out the ones that are not currently available to that particular merchant |
@jonrandy Thanks for the input 👍 The Capability API is to list out available payment methods of that particular Omise account "at the moment". But what this pull request is trying to achieve here is to list all the payment methods that is available for that "country" regardless of if it can be used on that particular account or not. However, I would love to implement the Capability API once it done, to maximize this feature so the output can be:
"Here are 5 payment methods that you may use with the account that is registered under Thailand, currently 3 enabled and 2 disabled. To enable these 2 payment methods, please contact our support team". |
Yup, that was my arguable 'best solution' above that is the best of both worlds |
@jonrandy ah sorry I miss-read the whole sentence of |
new Omise_Payment_Creditcard, | ||
new Omise_Payment_Installment, | ||
new Omise_Payment_Internetbanking, | ||
new Omise_Payment_Truemoney |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow - they're even alphabetised! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have the feeling this list of available gateways really belongs at a higher level as it feels like something that may be used again elsewhere. It's ok here for now though I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the input 👍
Now you have mentioned and it got me to think that probably the main Omise
class (omise-woocommerce.php) would also likely to be a place where this can also be implemented if not too complex.
Note for idea (but not in anytime soon)
foreach ( Omise::available_payment_methods() as $methods ) {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also note for myself. I think gateways
is a not so good name. methods
would be more accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I mentioned it because I'm doing something similar in my Prestashop refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some comments there with thoughts for the future though
works great.. |
1. Objective
Previously all the payment methods that have been implemented to the plugin will be shown at WooCommerce Payment Setting page, regardless on a given Omise account.
For instance, using Omise Japan account at Omise-WooCommerce plugin, you will see all the payment methods, including those that can be used only for Omise Thailand.
This, is believed to cause a bad user-experience and a confusion for all the merchants outside Thailand.
Related information:
Related issue(s): T18705
2. Description of change
At WordPress's
wp_options
table, option_name:woocommerce_omise_settings
, there will be 3 new parameters:account_id
,account_email
, andaccount_country
.Before
After
.
2. At the Admin Payment Setting page, add a condition to display only payment methods that are available for that specific Omise account's country.
Before

The below screenshot: all the payment methods are listed at the payment setting page regardless on a given Omise account.
After

The below screenshot: hide all the payment methods if Omise account's credential hasn't been set.
The below screenshot: Once the Omise account has been set, the payment methods will be shown accordingly to the given account (in this case, Thailand account).

The below screenshot: Once the Omise account has been set, the payment methods will be shown accordingly to the given account (in this case, Japan account).

3. Quality assurance
🔧 Environments:
✏️ Details:
There are 2 possible cases.
The following code should detect and auto-update its database to meet with the condition of displaying payment methods by a given Omise account.
https://github.com/omise/omise-woocommerce/pull/151/files#diff-9849043e36d1d7b568f325534b722341R77
As for user perspective, they wouldn't need to do any extra step.
This group should be no problem as described at the section 2. Description of change, [2].
4. Impact of the change
As described at the section 2. Description of change, [1]. There will be 3 new parameters saved at WordPress's
wp_options
table, option_name:woocommerce_omise_settings
.5. Priority of change
Normal
6. Additional Notes
No