settings = get_option( 'woocommerce_ach_processing_settings', [] ); $gateways = WC()->payment_gateways()->payment_gateways(); $this->gateway = $gateways[ $this->name ] ?? null; } public function is_active() { return $this->gateway instanceof Woo_ACH_Processing && $this->gateway->is_available(); } public function get_payment_method_script_handles() { $asset_file = ACHP_PLUGIN_DIR . '/assets/js/blocks/index.asset.php'; if ( file_exists( $asset_file ) ) { $asset = include $asset_file; } else { // Fallback if wp-scripts hasn't been run yet; covers new checkouts // of the repo before `npm run build:blocks` has executed. $asset = [ 'dependencies' => [ 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n' ], 'version' => ACHP_VERSION, ]; } wp_register_script( 'achp-blocks', plugins_url( 'assets/js/blocks/index.js', ACHP_PLUGIN_FILE ), $asset['dependencies'], $asset['version'], true ); if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( 'achp-blocks', ACHP_TEXT_DOMAIN ); } return [ 'achp-blocks' ]; } public function get_payment_method_data() { $title = $this->get_setting( 'title' ); $description = $this->get_setting( 'description' ); $supports = []; if ( $this->gateway instanceof Woo_ACH_Processing ) { $supports = array_values( array_filter( $this->gateway->supports, static function ( $feature ) { return in_array( $feature, [ 'products', 'refunds' ], true ); } ) ); } return [ 'title' => $title ? $title : __( 'ACH Processing', ACHP_TEXT_DOMAIN ), 'description' => $description, 'bankaccountEnabled' => 'yes' === ( $this->settings['bankaccount_enabled'] ?? 'no' ), 'creditcardEnabled' => 'yes' === ( $this->settings['creditcard_enabled'] ?? 'no' ), 'bankLabel' => $this->get_setting( 'bank_pay_text', __( 'Pay with Bank Account', ACHP_TEXT_DOMAIN ) ), 'cardLabel' => $this->get_setting( 'credit_card_pay_text', __( 'Pay with Credit Card', ACHP_TEXT_DOMAIN ) ), 'supports' => $supports, ]; } }