PluginProbe
HyperPay Payments / 1.7
HyperPay Payments v1.7
6.6.0 trunk 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.5 4.0.0 4.0.2 All 34 releases
hyperpay-gateways / includes / class-install.php

class-install.php in HyperPay Payments 1.7, at includes/class-install.php

76 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class hyperpay_main
3 {
4 /**
5 * Payment gateway classes.
6 * all new class should added here
7 * @var array
8 */
9 protected static $HP_gateways = [
10 // Add Class Here
11 'WC_Hyperpay_Zoodpay_Gateway',
12 'WC_Hyperpay_Gateway',
13 'WC_Hyperpay_STCPay_Gateway',
14 'WC_Hyperpay_Mada_Gateway',
15 'WC_Hyperpay_ApplePay_Gateway'
16 ];
17
18 /**
19 * First function fire when click on active plugin
20 *
21 * @return void
22 */
23
24 public static function load(): void
25 {
26 foreach (self::$HP_gateways as $names) { // <== looping over all regestered class in $HP_gateways array
27 include_once HYPERPAY_ABSPATH . "gateways/$names.php";
28 }
29
30 /**
31 * this filter documented in woocommerce to asign all gateways to [payments tab] insude woocommerce settings
32 *
33 * @param string filter_name
34 * @param array[class_name,function_name]
35 * @return void
36 */
37
38 add_filter('woocommerce_payment_gateways', ['hyperpay_main', 'get_gateways']);
39 self::run_migration();
40 }
41
42 /**
43 * CREATE tabe on database to store users transaction mode
44 */
45 public static function run_migration(): void
46 {
47
48 global $wpdb;
49 $sql_raw = "CREATE TABLE {$wpdb->prefix}woocommerce_saving_cards (
50 `id` INT AUTO_INCREMENT,
51 `registration_id` VARCHAR(255) NOT NULL,
52 `customer_id` VARCHAR(255) NOT NULL,
53 `mode` int (10) NOT NULL,
54 PRIMARY KEY (`id`)
55 ) ENGINE=INNODB
56 DEFAULT CHARACTER SET utf8
57 COLLATE utf8_unicode_520_ci;";
58
59 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
60 dbDelta($sql_raw, true);
61 }
62
63 /**
64 * Merge the previous gateways with hyperPay gatways
65 *
66 * @param array $gateways
67 * @return array $updated_gateways
68 */
69
70 public static function get_gateways(array $gateways): array
71 {
72
73 return array_merge($gateways, self::$HP_gateways);
74 }
75 }
76