PluginProbe ʕ •ᴥ•ʔ
GlobalPayments Gateway Provider for WooCommerce / 1.13.7
GlobalPayments Gateway Provider for WooCommerce v1.13.7
1.20.2 1.20.1 1.19.3 1.19.2 1.19.1 1.19.0 1.18.4 1.18.3 trunk 1.0.0 1.0.0-b2 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.6 1.10.7 1.10.8 1.11.0 1.12.0 1.12.1 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.7 1.13.8 1.14.0 1.14.1 1.14.2 1.14.3 1.14.4 1.14.5 1.14.6 1.14.7 1.14.8 1.14.9 1.15.0 1.15.2 1.15.4 1.15.5 1.15.6 1.15.8 1.15.9 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.17.0 1.17.1 1.18.0 1.18.1 1.18.2 1.2.0 1.2.1 1.2.2 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5
global-payments-woocommerce / src / Plugin.php
global-payments-woocommerce / src Last commit date
Blocks 1 year ago Data 1 year ago Gateways 1 year ago PaymentMethods 1 year ago Utils 1 year ago Plugin.php 1 year ago
Plugin.php
152 lines
1 <?php
2 /**
3 * Returns information about the package and handles init.
4 */
5
6 namespace GlobalPayments\WooCommercePaymentGatewayProvider;
7
8 use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
9 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\AffirmBlock;
10 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\ApplePayBlock;
11 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\ClickToPayBlock;
12 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\GooglePayBlock;
13 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\KlarnaBlock;
14 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\OpenBankingBlock;
15 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\PaypalBlock;
16 use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\GpApiGateway;
17 use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\HeartlandGateway;
18 use GlobalPayments\WooCommercePaymentGatewayProvider\Blocks\Gateways\GpApiGatewayBlock;
19
20 defined( 'ABSPATH' ) || exit;
21
22 /**
23 * Main plugin class.
24 */
25 class Plugin {
26 /**
27 * Version.
28 *
29 * @var string
30 */
31 const VERSION = '1.13.7';
32
33 /**
34 * Init the package.
35 */
36 public static function init() {
37 $pluginDirName = basename( dirname( __FILE__ , 2 ) );
38
39 load_plugin_textdomain( 'globalpayments-gateway-provider-for-woocommerce', false, $pluginDirName . '/languages' );
40
41 if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
42 return;
43 }
44
45 //initialize gift related hooks for Heartland ajax requests
46 if ( true === wp_doing_ajax() || ! empty( $_GET['wc-ajax'] ) ) {
47 $heartlandSettings = get_option( 'woocommerce_' . HeartlandGateway::GATEWAY_ID . '_settings' );
48 // prevent checkout blocker when Heartland settings not set loop
49 if (
50 ! empty( $heartlandSettings ) &&
51 isset( $heartlandSettings['enabled'] ) &&
52 'yes' === $heartlandSettings['enabled'] &&
53 isset( $heartlandSettings['allow_gift_cards'] ) &&
54 'yes' === $heartlandSettings['allow_gift_cards']
55 ) {
56 new HeartlandGateway();
57 }
58 }
59
60 add_filter( 'woocommerce_payment_gateways', array( self::class, 'add_gateways' ) );
61 add_action( 'woocommerce_order_actions', array( Gateways\AbstractGateway::class, 'add_capture_order_action' ) );
62 add_action( 'woocommerce_order_action_capture_credit_card_authorization', array(
63 Gateways\AbstractGateway::class,
64 'capture_credit_card_authorization'
65 ) );
66 add_action( 'woocommerce_blocks_loaded', array( self::class, 'add_block_gateways' ) );
67 }
68
69 /**
70 * Appends our payment gateways to WooCommerce's known list.
71 *
72 * @param string[] $methods
73 *
74 * @return string[]
75 */
76 public static function add_gateways( $methods ) {
77 $gateways = array(
78 Gateways\HeartlandGateway::class,
79 Gateways\GeniusGateway::class,
80 Gateways\TransitGateway::class,
81 Gateways\GpApiGateway::class,
82 );
83 $gateways = array_merge( $gateways, GpApiGateway::get_payment_methods() );
84
85 foreach ( $gateways as $gateway ) {
86 $methods[] = $gateway;
87 }
88
89 return $methods;
90 }
91
92 public static function add_block_gateways() {
93 add_action(
94 'woocommerce_blocks_payment_method_type_registration',
95 function (PaymentMethodRegistry $payment_method_registry) {
96 $payment_method_registry->register( new GpApiGatewayBlock() );
97 $payment_method_registry->register( new ApplePayBlock() );
98 $payment_method_registry->register( new ClickToPayBlock() );
99 $payment_method_registry->register( new GooglePayBlock() );
100 $payment_method_registry->register( new AffirmBlock() );
101 $payment_method_registry->register( new KlarnaBlock() );
102 $payment_method_registry->register( new OpenBankingBlock() );
103 $payment_method_registry->register( new PaypalBlock() );
104 }
105 );
106 }
107
108 /**
109 * Return the version of the package.
110 *
111 * @return string
112 */
113 public static function get_version() {
114 return self::VERSION;
115 }
116
117 /**
118 * Return the path to the package.
119 *
120 * @return string
121 */
122 public static function get_path() {
123 return dirname( __DIR__ );
124 }
125
126 public static function get_url( $path ) {
127 return plugins_url( $path, dirname( __FILE__ ) );
128 }
129
130 /**
131 * Return the active gateway of enforcing a single toggle.
132 *
133 * @return string
134 */
135 public static function get_active_gateway() {
136 $availableGateways = array(
137 Gateways\HeartlandGateway::GATEWAY_ID,
138 Gateways\GeniusGateway::GATEWAY_ID,
139 Gateways\TransitGateway::GATEWAY_ID,
140 Gateways\GpApiGateway::GATEWAY_ID,
141 );
142 foreach ( $availableGateways as $gateway ) {
143 $gatewaySettings = get_option( 'woocommerce_' . $gateway . '_settings' );
144 if ( ! empty( $gatewaySettings ) && isset( $gatewaySettings['enabled'] ) && 'yes' === $gatewaySettings['enabled'] ) {
145 return $gateway;
146 }
147 }
148
149 return;
150 }
151 }
152