From 995374d2d17fc86eeefe9f0e55aa8783e6739868 Mon Sep 17 00:00:00 2001 From: Dan Paun <82826872+dpaun1985@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:50:18 +0300 Subject: [PATCH] Fix Apple Pay and Google Pay if card payments are disabled (#7250) Co-authored-by: Dan Paun --- changelog/fix-5945-add-default-cc-enabled | 4 ++++ .../server/request/class-create-and-confirm-intention.php | 8 -------- includes/payment-methods/class-upe-payment-gateway.php | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 changelog/fix-5945-add-default-cc-enabled diff --git a/changelog/fix-5945-add-default-cc-enabled b/changelog/fix-5945-add-default-cc-enabled new file mode 100644 index 00000000000..ead1017db74 --- /dev/null +++ b/changelog/fix-5945-add-default-cc-enabled @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix Apple Pay and Google Pay if card payments are disabled. diff --git a/includes/core/server/request/class-create-and-confirm-intention.php b/includes/core/server/request/class-create-and-confirm-intention.php index 3313caa052b..725c3361378 100644 --- a/includes/core/server/request/class-create-and-confirm-intention.php +++ b/includes/core/server/request/class-create-and-confirm-intention.php @@ -80,14 +80,6 @@ public function set_off_session( bool $off_session = true ) { * @throws Invalid_Request_Parameter_Exception When there are no payment methods provided. */ public function set_payment_methods( array $payment_methods ) { - // Hard to validate without hardcoding a list here. - if ( empty( $payment_methods ) ) { - throw new Invalid_Request_Parameter_Exception( - __( 'Intentions require at least one payment method', 'woocommerce-payments' ), - 'wcpay_core_invalid_request_parameter_missing_payment_method_types' - ); - } - $this->set_param( 'payment_method_types', $payment_methods ); } diff --git a/includes/payment-methods/class-upe-payment-gateway.php b/includes/payment-methods/class-upe-payment-gateway.php index 339a90f91b1..52226ad3373 100644 --- a/includes/payment-methods/class-upe-payment-gateway.php +++ b/includes/payment-methods/class-upe-payment-gateway.php @@ -989,6 +989,7 @@ public function get_payment_method_ids_enabled_at_checkout( $order_id = null, $f $enabled_payment_methods = []; $active_payment_methods = $this->get_upe_enabled_payment_method_statuses(); + foreach ( $upe_enabled_payment_methods as $payment_method_id ) { $payment_method_capability_key = $this->payment_method_capability_key_map[ $payment_method_id ] ?? 'undefined_capability_key'; if ( isset( $this->payment_methods[ $payment_method_id ] ) ) {