Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions includes/class-wc-gateway-custom-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
);

Expand Down Expand Up @@ -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';
}
Expand Down
32 changes: 30 additions & 2 deletions includes/class-wc-gateway-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

}