PluginProbe ʕ •ᴥ•ʔ
GlobalPayments Gateway Provider for WooCommerce / trunk
GlobalPayments Gateway Provider for WooCommerce vtrunk
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 week ago Data 1 year ago Gateways 5 days ago PaymentMethods 1 week ago Services 6 months ago Utils 5 months ago Plugin.php 5 days ago
Plugin.php
168 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\{
10 AffirmBlock,
11 ApplePayBlock,
12 ClickToPayBlock,
13 GooglePayBlock,
14 GpApiGatewayBlock,
15 HeartlandGatewayBlock,
16 HeartlandGiftGatewayBlock,
17 KlarnaBlock,
18 OpenBankingBlock,
19 PaypalBlock
20 };
21 use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\{GpApiGateway, HeartlandGateway};
22
23 defined( 'ABSPATH' ) || exit;
24
25 /**
26 * Main plugin class.
27 */
28 class Plugin {
29 /**
30 * Version.
31 *
32 * @var string
33 */
34 const VERSION = '1.20.2';
35
36 /**
37 * Init the package.
38 */
39 public static function init() {
40 $pluginDirName = basename( dirname( __FILE__ , 2 ) );
41
42 load_plugin_textdomain( 'globalpayments-gateway-provider-for-woocommerce', false, $pluginDirName . '/languages' );
43
44 if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
45 return;
46 }
47
48 //initialize gift related hooks for Heartland ajax requests
49 if ( true === wp_doing_ajax() || ! empty( $_GET['wc-ajax'] ) ) {
50 $heartlandSettings = get_option( 'woocommerce_' . HeartlandGateway::GATEWAY_ID . '_settings' );
51 // prevent checkout blocker when Heartland settings not set loop
52 if (
53 ! empty( $heartlandSettings ) &&
54 isset( $heartlandSettings['enabled'] ) &&
55 'yes' === $heartlandSettings['enabled'] &&
56 isset( $heartlandSettings['allow_gift_cards'] ) &&
57 'yes' === $heartlandSettings['allow_gift_cards']
58 ) {
59 new HeartlandGateway();
60 }
61 }
62
63 add_filter( 'woocommerce_payment_gateways', array( self::class, 'add_gateways' ) );
64 add_action( 'woocommerce_order_actions', array( Gateways\AbstractGateway::class, 'add_capture_order_action' ) );
65 add_action( 'woocommerce_order_action_capture_credit_card_authorization', array(
66 Gateways\AbstractGateway::class,
67 'capture_credit_card_authorization'
68 ) );
69 add_action( 'woocommerce_blocks_loaded', array( self::class, 'add_block_gateways' ) );
70 }
71
72 /**
73 * Appends our payment gateways to WooCommerce's known list.
74 *
75 * @param string[] $methods
76 *
77 * @return string[]
78 */
79 public static function add_gateways( $methods ) {
80 $gateways = array(
81 Gateways\HeartlandGateway::class,
82 Gateways\GeniusGateway::class,
83 Gateways\TransitGateway::class,
84 Gateways\GpApiGateway::class,
85 );
86 $gateways = array_merge( $gateways, GpApiGateway::get_payment_methods() );
87
88 foreach ( $gateways as $gateway ) {
89 $methods[] = $gateway;
90 }
91
92 return $methods;
93 }
94
95 public static function add_block_gateways() {
96 add_action(
97 'woocommerce_blocks_payment_method_type_registration',
98 function (PaymentMethodRegistry $payment_method_registry) {
99 $payment_method_registry->register( new GpApiGatewayBlock() );
100 $payment_method_registry->register( new HeartlandGatewayBlock() );
101 $payment_method_registry->register( new ApplePayBlock() );
102 $payment_method_registry->register( new ClickToPayBlock() );
103 $payment_method_registry->register( new GooglePayBlock() );
104 $payment_method_registry->register( new AffirmBlock() );
105 $payment_method_registry->register( new KlarnaBlock() );
106 $payment_method_registry->register( new OpenBankingBlock() );
107 $payment_method_registry->register( new PaypalBlock() );
108 }
109 );
110
111 // Initialize gift card block support when Heartland is enabled with gift cards
112 $heartlandSettings = get_option( 'woocommerce_' . HeartlandGateway::GATEWAY_ID . '_settings' );
113 if (
114 ! empty( $heartlandSettings ) &&
115 isset( $heartlandSettings['enabled'] ) &&
116 'yes' === $heartlandSettings['enabled'] &&
117 isset( $heartlandSettings['allow_gift_cards'] ) &&
118 'yes' === $heartlandSettings['allow_gift_cards']
119 ) {
120 new HeartlandGiftGatewayBlock();
121 }
122 }
123
124 /**
125 * Return the version of the package.
126 *
127 * @return string
128 */
129 public static function get_version() {
130 return self::VERSION;
131 }
132
133 /**
134 * Return the path to the package.
135 *
136 * @return string
137 */
138 public static function get_path() {
139 return dirname( __DIR__ );
140 }
141
142 public static function get_url( $path ) {
143 return plugins_url( $path, dirname( __FILE__ ) );
144 }
145
146 /**
147 * Return the active gateway of enforcing a single toggle.
148 *
149 * @return string
150 */
151 public static function get_active_gateway() {
152 $availableGateways = array(
153 Gateways\HeartlandGateway::GATEWAY_ID,
154 Gateways\GeniusGateway::GATEWAY_ID,
155 Gateways\TransitGateway::GATEWAY_ID,
156 Gateways\GpApiGateway::GATEWAY_ID,
157 );
158 foreach ( $availableGateways as $gateway ) {
159 $gatewaySettings = get_option( 'woocommerce_' . $gateway . '_settings' );
160 if ( ! empty( $gatewaySettings ) && isset( $gatewaySettings['enabled'] ) && 'yes' === $gatewaySettings['enabled'] ) {
161 return $gateway;
162 }
163 }
164
165 return;
166 }
167 }
168