<?php

namespace Booktics\Module\Stripe_Addon\Assets;

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

use Booktics\Contracts\Hookable_Service_Contract;
use Booktics\Module\Stripe_Addon\Handler\Stripe_Handler;

class Stripe_Frontend_Assets implements Hookable_Service_Contract {

    /**
     * Register WordPress hooks and filters for Stripe frontend assets.
     *
     * Implements the Hookable_Service_Contract interface method to register
     * necessary frontend script localization.
     *
     * @return void
     * @since 1.0.0
     */
    public function register() {
        add_filter( 'booktics_frontend_localize', [
            $this,
            'localize_script'
        ] );
    }

    /**
     * Add Stripe-specific data to frontend script localization.
     *
     * Adds the Stripe publishable key to the localized script data
     * for use in frontend Stripe integration.
     *
     * @param array $data Existing localized script data.
     *
     * @return array Modified script data with Stripe information.
     * @since 1.0.0
     */
    public function localize_script( $data ) {
        $data['stripe_publishable_key'] = Stripe_Handler::get_stripe_publishable_key();

        return $data;
    }
}