<?php

namespace WPCompanion\ScotiaBank;

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

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.

final class Gateway_Block extends AbstractPaymentMethodType {

 	private $gateway;
 	protected $name = 'ig_scotiabank';
    private $profile_monitor;

 	public function initialize() {
        
 		$this->settings = get_option( 'woocommerce_ig_scotiabank_settings', [] );
        
 		$this->gateway = new Gateway();
 	}

 	public function is_active() {
 		return $this->get_setting( 'enabled' ) === 'yes';
 	}

 	public function get_payment_method_script_handles() {
        
        $ver = gmdate("ymd-Gis", filemtime( ig_scotiabank()->plugin_path(). '/assets/js/checkout.js' ));
        
 		wp_register_script(
 			'wc-scotiabank-blocks-integration',
 			ig_scotiabank()->plugin_url(). '/assets/js/checkout.js',
 			[
 				'wc-blocks-registry',
 				'wc-settings',
 				'wp-element',
 				'wp-html-entities',
 				'wp-i18n',
 			],
 			$ver,
 			true
 		);
        
 		if( function_exists( 'wp_set_script_translations' ) ) {
 			wp_set_script_translations( 'wc-scotiabank-blocks-integration');
 		}

 		return [ 'wc-scotiabank-blocks-integration' ];
 	}

 	public function get_payment_method_data() {
 		return [
 			'title'       => $this->gateway->title,
 			'description' => $this->gateway->description,
            'logo'        => ig_scotiabank()->plugin_url().'/assets/images/scotiabank.png',
			'cards'       => ig_scotiabank()->plugin_url().'/assets/images/card-logos.png',
			'supports'    => $this->gateway->supports,
 		];
 	}

 }