Fix stripe being shown in Klarna and Square cases regardless of Stripe support

No difference in practice, since I believe all Klarna and Square countries are supported by Stripe, but for robustness this should be explicitly checked.
This commit is contained in:
Paul Dechov 2017-12-12 20:39:04 -05:00
parent b26a3ca1a2
commit b1b604b401
1 changed files with 9 additions and 4 deletions

View File

@ -1200,13 +1200,15 @@ class WC_Admin_Setup_Wizard {
* @return array
*/
protected function get_wizard_in_cart_payment_gateways() {
$country = WC()->countries->get_base_country();
$gateways = $this->get_wizard_available_in_cart_payment_gateways();
if ( ! current_user_can( 'install_plugins' ) ) {
return array( 'paypal' => $gateways['paypal'] );
}
$country = WC()->countries->get_base_country();
$can_stripe = $this->is_stripe_supported_country( $country );
if ( $this->is_klarna_checkout_supported_country( $country ) ) {
$spotlight = 'klarna_checkout';
} elseif ( $this->is_klarna_payments_supported_country( $country ) ) {
@ -1216,15 +1218,18 @@ class WC_Admin_Setup_Wizard {
}
if ( isset( $spotlight ) ) {
return array(
$offered_gateways = array(
$spotlight => $gateways[ $spotlight ],
'ppec_paypal' => $gateways['ppec_paypal'],
'stripe' => $gateways['stripe'],
);
if ( $can_stripe ) {
$offered_gateways += array( 'stripe' => $gateways['stripe'] );
}
return $offered_gateways;
}
$offered_gateways = array();
if ( $this->is_stripe_supported_country( $country ) ) {
if ( $can_stripe ) {
$gateways['stripe']['enabled'] = true;
$gateways['stripe']['featured'] = true;
$offered_gateways += array( 'stripe' => $gateways['stripe'] );