-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
112 lines (97 loc) · 3.03 KB
/
index.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
<?php
/*
* Plugin Name: Moka Payment Gateway for WooCommerce
* Plugin URI: https://github.com/optimisthub/moka-woocommerce
* Description: Moka Payment gateway for woocommerce
* Version: 3.8.4
* Author: Optimist Hub
* Author URI: https://optimisthub.com/?utm_source=moka-woocommerce&utm_campaign=moka-woocommerce&utm_content=plugins
* Domain Path: /languages/
* Text Domain: moka-woocommerce
*/
if ( !defined('ABSPATH') ) {
exit;
}
define( 'OPTIMISTHUB_MOKA_PAY_VERSION', '3.8.4' );
define( 'OPTIMISTHUB_MOKA_FILE', __FILE__ );
define( 'OPTIMISTHUB_MOKA_BASENAME', plugin_basename( OPTIMISTHUB_MOKA_FILE ) );
define( 'OPTIMISTHUB_MOKA_DIR', plugin_dir_path( OPTIMISTHUB_MOKA_FILE ) );
define( 'OPTIMISTHUB_MOKA_URL', plugin_dir_url( OPTIMISTHUB_MOKA_FILE ) );
define( 'OPTIMISTHUB_MOKA_UPDATE', 'https://moka.wooxup.com/' );
define( 'OPTIMISTHUB_MOKA_DOMAIN', 'moka-woocommerce' );
/**
* Auto load Optimisthub Moka
*
* @return void
*/
function loadOptimisthubMoka()
{
require __DIR__ . '/vendor/autoload.php';
$path = dirname( plugin_basename( OPTIMISTHUB_MOKA_FILE ) ) . '/languages';
load_plugin_textdomain( OPTIMISTHUB_MOKA_DOMAIN, false, $path );
}
/**
* Generate Moka Transaction Table For Transaction Logs
*
* @return void
*/
function mokaPaySqlTables()
{
global $wpdb;
$tableNames = [
$wpdb->prefix . 'moka_transactions',
$wpdb->prefix . 'moka_transactions_hash',
$wpdb->prefix . 'moka_subscriptions',
];
$charsetCollate = $wpdb->get_charset_collate();
$createTableQuery = [
"CREATE TABLE $tableNames[0] (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`id_cart` text,
`id_customer` int DEFAULT NULL,
`optimist_id` text,
`amount` decimal(10,2) DEFAULT '0.00',
`amount_paid` decimal(10,2) DEFAULT '0.00',
`installment` int DEFAULT '1',
`result_code` text,
`result_message` text,
`result` tinyint DEFAULT '1',
`created_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) $charsetCollate;",
"CREATE TABLE $tableNames[1] (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`id_hash` text,
`id_order` int DEFAULT NULL,
`order_details` text,
`optimist_id` text,
`created_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) $charsetCollate;",
"CREATE TABLE $tableNames[2] (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`order_id` text,
`order_amount` decimal(10,2) DEFAULT '0.00',
`order_details` text,
`subscription_status` int DEFAULT '0',
`subscription_period` text,
`subscription_next_try` text,
`user_id` int DEFAULT NULL,
`optimist_id` text,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) $charsetCollate;",
];
if( !function_exists( 'dbDelta' ))
{
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
}
foreach($createTableQuery as $perQuery )
{
dbDelta( $perQuery );
}
update_option( 'moka_transactions', OPTIMISTHUB_MOKA_PAY_VERSION );
}
register_activation_hook(__FILE__, 'mokaPaySqlTables');
add_action( 'plugins_loaded', 'loadOptimisthubMoka' );