<?php

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Cregis Payment Blocks Integration
 *
 * @since 1.0.0
 */
class Cregis_Blocks_Payment_Method {
    /**
     * Constructor
     */
    public function __construct() {
        add_action('woocommerce_blocks_payment_method_type_registration', array($this, 'register_payment_method'));
    }
    
    /**
     * Register payment method
     *
     * @param Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry
     */
    public function register_payment_method($payment_method_registry) {
        if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
            require_once CREGIS_PAYMENT_PLUGIN_DIR . 'includes/class-cregis-blocks-payment-integration.php';
            
            if (class_exists('Cregis_Blocks_Payment_Integration')) {
                $payment_method_registry->register(new Cregis_Blocks_Payment_Integration());
            }
        }
    }
}

// Initialize the blocks integration
if (class_exists('WooCommerce')) {
    new Cregis_Blocks_Payment_Method();
}
