| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit(); |
| 3 |
|
| 4 |
class BetterPayment_Installer |
| 5 |
{ |
| 6 |
|
| 7 |
public static function install() { |
| 8 |
self::create_tables(); |
| 9 |
} |
| 10 |
|
| 11 |
private static function get_schema() { |
| 12 |
global $wpdb; |
| 13 |
return [ |
| 14 |
"CREATE TABLE IF NOT EXISTS {$wpdb->prefix}betterpayment( |
| 15 |
id bigint(20) NOT NULL AUTO_INCREMENT, |
| 16 |
order_id varchar(50) NOT NULL, |
| 17 |
transaction_id varchar(50) DEFAULT '', |
| 18 |
amount decimal(10,2) NOT NULL, |
| 19 |
status varchar(50) DEFAULT NULL, |
| 20 |
source varchar(50) NOT NULL, |
| 21 |
payment_date datetime DEFAULT NULL, |
| 22 |
email varchar(50) NOT NULL DEFAULT '', |
| 23 |
customer_info longtext, |
| 24 |
form_fields_info longtext, |
| 25 |
currency varchar(11) NOT NULL DEFAULT '', |
| 26 |
referer varchar(64) DEFAULT NULL, |
| 27 |
obj_id text, |
| 28 |
PRIMARY KEY (id), |
| 29 |
KEY order_id (order_id), |
| 30 |
KEY status (status) |
| 31 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 " |
| 32 |
]; |
| 33 |
} |
| 34 |
|
| 35 |
public static function create_tables() { |
| 36 |
global $wpdb; |
| 37 |
$wpdb->hide_errors(); |
| 38 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 39 |
$tables = self::get_schema(); |
| 40 |
foreach ( $tables as $table ) { |
| 41 |
dbDelta( $table ); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|