PluginProbe
WooCommerce / 11.1.0-beta.2
WooCommerce v11.1.0-beta.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Blocks / Payments / Integrations / Cheque.php
Cheque.php
79 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
3
4 use Exception;
5 use Automattic\WooCommerce\Blocks\Assets\Api;
6 use WC_Gateway_Cheque;
7
8 /**
9 * Cheque payment method integration
10 *
11 * @since 2.6.0
12 */
13 final class Cheque extends AbstractPaymentMethodType {
14 /**
15 * Payment method name defined by payment methods extending this class.
16 *
17 * @var string
18 */
19 protected $name = WC_Gateway_Cheque::ID;
20
21 /**
22 * An instance of the Asset Api
23 *
24 * @var Api
25 */
26 private $asset_api;
27
28 /**
29 * Constructor
30 *
31 * @param Api $asset_api An instance of Api.
32 */
33 public function __construct( Api $asset_api ) {
34 $this->asset_api = $asset_api;
35 }
36
37 /**
38 * Initializes the payment method type.
39 */
40 public function initialize() {
41 $this->settings = get_option( 'woocommerce_cheque_settings', [] );
42 }
43
44 /**
45 * Returns if this payment method should be active. If false, the scripts will not be enqueued.
46 *
47 * @return boolean
48 */
49 public function is_active() {
50 return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
51 }
52
53 /**
54 * Returns an array of scripts/handles to be registered for this payment method.
55 *
56 * @return array
57 */
58 public function get_payment_method_script_handles() {
59 $this->asset_api->register_script(
60 'wc-payment-method-cheque',
61 'assets/client/blocks/wc-payment-method-cheque.js'
62 );
63 return [ 'wc-payment-method-cheque' ];
64 }
65
66 /**
67 * Returns an array of key=>value pairs of data made available to the payment methods script.
68 *
69 * @return array
70 */
71 public function get_payment_method_data() {
72 return [
73 'title' => $this->get_setting( 'title' ),
74 'description' => $this->get_setting( 'description' ),
75 'supports' => $this->get_supported_features(),
76 ];
77 }
78 }
79