settings = get_option( 'woocommerce_alatpay_settings', [] ); $this->gateway = new Alatpay_Payment_Gateway(); } public function is_active() { return $this->gateway->is_available(); } public function get_payment_method_script_handles() { // Register the script securely wp_register_script( 'alatpay-blocks-integration', esc_url( plugin_dir_url( __FILE__ ) . 'assets/js/checkout.js' ), [ 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n', ], '1.0.0', true ); // Add localized data securely wp_localize_script( 'alatpay-blocks-integration', 'alatPayData', array( 'icon' => esc_url( $this->gateway->icon ), 'title' => esc_html( $this->gateway->title ), ) ); // Enqueue the script wp_enqueue_script( 'alatpay-blocks-integration' ); // Set script translations if available if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( 'alatpay-blocks-integration' ); } return [ 'alatpay-blocks-integration' ]; } public function get_payment_method_data() { // Collect and sanitize payment method data return [ 'title' => esc_html( $this->gateway->title ), 'description' => esc_html( $this->gateway->description ), 'icon' => esc_url( $this->gateway->icon ), 'business_id' => sanitize_text_field( $this->gateway->get_option( 'business_id' ) ), 'enabled' => sanitize_text_field( $this->gateway->get_option( 'enabled' ) ), 'api_key' => sanitize_text_field( $this->gateway->get_option( 'api_key' ) ), 'instructions'=> esc_html( $this->gateway->get_option( 'instructions', $this->gateway->description ) ), ]; } }