id = 'stripe_sofort'; $this->method_title = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); /* translators: link */ $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted here.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); $this->supports = array( 'products', 'refunds', ); // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); $main_settings = get_option( 'woocommerce_stripe_settings' ); $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->enabled = $this->get_option( 'enabled' ); $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; $this->saved_cards = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false; $this->publishable_key = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : ''; $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; $this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : ''; if ( $this->testmode ) { $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; } add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); } /** * Returns all supported currencies for this payment method. * * @since 4.0.0 * @version 4.0.0 * @return array */ public function get_supported_currency() { return apply_filters( 'wc_stripe_sofort_supported_currencies', array( 'EUR', ) ); } /** * Checks to see if all criteria is met before showing payment method. * * @since 4.0.0 * @version 4.0.0 * @return bool */ public function is_available() { if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { return false; } return parent::is_available(); } /** * Get_icon function. * * @since 1.0.0 * @version 4.0.0 * @return string */ public function get_icon() { $icons = $this->payment_icons(); $icons_str = ''; $icons_str .= isset( $icons['sofort'] ) ? $icons['sofort'] : ''; return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); } /** * payment_scripts function. * * Outputs scripts used for stripe payment * * @access public */ public function payment_scripts() { if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { return; } wp_enqueue_style( 'stripe_styles' ); wp_enqueue_script( 'woocommerce_stripe' ); } /** * Initialize Gateway Settings Form Fields. */ public function init_form_fields() { $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sofort-settings.php' ); } /** * Payment form on checkout page */ public function payment_fields() { global $wp; $user = wp_get_current_user(); $total = WC()->cart->total; $description = $this->get_description(); // If paying from order, we need to get total from order not cart. if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { $order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); $total = $order->get_total(); } if ( is_add_payment_method_page() ) { $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); $total = ''; } else { $pay_button_text = ''; } echo '