-
Notifications
You must be signed in to change notification settings - Fork 11
/
tpay.php
107 lines (86 loc) · 3.3 KB
/
tpay.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/*
* Plugin Name: Tazapay Checkout Payment Gateway
* Plugin URI: https://wordpress.org/plugins/tazapay
* Description: Pay securely with buyer protection.
* Version: 3.0.1
* Author: Tazapay
* Author URI: https://wordpress.org/plugins/tazapay
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wc-tp-payment-gateway
*/
define('TZP_CSS_JSS_VERISON', time());
define('TZP_PUBLIC_ASSETS_DIR', plugins_url('assets/', __FILE__));
// constants
define('PAID', 'paid');
define('SUCCEEDED', 'succeeded');
define('PENDING', 'pending');
define('ON_HOLD', 'on-hold');
define('FAILED', 'failed');
define('REQUIRES_ACTION', 'requires_action');
define('CHECKOUT_PAID', 'checkout.paid');
define('REFUND_SUCCEEDED', 'refund.succeeded');
define('REFUND_FAILED', 'refund.failed');
define('REFUND_PENDING', 'refund.pending');
define('COMPLETED', 'completed');
define('PROCESSING', 'processing');
define('APPROVED', 'approved');
$plugin = plugin_basename(__FILE__);
// htdocs/wordpress/wp-content/plugins
// htdocs/wordpress/wp-includes/functions.php
/* Deactivate */
function tzp_deactivate(){
// wp_clear_scheduled_hook( 'my_hourly_event' );
/*
* This action hook unregisters our PHP class as a WooCommerce payment gateway
*/
remove_filter( 'woocommerce_payment_gateways', 'tzp_add_gateway_class' );
remove_action( 'plugins_loaded', 'tzp_init_gateway_class' );
}
register_deactivation_hook( __FILE__, 'tzp_deactivate');
function tzp_get_plugin_info(){
return get_plugin_data(__FILE__);
}
/*
* The class itself, please note that it is inside plugins_loaded action hook
*/
add_action( 'plugins_loaded', 'tzp_init_gateway_class' );
function tzp_init_gateway_class() {
include 'includes/tazapay-apis.php';
include 'includes/tazapay-methods.php';
include 'includes/class-wc-tpay.php';
#TODO: Use alternate approach for below functionality
}
// Frontend css and js
add_action('wp_enqueue_scripts', 'tzp_frontend_enqueue_styles');
function tzp_frontend_enqueue_styles()
{
wp_enqueue_style('tazapay-frontend-css', TZP_PUBLIC_ASSETS_DIR . 'css/tazapay-frontend.css', array(), TZP_CSS_JSS_VERISON, 'all');
wp_enqueue_script('tazapay-admin', TZP_PUBLIC_ASSETS_DIR . 'js/tazapay-form.js', array('jquery'), TZP_CSS_JSS_VERISON, true);
}
// Backend css and js
add_action('admin_enqueue_scripts', 'tzp_enqueue_styles');
function tzp_enqueue_styles()
{
wp_enqueue_style('tazapay-frontend-css', TZP_PUBLIC_ASSETS_DIR . 'css/tazapay-frontend.css', array(), TZP_CSS_JSS_VERISON, 'all');
wp_enqueue_script('tazapay-admin', TZP_PUBLIC_ASSETS_DIR . 'js/tazapay-form.js', array('jquery'), TZP_CSS_JSS_VERISON, true);
}
/*
* This action hook registers our PHP class as a WooCommerce payment gateway
*/
add_filter( 'woocommerce_payment_gateways', 'tzp_add_gateway_class' );
function tzp_add_gateway_class( $gateways ) {
$gateways[] = 'TPAY_Gateway'; // your class name is here
return $gateways;
}
/*
* Plugin settings page
*/
add_filter("plugin_action_links_$plugin", 'tzp_plugin_settings_link');
function tzp_plugin_settings_link($links)
{
$settings_link = '<a href="admin.php?page=wc-settings&tab=checkout§ion=tz_tazapay">Settings</a>';
array_unshift($links, $settings_link);
return $links;
}