-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto-payment-gateway.php
197 lines (186 loc) · 17.5 KB
/
crypto-payment-gateway.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/**
* Plugin Name: Crypto Payment Gateway with Instant Payouts
* Plugin URI: https://paygate.to/crypto-payment-gateway-no-kyc-instant-payouts/
* Description: Cryptocurrency Payment Gateway with instant payouts to your wallet and without KYC hosted directly on your website.
* Version: 1.0.4
* Requires at least: 5.8
* Tested up to: 6.7.1
* WC requires at least: 5.8
* WC tested up to: 9.5.1
* Requires PHP: 7.2
* Author: PayGate.to
* Author URI: https://paygate.to/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
add_action('before_woocommerce_init', function() {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
add_action( 'before_woocommerce_init', function() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
}
} );
/**
* Enqueue block assets for the gateway.
*/
function paygatedottocryptogateway_enqueue_block_assets() {
// Fetch all enabled WooCommerce payment gateways
$paygatedottocryptogateway_available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
$paygatedottocryptogateway_gateways_data = array();
foreach ($paygatedottocryptogateway_available_gateways as $gateway_id => $gateway) {
if (strpos($gateway_id, 'paygatedotto-crypto-payment-gateway') === 0) {
$icon_url = method_exists($gateway, 'paygatedotto_crypto_payment_gateway_get_icon_url') ? $gateway->paygatedotto_crypto_payment_gateway_get_icon_url() : '';
$paygatedottocryptogateway_gateways_data[] = array(
'id' => sanitize_key($gateway_id),
'label' => sanitize_text_field($gateway->get_title()),
'description' => wp_kses_post($gateway->get_description()),
'icon_url' => sanitize_url($icon_url),
);
}
}
wp_enqueue_script(
'paygatedottocryptogateway-block-support',
plugin_dir_url(__FILE__) . 'assets/js/paygatedottocryptogateway-block-checkout-support.js',
array('wc-blocks-registry', 'wp-element', 'wp-i18n', 'wp-components', 'wp-blocks', 'wp-editor'),
filemtime(plugin_dir_path(__FILE__) . 'assets/js/paygatedottocryptogateway-block-checkout-support.js'),
true
);
// Localize script with gateway data
wp_localize_script(
'paygatedottocryptogateway-block-support',
'paygatedottocryptogatewayData',
$paygatedottocryptogateway_gateways_data
);
}
add_action('enqueue_block_assets', 'paygatedottocryptogateway_enqueue_block_assets');
/**
* Enqueue styles for the gateway on checkout page.
*/
function paygatedottocryptogateway_enqueue_styles() {
if (is_checkout()) {
wp_enqueue_style(
'paygatedottocryptogateway-styles',
plugin_dir_url(__FILE__) . 'assets/css/paygatedottocryptogateway-payment-gateway-styles.css',
array(),
filemtime(plugin_dir_path(__FILE__) . 'assets/css/paygatedottocryptogateway-payment-gateway-styles.css')
);
}
}
add_action('wp_enqueue_scripts', 'paygatedottocryptogateway_enqueue_styles');
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-btc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-bch.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-ltc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-doge.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-oneinchbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-adabep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-bnbbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-btcbbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-cakebep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-daibep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-dogebep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-ethbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-injbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-ltcbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-phptbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-shibbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-thcbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-virtubep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-xrpbep20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-oneincherc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-arberc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-bnberc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-daierc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eurcerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eurterc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-linkerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-mkrerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-nexoerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-pepeerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-shiberc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-tusderc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdperc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdterc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-verseerc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-arbarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-daiarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-etharbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-linkarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-pepearbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcearbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wbtcarbitrum.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-avaxpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-manapolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-polpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-smtpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcepolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-virtupolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wbtcpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wethpolygon.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-avaxavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-btcbavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eurcavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdceavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wavaxavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wbtceavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wetheavaxc.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-daibase.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-ethbase.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eurcbase.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcbase.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-daioptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-ethoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-linkoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-opoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdceoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wbtcoptimism.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eth.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-aedttrc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-btctrc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-inrttrc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-tusdtrc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdttrc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-trx.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-pyusderc20.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-solsol.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdcsol.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-usdtsol.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-eurcsol.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wbtcsol.php'); // Include the payment gateway class
include_once(plugin_dir_path(__FILE__) . 'includes/class-paygatedotto-crypto-payment-gateway-wethsol.php'); // Include the payment gateway class
// Conditional function that check if Checkout page use Checkout Blocks
function paygatedottocryptogateway_is_checkout_block() {
return WC_Blocks_Utils::has_block_in_page( wc_get_page_id('checkout'), 'woocommerce/checkout' );
}
function paygatedottocryptogateway_add_notice($paygatedottocryptogateway_message, $paygatedottocryptogateway_notice_type = 'error') {
// Check if the Checkout page is using Checkout Blocks
if (paygatedottocryptogateway_is_checkout_block()) {
// For blocks, throw a WooCommerce exception
if ($paygatedottocryptogateway_notice_type === 'error') {
throw new \WC_Data_Exception('checkout_error', esc_html($paygatedottocryptogateway_message));
}
// Handle other notice types if needed
} else {
// Default WooCommerce behavior
wc_add_notice(esc_html($paygatedottocryptogateway_message), $paygatedottocryptogateway_notice_type);
}
}
?>