-
Notifications
You must be signed in to change notification settings - Fork 211
Show payment methods available in the PMC on settings page #4252
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
base: develop
Are you sure you want to change the base?
Conversation
…ove reset_primary_configuration in favor of clear_primary_configuration_cache
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.
The implementation looks good, the only comment is renaming the get_upe_available_payment_methods
function in WC_Stripe_Payment_Method_Configurations
@Mayisha, could you add more context to the PR so we can test it before @diegocurbelo is available? |
@daledupreez I have added the description and addressed the feedback. |
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.
It looks like there are a number of legitimate unit test failures that we need to resolve before we can merge this.
@Mayisha, let me know if you'd like to hand over work on getting the tests working.
$available_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_available_payment_methods( true ) : WC_Stripe_Helper::get_legacy_available_payment_method_ids(); | ||
$ordered_payment_method_ids = $is_upe_enabled ? WC_Stripe_Helper::get_upe_ordered_payment_method_ids( $this->gateway ) : $available_payment_method_ids; | ||
$enabled_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_enabled_payment_method_ids( true ) : WC_Stripe_Helper::get_legacy_enabled_payment_method_ids(); | ||
|
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 have one concern here: we're forcing two refreshes of the PMC from Stripe when $is_upe_enabled
, as we're supplying $force_refresh = true
to both $this->gateway->get_upe_available_payment_methods()
and $this->gateway->get_upe_enabled_payment_method_ids( true )
. We should only trigger one re-fetch.
$available_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_available_payment_methods( true ) : WC_Stripe_Helper::get_legacy_available_payment_method_ids(); | |
$ordered_payment_method_ids = $is_upe_enabled ? WC_Stripe_Helper::get_upe_ordered_payment_method_ids( $this->gateway ) : $available_payment_method_ids; | |
$enabled_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_enabled_payment_method_ids( true ) : WC_Stripe_Helper::get_legacy_enabled_payment_method_ids(); | |
// Note that we specify the $force_refresh parameter for this fetch only, and not when fetching enabled payment methods below. | |
$available_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_available_payment_methods( true ) : WC_Stripe_Helper::get_legacy_available_payment_method_ids(); | |
$ordered_payment_method_ids = $is_upe_enabled ? WC_Stripe_Helper::get_upe_ordered_payment_method_ids( $this->gateway ) : $available_payment_method_ids; | |
$enabled_payment_method_ids = $is_upe_enabled ? $this->gateway->get_upe_enabled_payment_method_ids( false ) : WC_Stripe_Helper::get_legacy_enabled_payment_method_ids(); | |
$available_payment_method_ids = []; | ||
$merchant_payment_method_configuration = self::get_primary_configuration( $force_refresh ); | ||
|
||
if ( $merchant_payment_method_configuration ) { |
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 am not clear on why this code is not checking/calling self::is_enabled()
. We are checking that in get_upe_enabled_payment_method_ids()
below, and in the current calling code, so I am not sure why we're skipping the check here.
My initial suspicion is that is_enabled()
is checking for write permissions, where we only need to read what functions are available for the account. But then I got confused across the various cases.
@@ -39,7 +38,6 @@ class WC_Stripe_UPE_Payment_Gateway extends WC_Gateway_Stripe { | |||
WC_Stripe_Payment_Methods::OXXO => WC_Stripe_UPE_Payment_Method_Oxxo::class, | |||
WC_Stripe_Payment_Methods::SEPA => WC_Stripe_UPE_Payment_Method_Sepa::class, | |||
WC_Stripe_Payment_Methods::P24 => WC_Stripe_UPE_Payment_Method_P24::class, | |||
WC_Stripe_Payment_Methods::SOFORT => WC_Stripe_UPE_Payment_Method_Sofort::class, |
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.
This removal is causing unit test failures, and I am not sure how it's related to fixing the original issue.
At the very least we need to fix the unit test failures, but it feels like this should be something tackled by a different PR.
In the current PMC implementation, we are syncing the enabled/disable payment methods between plugin settings and Stripe dashboard. But the list of available payment methods in plugin settings is not aligned with the payment method configuration. As a result, we show some payment methods in the settings page that are not available in the PMC.
Changes proposed in this Pull Request:
get_upe_available_payment_methods
is called.Testing instructions
develop
, go to the payment methods tab and notice that you have OXXO, Boleto, ACSS available in the payment method list.Save
and refresh your page.Error:
acss_debitis not available to this merchant
.