<?php

namespace Pay4AllForMypos\Blocks;

defined( 'ABSPATH' ) || exit;

/**
 * Registers the Pay4All myPOS gateway with the WooCommerce Blocks
 * (Cart/Checkout) payment-method registry so it appears in the block-based
 * checkout (`wp:woocommerce/checkout`).
 *
 * The actual myPOS UI lives on mypos.com (auto-submitting form, see
 * MyposGateway::receipt_page()), so the block-side integration just needs
 * to surface the gateway in the picker and let the PHP
 * MyposGateway::process_payment() return the "Pay for order" redirect URL,
 * which WC Blocks honours natively via the Store API.
 */
final class BlocksRegistration
{
    public static function register() : void
    {
        add_action(
            'woocommerce_blocks_payment_method_type_registration',
            static function ( $payment_method_registry ) {
                if ( ! class_exists( MyposBlocksMethod::class ) ) {
                    require_once __DIR__ . '/MyposBlocksMethod.php';
                }
                $payment_method_registry->register( new MyposBlocksMethod() );
            }
        );
    }
}
