AbstractPaymentMethodType.php
2 years ago
BankTransfer.php
1 year ago
CashOnDelivery.php
1 year ago
Cheque.php
1 year ago
PayPal.php
5 months ago
BankTransfer.php
78 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Blocks\Payments\Integrations; |
| 3 | |
| 4 | use Automattic\WooCommerce\Blocks\Assets\Api; |
| 5 | use WC_Gateway_BACS; |
| 6 | |
| 7 | /** |
| 8 | * Bank Transfer (BACS) payment method integration |
| 9 | * |
| 10 | * @since 3.0.0 |
| 11 | */ |
| 12 | final class BankTransfer extends AbstractPaymentMethodType { |
| 13 | /** |
| 14 | * Payment method name/id/slug (matches id in WC_Gateway_BACS in core). |
| 15 | * |
| 16 | * @var string |
| 17 | */ |
| 18 | protected $name = WC_Gateway_BACS::ID; |
| 19 | |
| 20 | /** |
| 21 | * An instance of the Asset Api |
| 22 | * |
| 23 | * @var Api |
| 24 | */ |
| 25 | private $asset_api; |
| 26 | |
| 27 | /** |
| 28 | * Constructor |
| 29 | * |
| 30 | * @param Api $asset_api An instance of Api. |
| 31 | */ |
| 32 | public function __construct( Api $asset_api ) { |
| 33 | $this->asset_api = $asset_api; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Initializes the payment method type. |
| 38 | */ |
| 39 | public function initialize() { |
| 40 | $this->settings = get_option( 'woocommerce_bacs_settings', [] ); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Returns if this payment method should be active. If false, the scripts will not be enqueued. |
| 45 | * |
| 46 | * @return boolean |
| 47 | */ |
| 48 | public function is_active() { |
| 49 | return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns an array of scripts/handles to be registered for this payment method. |
| 54 | * |
| 55 | * @return array |
| 56 | */ |
| 57 | public function get_payment_method_script_handles() { |
| 58 | $this->asset_api->register_script( |
| 59 | 'wc-payment-method-bacs', |
| 60 | 'assets/client/blocks/wc-payment-method-bacs.js' |
| 61 | ); |
| 62 | return [ 'wc-payment-method-bacs' ]; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns an array of key=>value pairs of data made available to the payment methods script. |
| 67 | * |
| 68 | * @return array |
| 69 | */ |
| 70 | public function get_payment_method_data() { |
| 71 | return [ |
| 72 | 'title' => $this->get_setting( 'title' ), |
| 73 | 'description' => $this->get_setting( 'description' ), |
| 74 | 'supports' => $this->get_supported_features(), |
| 75 | ]; |
| 76 | } |
| 77 | } |
| 78 |