I recently created a plugin for customized payment platforms on WooCommerce, it seems to work in the back-end and I can activate this custom payment gateway from the settings, but it doesn't seem to show in WooCommerce checkout page (I am using Checkout Blocks).
Code:
<?php
/**
* Plugin Name: Custom Plugin for Woocommerce Subscriptions + Xendit
* Plugin URI:
* Author Name: Emmanuel John Navarro
* Description: Plugin integration to create subscription based payments with automated integration to Xendit
* Version 0.1.0
*
*
*/
add_action('plugins_loaded', 'woocommerce_xen_payment_init',00);
function woocommerce_xen_payment_init(){
if(class_exists('WC_Payment_Gateway')){
#[AllowDynamicProperties]
class WC_xen_payment extends WC_Payment_Gateway{
public function __construct() {
$this->id = 'xen_payment';
$this->icon = apply_filters('woocommerce_payment_icon', plugins_url() . '/assets/icon.png');
$this->has_fields = false;
$this->method_title = __('Credit Cards/E-Wallets','xen-pay-woo');
$this->method_description = __('Pay Through Credit Cards or E-Wallets Through XENDIT, Personal Information will NOT be stored','xen-pay-woo');
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->instructions = $this->get_option( 'instructions', $this->description );
$this->init_form_fields();
$this->init_settings();
}
public function init_form_fields(){
$this->form_fields = apply_filters('xen_pay_fields',array(
'enabled' => array(
'title' => __('Enable/Disable','xen-pay-woo'),
'type' =>'checkbox',
'label'=> __('Enable or Disable Payments','xen-pay-woo'),
'default'=>'no'
),
'title' => array(
'title' => __('Payment Gateway Name','xen-pay-woo'),
'type' =>'text',
'default'=>__('Credit Cards/E-Wallets','xen-pay-woo'),
'desc_tip'=> true,
'description'=> __('Add a new title for the payment gateway that customers will see in the checkout page','xen-pay-woo')
),
'description' => array(
'title' => __('Payment Gateway Description','xen-pay-woo'),
'type' =>'textarea',
'default'=>__('This gateway accepts VISA, MASTERCARD, ETC','xen-pay-woo'),
'desc_tip'=> true,
'description'=> __('Add a new description for the payment gateway that customers will see in the checkout page','xen-pay-woo')
),
'instructions' => array(
'title' => __('Instructions','xen-pay-woo'),
'type' =>'textarea',
'default'=>__('Kindly check your account page and reload to contact your personal graphics manager. Thank you so much for choosing HelloGFX','xen-pay-woo'),
'desc_tip'=> true,
'description'=> __('Place a product description that will be shown after checkout on EMAIL and THANK YOU PAGE','xen-pay-woo')
)
));
}
public function process_payment($order_id){
$order_id = wc_get_order($order_id);
$this->clear_payment_with_api();
$order->update_status('pending-payment', __('Awaiting Payments','xen-pay-woo'));
$order->reduce_order_stock();
WC()->cart->empty_cart();
return array(
'result'=>'success',
'redirect'=>$this->get_return_url($order)
);
}
public function clear_payment_with_api(){
}
}
}
}
add_filter('woocommerce_payment_gateways','add_to_woo_xen_payment');
function add_to_woo_xen_payment( $gateways ){
$gateways[] = 'WC_xen_payment';
return $gateways;
}
Kindly let me know if anyone has any idea why it won't show on the checkout page.