-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwc-victoriabank-wbc.php
87 lines (76 loc) · 2.25 KB
/
wc-victoriabank-wbc.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
<?php
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
final class WC_VictoriaBank_WBC extends AbstractPaymentMethodType
{
/**
* The gateway instance.
*
* @var WC_VictoriaBank
*/
protected $gateway;
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = WC_VictoriaBank::MOD_ID;
/**
* Initializes the payment method type.
*/
public function initialize()
{
$this->settings = get_option("woocommerce_{$this->name}_settings", []);
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[$this->name];
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active()
{
return $this->gateway->is_available();
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles()
{
$script_id = 'wc-victoriabank-block-frontend';
wp_register_script(
$script_id,
plugin_dir_url(__FILE__) . 'assets/js/blocks.js',
[
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
],
null,
true
);
if (function_exists('wp_set_script_translations')) {
wp_set_script_translations($script_id, 'wc-victoriabank', dirname(plugin_basename(__FILE__)) . '/languages');
}
return [$script_id];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data()
{
return [
'id' => $this->gateway->id,
'title' => $this->gateway->title,
'description' => $this->gateway->description,
'icon' => $this->gateway->icon,
'supports' => array_filter($this->gateway->supports, [$this->gateway, 'supports'])
];
}
}