is_enabled()) { $this->icon = apply_filters('woocommerce_payu_icon', plugins_url('/assets/images/ap.svg', PAYU_PLUGIN_FILE)); add_action('wp_enqueue_scripts', [$this, 'include_scripts']); } } public function is_available(): bool { if (! $this->try_retrieve_banks() || empty($this->get_option('merchant_name')) || empty($this->get_option('merchant_id'))) { return false; } return parent::is_available(); } public function payment_fields(): void { ?> agreements_field(); } public function get_additional_data(): array { return [ 'posId' => $this->pos_id, 'currency' => get_woocommerce_currency(), 'totalPrice' => WC()->cart ? WC()->cart->get_total('') : '0', 'env' => $this->sandbox ? 'TEST' : 'PRODUCTION', 'merchantName' => $this->get_option('merchant_name'), 'merchantId' => $this->sandbox ? '0' : $this->get_option('merchant_id') ]; } public function include_scripts(): void { wp_enqueue_script('google-pay', 'https://pay.google.com/gp/p/js/pay.js'); } protected function get_payu_pay_method(): array { $token = sanitize_text_field($_POST['payu-google-token']); return [ 'payMethod' => [ 'type' => 'PBL', 'value' => 'ap', 'authorizationCode' => $token ] ]; } protected function get_additional_gateway_fields(): array { return [ 'merchant_id' => [ 'title' => __( 'Google Merchant Id:', 'woo-payu-payment-gateway' ), 'type' => 'text', 'description' => __( 'Your Google Merchant Id. You need to verify your shop in Google, following the instructions.', 'woo-payu-payment-gateway' ), ], 'merchant_name' => [ 'title' => __( 'Google Merchant name:', 'woo-payu-payment-gateway' ), 'type' => 'text', 'description' => __( 'Your Google Merchant name, visible for customers.', 'woo-payu-payment-gateway' ), 'desc_tip' => true ] ]; } }