-
Notifications
You must be signed in to change notification settings - Fork 2
/
wc-malaysia-payment-gateway.php
67 lines (57 loc) · 2.45 KB
/
wc-malaysia-payment-gateway.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
Plugin Name: Woocommerce Custom Payment Gateway Malaysia
Description: Malaysia Custom Payment Gateway for Woocommerce that supports DuitNow QR and custom Bank Transfer.
Version: 1.0
Author: Aliff Azmi
Author URI: https://aliffazmi.com/
License: GPLv2 or later
*/
$asset_url = plugins_url("/assets/", __FILE__);
add_action('plugins_loaded', 'init_custom_payment_gateway');
function init_custom_payment_gateway()
{
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
require_once(WC()->plugin_path() . '/includes/abstracts/abstract-wc-payment-gateway.php');
require_once(plugin_dir_path(__FILE__) . 'includes/class-duitnow-qr.php');
require_once(plugin_dir_path(__FILE__) . 'includes/class-bank-transfer.php');
require_once plugin_dir_path(__FILE__) . 'includes/partials/class-custom-payment-gateway-ajax.php';
require_once plugin_dir_path(__FILE__) . 'includes/partials/class-custom-payment-gateway-metabox.php';
require_once plugin_dir_path(__FILE__) . 'includes/partials/class-custom-payment-gateway-admin-column.php';
global $asset_url;
/**
* This class is use to create metabox and show receipt in admin order page.
*/
$metabox = new Custom_Payment_Gateway_MetaBox($asset_url);
/**
* Handle ajax request on checkout page.
*/
$ajax_handler = new Custom_Payment_Gateway_Ajax_Handler();
/**
* Create receipt flag/status in order table.
*/
$admin_order_column = new Custom_Payment_Gateway_Admin_Column();
/**
* Register our custom payment gateway class.
*/
add_filter('woocommerce_payment_gateways', 'add_custom_payment_gateways');
function add_custom_payment_gateways($gateways)
{
global $asset_url;
$gateways[] = 'DuitNow_QR_Payment_Gateway';
$gateways[] = 'Bank_Transfer_Payment_Gateway';
return $gateways;
}
/**
* Hook our settings.
*/
add_filter("plugin_action_links", "plugin_action_links", 10, 2);
function plugin_action_links($links, $file)
{
if (plugin_basename(__FILE__) == $file) {
$links['wc-custom-payment-gateway-settings'] = '<a href="' . admin_url("admin.php?page=wc-settings&tab=checkout") . '">Settings</a>';
}
return $links;
}
}
}