register( new Alatpay_Payment_Gateway_Blocks ); } ); } function alatpay_payment_page( $order_id ) { $order = wc_get_order( $order_id ); if ( ! $order ) { wp_safe_redirect( wc_get_checkout_url() . '?result=fail' ); exit; } $gateway = new Alatpay_Payment_Gateway(); $api_key = $gateway->get_option( 'api_key' ); $business_id = $gateway->get_option( 'business_id' ); $auto_complete_order = $gateway->get_option( 'auto_complete_order' ); // Get the currency set in WooCommerce settings $currency = get_woocommerce_currency(); // Ensure proper sanitization and escaping of dynamic content wp_register_script( 'alatpay-gateway', esc_url( plugin_dir_url( __FILE__ ) . '/assets/js/alatpay.js' ), array( 'jquery' ), '1.0.0', true ); // Localize script variables securely wp_localize_script( 'alatpay-gateway', 'gatewayData', array( 'apiKey' => sanitize_text_field( $api_key ), 'businessId' => sanitize_text_field( $business_id ), 'orderEmail' => sanitize_email( $order->get_billing_email() ), 'orderAmount' => floatval( $order->get_total() ), 'currency' => $currency, 'updateOrderUrl' => esc_url( admin_url( 'admin-ajax.php' ) ) . "?action=alatpay_update_order_status&order_id={$order_id}&status=" . ( 'yes' === $auto_complete_order ? 'completed' : 'processing' ) . "&nonce=" . wp_create_nonce( 'alatpay_update_order_status' ), 'failUrl' => esc_url( wc_get_checkout_url() . '?result=fail' ) ) ); wp_enqueue_script( 'alatpay-gateway' ); ?> ' . esc_html__( 'Thank you for your order, please click the button below to pay via ALATPay.', 'alatpay' ) . '
'; ?>