diff --git a/includes/class-wc-gateway-custom-paystack.php b/includes/class-wc-gateway-custom-paystack.php index 0b45939..7eee505 100644 --- a/includes/class-wc-gateway-custom-paystack.php +++ b/includes/class-wc-gateway-custom-paystack.php @@ -298,7 +298,6 @@ public function channels() { 'bank' => __( 'Pay with Bank', 'woo-paystack' ), 'ussd' => __( 'USSD', 'woo-paystack' ), 'qr' => __( 'QR', 'woo-paystack' ), - 'mobile_money' => __( 'Mobile Money', 'woo-paystack' ), 'bank_transfer' => __( 'Bank Transfer', 'woo-paystack' ), ); @@ -503,10 +502,6 @@ public function payment_scripts() { $paystack_params['qr_channel'] = 'true'; } - if ( in_array( 'mobile_money', $this->payment_channels ) ) { - $paystack_params['mobile_money_channel'] = 'true'; - } - if ( in_array( 'bank_transfer', $this->payment_channels ) ) { $paystack_params['bank_transfer_channel'] = 'true'; } diff --git a/includes/class-wc-gateway-paystack.php b/includes/class-wc-gateway-paystack.php index ceac965..886609b 100644 --- a/includes/class-wc-gateway-paystack.php +++ b/includes/class-wc-gateway-paystack.php @@ -690,7 +690,6 @@ public function payment_scripts() { $paystack_params['card_channel'] = 'true'; $paystack_params['ussd_channel'] = 'true'; $paystack_params['qr_channel'] = 'true'; - $paystack_params['mobile_money_channel'] = 'true'; $paystack_params['bank_transfer_channel'] = 'true'; } @@ -888,15 +887,20 @@ public function process_redirect_payment_option( $order_id ) { $currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->order_currency; $callback_url = WC()->api_request_url( 'WC_Gateway_Paystack' ); + $payment_channels = $this->get_gateway_payment_channels( $order ); + $paystack_params = array( 'amount' => $amount, 'email' => $email, 'currency' => $currency, 'reference' => $txnref, 'callback_url' => $callback_url, - 'channels' => [ 'card', 'bank', 'ussd', 'qr', 'mobile_money', 'bank_transfer' ], ); + if ( ! empty( $payment_channels ) ) { + $paystack_params['channels'] = $payment_channels; + } + if ( $this->split_payment ) { $paystack_params['subaccount'] = $this->subaccount_code; @@ -1754,4 +1758,28 @@ protected function is_autocomplete_order_enabled( $order ) { return $autocomplete_order; } + /** + * Retrieve the payment channels configured for the gateway + * + * @since 5.7 + * @param WC_Order $order Order object. + * @return array + */ + protected function get_gateway_payment_channels( $order ) { + + $payment_method = $order->get_payment_method(); + + if ( 'paystack' === $payment_method ) { + return array(); + } + + $payment_channels = $this->payment_channels; + + if ( empty( $payment_channels ) ) { + $payment_channels = array( 'card' ); + } + + return $payment_channels; + } + }