-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce-gateway-subscription-iyzico.php
128 lines (89 loc) · 4.39 KB
/
woocommerce-gateway-subscription-iyzico.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Plugin Name: iyzico Subscription WooCommerce
* Description: iyzico Payment Subscription Gateway for WooCommerce.
* Author: iyzico
* Author URI: https://iyzico.com
* Version: 1.0.0
* Text Domain: iyzico Subscription WooCommerce
* Domain Path: /i18n/languages/
* WC requires at least: 3.0.0
* WC tested up to: 3.7.1
*/
define('IYZICO_PATH',untrailingslashit( plugin_dir_path( __FILE__ )));
define('IYZICO_LANG_PATH',plugin_basename(dirname(__FILE__)) . '/i18n/languages/');
define('IYZICO_PLUGIN_NAME','/'.plugin_basename(dirname(__FILE__)));
if (!defined('ABSPATH')) {
exit;
}
if ( ! class_exists( 'Iyzico_Subscription_For_WooCommerce' ) ) {
class Iyzico_Subscription_For_WooCommerce {
protected static $instance;
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {
add_action('plugins_loaded', array($this,'init'));
}
public static function SubscriptionIyzicoActive() {
global $wpdb;
$table_name = $wpdb->prefix . 'subscription_iyzico';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
subscription_iyzico_id int(11) NOT NULL AUTO_INCREMENT,
subscription_reference_code varchar(45) NOT NULL,
order_id int(11) NOT NULL,
user_id int(11) NOT NULL,
created_at timestamp DEFAULT current_timestamp,
PRIMARY KEY (subscription_iyzico_id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
public static function SubscriptionIyzicoDeactive() {
global $wpdb;
$table_name = $wpdb->prefix . 'subscription_iyzico';
$charset_collate = $wpdb->get_charset_collate();
$sql = "DROP TABLE IF EXISTS $table_name;";
$wpdb->query($sql);
flush_rewrite_rules();
}
public function init() {
$this->InitIyzicoPaymentGateway();
}
public static function installLanguage() {
load_plugin_textdomain('woocommerce-iyzico-subscription',false,IYZICO_LANG_PATH);
}
public function InitIyzicoPaymentGateway() {
if ( ! class_exists('WC_Payment_Gateway')) {
return;
}
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-fields.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-formobjectgenerate.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-helper.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-pkibuilder.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-authorization.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-request.php';
include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-model.php';
add_action('woocommerce_payment_gateways',array($this,'AddIyzicoSubscriptionGateway'));
add_action('woocommerce_product_options_general_product_data',
array('Iyzico_Subscription_For_WooCommerce_Gateway',
'pricingPlanMethod'));
add_action('woocommerce_process_product_meta',
array('Iyzico_Subscription_For_WooCommerce_Gateway',
'pricingPlanMethodSave'));
}
public function AddIyzicoSubscriptionGateway($methods) {
$methods[] = 'Iyzico_Subscription_For_WooCommerce_Gateway';
return $methods;
}
}
Iyzico_Subscription_For_WooCommerce::get_instance();
add_action('plugins_loaded',array('Iyzico_Subscription_For_WooCommerce','installLanguage'));
register_activation_hook(__FILE__, array('Iyzico_Subscription_For_WooCommerce','SubscriptionIyzicoActive'));
register_deactivation_hook(__FILE__,array('Iyzico_Subscription_For_WooCommerce','SubscriptionIyzicoDeactive'));
}