<?php

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

class WC_Gateway_Wooplatnica_Blocks extends AbstractPaymentMethodType {
  protected $name = 'uplatnica';

  public function initialize() {
    $this->settings = get_option('wooplatnica_uplatnica_settings', []);
  }

  public function is_active() {
    return ($this->settings['enabled'] ?? '') === 'yes';
  }

  public function get_payment_method_script_handles() {
    wp_register_script(
      'wc-wooplatnica-blocks',
      plugins_url('../assets/js/wooplatnica-payment-block.js', __FILE__),
      ['wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'],
      '1.3',
      true
    );
    return ['wc-wooplatnica-blocks'];
  }

  public function get_payment_method_data() {
    return [
      'title'       => $this->settings['title'] ?? __('Opšta uplatnica', 'wooplatnica'),
      'description' => $this->settings['description'] ?? '',
      'supports'    => ['products'],
    ];
  }
}
