settings = is_array($s) ? $s : []; } public function is_active(): bool { return ($this->settings['enabled'] ?? 'no') === 'yes' && !empty($this->settings['stripe_publishable_key']); } /** @return array */ public function get_payment_method_script_handles(): array { if (!wp_script_is('stripe-js', 'registered')) { wp_register_script('stripe-js', 'https://js.stripe.com/v3/', [], ABOVAULT_VERSION, true); } $path = ABOVAULT_PATH . 'assets/js/blocks-checkout.js'; wp_register_script( 'abovault-blocks', ABOVAULT_URL . 'assets/js/blocks-checkout.js', ['wc-blocks-registry', 'wp-element', 'wp-html-entities', 'stripe-js'], is_file($path) ? (string) filemtime($path) : ABOVAULT_VERSION, true ); return ['abovault-blocks']; } /** @return array Exposed to JS as wcSettings.getSetting('abovault_sepa_data'). */ public function get_payment_method_data(): array { return [ 'title' => $this->settings['title'] ?? __('SEPA Direct Debit', 'abovault'), 'description' => __('Pay by SEPA Direct Debit. Your payment data is processed by Stripe; your subscription data stays on this site.', 'abovault'), 'pk' => (string) ($this->settings['stripe_publishable_key'] ?? ''), 'supports' => ['products'], // Error strings resolved server-side → block JS reads settings.i18n (same as classic checkout). 'i18n' => [ 'unavailable' => __('SEPA payment is temporarily unavailable. Please reload the page or choose another method.', 'abovault'), 'loadFailed' => __('Could not load the SEPA payment field. Please reload and try again.', 'abovault'), 'notReady' => __('Payment field not ready. Please reload the page.', 'abovault'), 'network' => __('We couldn’t reach the payment provider. Please check your connection and try again.', 'abovault'), ], ]; } }