-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-block.php
62 lines (53 loc) · 1.88 KB
/
class-block.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
<?php
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
final class CoinPays_Gateway_Blocks extends AbstractPaymentMethodType {
protected $name = 'coinpays_payment_gateway';
private array $gateways;
public function initialize()
{
$this->settings['iframe'] = get_option( 'woocommerce_coinpays_payment_gateway_settings');
$this->gateways['coinpays_payment_gateway'] = [
'title' => $this->settings['iframe']['title'],
'description' => $this->settings['iframe']['description'],
'enabled' => $this->settings['iframe']['enabled'],
'icon' => $this->settings['iframe']['logo'] === 'yes'
? plugin_dir_url( __DIR__ ) . '/' . plugin_basename( __DIR__ ) . '/assets/img/logo.webp'
: null
];
}
public function is_active()
{
return $this->settings['iframe']['enabled'] === 'yes' ? 1 : 0;
}
public function get_payment_method_script_handles()
{
wp_register_script(
'coinpays-payment-gateway-blocks-integration',
plugin_dir_url(__FILE__) . 'checkout.js',
[
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
],
null,
true
);
return [ 'coinpays-payment-gateway-blocks-integration' ];
}
public function get_payment_method_data()
{
$data = [];
foreach ($this->gateways as $key => $gateway) {
if($gateway['enabled'] === 'yes') {
$data[$key] = [
'title' => $gateway['title'],
'description' => $gateway['description'],
'icon' => $gateway['icon'],
];
}
}
return $data;
}
}