Extended by individual payment gateways to handle payments.
저자: WooThemes
상속: extends WC_Settings_API
 /**
  * @param WC_Payment_Gateway $gateway
  */
 public function merge_settings(WC_Payment_Gateway $gateway)
 {
     $data = $this->get_data();
     if (isset($data['title'])) {
         $gateway->title = $data['title'];
     }
     if (isset($data['description'])) {
         $gateway->description = $data['description'];
     }
     $gateway->has_icon = $gateway->get_icon() != '';
     $gateway->show_icon = isset($data['icon']) ? $data['icon'] : true;
 }
 /**
  * Check if this gateway is enabled
  */
 public function is_available()
 {
     if (!$this->api_key || !$this->mid) {
         return false;
     }
     return parent::is_available();
 }
 /**
  * Amazon Payments Advanced is available if the following conditions are met (on top of WC_Payment_Gateway::is_available)
  * 1) Login App mode is enabled and we have an access token from Amazon
  * 2) Login App mode is *not* enabled and we have an order reference id
  *
  * @return bool
  */
 function is_available()
 {
     $login_app_enabled = 'yes' === $this->enable_login_app;
     $standard_mode_ok = !$login_app_enabled && !empty($this->reference_id);
     $login_app_mode_ok = $login_app_enabled && !empty($this->access_token);
     return parent::is_available() && ($standard_mode_ok || $login_app_mode_ok);
 }
 public function init_settings()
 {
     parent::init_settings();
     $options_to_import = array('payapp_user_id', 'payapp_link_key', 'payapp_link_val', 'checkout_methods');
     foreach ($options_to_import as $key) {
         $this->settings[$key] = get_option(wskl_get_option_name($key));
     }
     $this->settings['enabled'] = wskl_yes_or_no(wskl_is_option_enabled('enable_sym_pg') && wskl_get_option('pg_agency') == 'payapp' && in_array($this->checkout_method, $this->get_option('checkout_methods')));
 }
 public function init_settings()
 {
     parent::init_settings();
     $options_to_import = array('iamport_user_code', 'iamport_rest_key', 'iamport_rest_secret', 'checkout_methods');
     foreach ($options_to_import as $key) {
         $this->settings[$key] = wskl_get_option($key);
     }
     $this->settings['enabled'] = wskl_yes_or_no(wskl_is_option_enabled('enable_sym_pg') && wskl_get_option('pg_agency') == 'iamport' && in_array($this->checkout_method, $this->settings['checkout_methods']));
 }
 /**
  * Check if gateway meets all the requirements to be used
  *
  * @access public
  * @return bool
  */
 function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // Required fields check
     if (!$this->customer_api && !$this->customer_password) {
         $is_available = false;
     }
     return apply_filters('woocommerce_eway_is_available', $is_available);
 }
 /**
  * Check if the gateway is available for use
  *
  * @return bool
  */
 public function is_available()
 {
     $is_available = parent::is_available();
     // Only allow unencrypted connections when testing
     if (!is_ssl() && !$this->testmode) {
         $is_available = false;
     }
     // Required fields check
     if (!$this->merchant_id || !$this->merchant_password) {
         $is_available = false;
     }
     return $is_available;
 }
    /**
     * Admin Panel Options
     * - Options for bits like 'title' and availability on a country-by-country basis
     *
     * @access public
     * @return void
     */
    public function admin_options()
    {
        parent::admin_options();
        ?>
		<script type="text/javascript">
			jQuery( '#woocommerce_paypal_pro_enable_3dsecure' ).change( function () {
				var threedsec = jQuery( '#woocommerce_paypal_pro_centinel_pid, #woocommerce_paypal_pro_centinel_mid, #woocommerce_paypal_pro_centinel_pwd, #woocommerce_paypal_pro_liability_shift' ).closest( 'tr' );

				if ( jQuery( this ).is( ':checked' ) ) {
					threedsec.show();
				} else {
					threedsec.hide();
				}
			}).change();
		</script>
		<?php 
    }
 public function process_admin_options()
 {
     $post_data = $this->get_post_data();
     $mode = 'live';
     if ($post_data['woocommerce_' . $this->id . '_sandbox'] == '1') {
         $mode = 'test';
     }
     $this->merchant_id = $post_data['woocommerce_' . $this->id . '_' . $mode . '_merchant_id'];
     $this->private_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_private_key'];
     $this->publishable_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_publishable_key'];
     $env = $mode == 'live' ? 'Producton' : 'Sandbox';
     if ($this->merchant_id == '' || $this->private_key == '' || $this->publishable_key == '') {
         $settings = new WC_Admin_Settings();
         $settings->add_error('You need to enter "' . $env . '" credentials if you want to use this plugin in this mode.');
     } else {
         $this->createWebhook();
     }
     return parent::process_admin_options();
 }
 /**
  * Disables the gateway under any of these conditions:
  * 1) If the cart does not contain a pre-order
  * 2) If the pre-order amount is charged upfront
  * 3) On the pay page
  *
  * @since 1.0
  * @return bool
  */
 public function is_available()
 {
     $is_available = parent::is_available();
     // on checkout page
     if (!is_page(woocommerce_get_page_id('pay')) || defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT) {
         // not available if the cart does not contain a pre-order
         if (WC_Pre_Orders_Cart::cart_contains_pre_order()) {
             // not available when the pre-order amount is charged upfront
             if (WC_Pre_Orders_Product::product_is_charged_upfront(WC_Pre_Orders_Cart::get_pre_order_product())) {
                 $is_available = false;
             }
         } else {
             $is_available = false;
         }
     } else {
         // not available on the pay page (for now)
         $is_available = false;
     }
     return $is_available;
 }
 public function is_available()
 {
     $order = null;
     if (empty($this->authorizenet_apilogin) || empty($this->authorizenet_transactionkey)) {
         return false;
     }
     if (!empty($this->authorizenet_enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->authorizenet_enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Checks for proper gateway configuration including:
  *
  * + gateway enabled
  * + correct configuration (gateway specific)
  * + any dependencies met
  * + required currency
  * + required country
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::is_available()
  * @return true if this gateway is available for checkout, false otherwise
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->is_configured()) {
         $is_available = false;
     }
     // all plugin dependencies met
     if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     // any required currencies?
     if (!$this->currency_is_accepted()) {
         $is_available = false;
     }
     // any required countries?
     if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
         $is_available = false;
     }
     return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
 }
 /**
  * Init the based settings array and our own properties.
  *
  * @access public
  */
 public function init_settings()
 {
     // Load the settings.
     parent::init_settings();
     // Get setting values.
     $this->enabled = $this->get_option('enabled');
     $this->title = $this->get_option('title');
     $this->description = $this->get_option('description');
     $this->account_address = $this->get_option('account_address');
     $this->debug = $this->get_option('debug');
 }
 /**
  * Sanitize payment fields
  * - some gateways include js in their payment fields
  *
  * @param WC_Payment_Gateway $gateway
  * @return mixed|string
  */
 protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
 {
     $html = '';
     if ($gateway->has_fields() || $gateway->get_description()) {
         ob_start();
         $gateway->payment_fields();
         $html = ob_get_contents();
         ob_end_clean();
         // remove script tags
         $html = $this->removeDomNodes($html, '//script');
     }
     return self::trim_html_string($html);
 }
예제 #15
0
 /**
  * Check if the gateway is available for use
  *
  * @return bool
  */
 public function is_available()
 {
     if (!parent::is_available()) {
         return false;
     }
     if (WC()->cart && $this->get_order_total() > 0) {
         // Validate min amount
         if (0 < $this->min_amount && $this->min_amount > $this->get_order_total()) {
             return false;
         }
         // Validate max amount
         if (0 < $this->max_amount && $this->max_amount < $this->get_order_total()) {
             return false;
         }
     }
     return true;
 }
 /**
  * Prepare a payment gateway for response.
  *
  * @param  WC_Payment_Gateway $gateway    Payment gateway object.
  * @param  WP_REST_Request    $request    Request object.
  * @return WP_REST_Response   $response   Response data.
  */
 public function prepare_item_for_response($gateway, $request)
 {
     $order = (array) get_option('woocommerce_gateway_order');
     $item = array('id' => $gateway->id, 'title' => $gateway->title, 'description' => $gateway->description, 'order' => isset($order[$gateway->id]) ? $order[$gateway->id] : '', 'enabled' => 'yes' === $gateway->enabled, 'method_title' => $gateway->get_method_title(), 'method_description' => $gateway->get_method_description(), 'settings' => $this->get_settings($gateway));
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($item, $request);
     $data = $this->filter_response_by_context($data, $context);
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($gateway, $request));
     /**
      * Filter payment gateway objects returned from the REST API.
      *
      * @param WP_REST_Response   $response The response object.
      * @param WC_Payment_Gateway $gateway  Payment gateway object.
      * @param WP_REST_Request    $request  Request object.
      */
     return apply_filters('woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request);
 }
 /**
  * Extend woocommerce function to add our custom options
  */
 public function generate_text_html($key, $data)
 {
     $row_html = parent::generate_text_html($key, $data);
     return $this->apply_custom_row_attributes($row_html, $data);
 }
    /** 
     * Admin Panel Options 
     * - Options for bits like 'title' and availability on a country-by-country basis 
     * 
     * @access public 
     * @return void 
     */
    public function admin_options()
    {
        if ($this->is_valid_for_use()) {
            if ($this->sandbox != 'yes' && isset($_GET["show-pending"]) && $_GET["show-pending"] == '1') {
                echo $this->admin_page_top(false);
                echo $this->pending_payments();
                exit;
            } else {
                if ($this->sandbox != 'yes') {
                    echo $this->admin_page_top(true);
                }
                parent::admin_options();
            }
        } else {
            ?>
          <div class="inline error"><p><strong><?php 
            _e('Gateway Disabled', $this->td);
            ?>
</strong>: <?php 
            _e('Maksuturva does not support your store currency.', $this->td);
            ?>
</p></div>
          <?php 
        }
    }
예제 #19
0
 /**
  * Check If The Gateway Is Available For Use
  *
  * @return bool
  */
 public function is_available()
 {
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods = array_unique(WC()->session->get('chosen_shipping_methods'));
         $check_method = false;
         if (is_page(wc_get_page_id('checkout')) && !empty($wp->query_vars['order-pay'])) {
             $order_id = absint($wp->query_vars['order-pay']);
             $order = new WC_Order($order_id);
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Returns a value indicating the the Gateway is available or not.
  *
  * @return bool
  */
 public function is_available()
 {
     if (!parent::is_available()) {
         return false;
     }
     $errors = array();
     if (empty($this->email)) {
         $errors[] = __('Skrill Gateway - Email address is not configured.', $this->texdomain);
     }
     if (empty($this->secret_word)) {
         $errors[] = __('Skrill Gateway - Secret word is not configured.', $this->texdomain);
     }
     $currency = get_woocommerce_currency();
     if (!$this->is_currency_supported($currency)) {
         $errors[] = sprintf(__('Skrill Gateway - Currency not supported: "%s".', $this->texdomain), $currency);
     }
     // If, for any reason, the gateway is enabled, but not available due to
     // misconfiguration, log the issues and trigger a warning so that the Admin
     // can take the appropriate corrective action(s)
     if (!empty($errors)) {
         $errors[] = __('Skrill Gateway disabled.', $this->text_domain);
         foreach ($errors as $error_msg) {
             $this->log($error_msg);
             trigger_error($error_msg, E_USER_WARNING);
         }
         return false;
     }
     return true;
 }
 /**
  * Checks for proper gateway configuration including:
  *
  * + gateway enabled
  * + correct configuration (gateway specific)
  * + any dependencies met
  * + required currency
  * + required country
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::is_available()
  * @return true if this gateway is available for checkout, false otherwise
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->is_configured()) {
         $is_available = false;
     }
     // all plugin dependencies met
     if (count($this->get_plugin()->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     // any required currencies?
     if (!$this->currency_is_accepted()) {
         $is_available = false;
     }
     // any required countries?
     if ($this->countries && WC()->customer && WC()->customer->get_country() && !in_array(WC()->customer->get_country(), $this->countries)) {
         $is_available = false;
     }
     /**
      * Payment Gateway Is Available Filter.
      *
      * Allow actors to modify whether the gateway is available or not.
      *
      * @since 1.0.0
      * @param bool $is_available
      */
     return apply_filters('wc_gateway_' . $this->get_id() . '_is_available', $is_available);
 }
 /**
  * Checks for proper gateway configuration (required fields populated, etc)
  * and that there are no missing dependencies
  *
  * @see WC_Payment_Gateway::is_available()
  */
 public function is_available()
 {
     // proper configuration
     if (!$this->get_ssl_merchant_id() || !$this->get_ssl_user_id() || !$this->get_ssl_pin()) {
         return false;
     }
     // all dependencies met
     if (count(wc_elavon_vm()->get_missing_dependencies()) > 0) {
         return false;
     }
     return parent::is_available();
 }
    /**
     * Admin Panel Options
     */
    public function admin_options()
    {
        if ($this->is_valid_for_use()) {
            parent::admin_options();
        } else {
            ?>
			<div class="inline error"><p><strong><?php 
            _e('Gateway Disabled', 'woocommerce');
            ?>
</strong>: <?php 
            _e('Komoju does not support your store currency.', 'woocommerce');
            ?>
</p></div>
			<?php 
        }
    }
 /**
  * Check If The Gateway Is Available For Use
  *
  * @return bool
  */
 public function is_available()
 {
     $order = null;
     if (!$this->enable_for_virtual) {
         if (WC()->cart && !WC()->cart->needs_shipping()) {
             return false;
         }
         if (is_page(wc_get_page_id('checkout')) && 0 < get_query_var('order-pay')) {
             $order_id = absint(get_query_var('order-pay'));
             $order = new WC_Order($order_id);
             // Test if order needs shipping.
             $needs_shipping = false;
             if (0 < sizeof($order->get_items())) {
                 foreach ($order->get_items() as $item) {
                     $_product = $order->get_product_from_item($item);
                     if ($_product->needs_shipping()) {
                         $needs_shipping = true;
                         break;
                     }
                 }
             }
             $needs_shipping = apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
             if ($needs_shipping) {
                 return false;
             }
         }
     }
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
 /**
  * Checks for proper gateway configuration (required fields populated, etc)
  * and that there are no missing dependencies
  *
  * @since 2.0
  */
 public function is_available()
 {
     // is enabled check
     $is_available = parent::is_available();
     // proper configuration
     if (!$this->get_access_key() || !$this->get_secret_key()) {
         $is_available = false;
     }
     // all dependencies met
     if (count($GLOBALS['wc_amazon_fps']->get_missing_dependencies()) > 0) {
         $is_available = false;
     }
     return apply_filters('wc_gateway_amazon_fps_is_available', $is_available);
 }
 /**
  * Edit the Subscriptions automatic renewal payments support column content
  * when a gateway supports subscriptions (via tokenization) but tokenization
  * is not enabled
  *
  * @since 4.1.0
  * @param string $html column content
  * @param \WC_Payment_Gateway|\SV_WC_Payment_Gateway $gateway payment gateway being checked for support
  * @return string html
  */
 public function subscriptions_maybe_edit_renewal_support_status($html, $gateway)
 {
     // only for our gateways
     if (!in_array($gateway->id, $this->get_gateway_ids())) {
         return $html;
     }
     if ($gateway->is_enabled() && $gateway->supports_tokenization() && !$gateway->tokenization_enabled()) {
         $tool_tip = esc_attr__('You must enable tokenization for this gateway in order to support automatic renewal payments with the WooCommerce Subscriptions extension.', 'woocommerce-plugin-framework');
         $status = esc_html__('Inactive', 'woocommerce-plugin-framework');
         $html = sprintf('<a href="%1$s"><span class="sv-wc-payment-gateway-renewal-status-inactive tips" data-tip="%2$s">%3$s</span></a>', esc_url(SV_WC_Payment_Gateway_Helper::get_payment_gateway_configuration_url($this->get_gateway_class_name($gateway->get_id()))), $tool_tip, $status);
     }
     return $html;
 }
예제 #27
0
            public function payment_fields()
            {
                global $woocommerce;
                if (!$GLOBALS['paymill_active']) {
                    paymill_load_frontend_scripts();
                    // load frontend scripts
                    // settings
                    $GLOBALS['paymill_active'] = true;
                    $cart_total = WC_Payment_Gateway::get_order_total() * 100;
                    $currency = get_woocommerce_currency();
                    $no_logos = true;
                    // form ids
                    echo '<script>
						paymill_form_checkout_id = "form.checkout, form#order_review";
						paymill_form_checkout_submit_id = "#place_order";
						paymill_shop_name = "woocommerce";
						paymill_pcidss3 = ' . (empty($GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3']) || $GLOBALS['paymill_settings']->paymill_general_settings['pci_dss_3'] != '1' ? 1 : 0) . ';
						paymill_pcidss3_lang = "' . substr(apply_filters('plugin_locale', get_locale(), $domain), 0, 2) . '";
						</script>';
                    echo '<a href="https://www.paymill.com/" target="_blank"><img src="' . WC_HTTPS::force_https_url($this->logo_small) . '" alt="' . $this->title . '" /></a>';
                    echo '<p class="paymill_payment_description">' . $this->settings['description'] . '</p>';
                    require_once PAYMILL_DIR . 'lib/tpl/checkout_form.php';
                } else {
                    echo '<div class="paymill_notification paymill_notification_once_only"><strong>Error:</strong> Paymill can be loaded once only on the same page.</div>';
                }
                return true;
            }
예제 #28
0
 /**
  * Get the transaction URL.
  *
  * @param  WC_Order $order
  *
  * @return string
  */
 public function get_transaction_url($order)
 {
     if ($this->testmode) {
         $this->view_transaction_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s';
     } else {
         $this->view_transaction_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s';
     }
     return parent::get_transaction_url($order);
 }
	/**
	* extend parent method for initialising settings, so that new settings can receive defaults
	*/
	public function init_settings() {
		parent::init_settings();

		if (is_callable(array($this, 'get_form_fields'))) {
			$form_fields = $this->get_form_fields();
		}
		else {
			// WooCommerce 2.0.20 or earlier
			$form_fields = $this->form_fields;
		}

		if ($form_fields) {
			foreach ($form_fields as $key => $value) {
				if (!isset($this->settings[$key])) {
					$this->settings[$key] = isset($value['default']) ? $value['default'] : '';
				}
			}
		}
	}
예제 #30
-4
 public function process_admin_options()
 {
     $target_dir = IMAGE_FOLDER_URL;
     $target_file = $target_dir . basename($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]);
     if ($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]) {
         try {
             move_uploaded_file($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["tmp_name"], $target_file);
             chmod($target_file, 0777);
         } catch (Exception $e) {
             echo 'error in uploading file';
         }
     }
     $value = isset($_POST['woocommerce_Pwacheckout_pwa_delete_img']) ? $_POST['woocommerce_Pwacheckout_pwa_delete_img'] : 0;
     if (!$value && $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name']) {
         $_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = IMAGE_FOLDER_HTTPURL . $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name'];
     } elseif ($value) {
         $_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = '';
     }
     $_POST['woocommerce_Pwacheckout_pwa_delete_img'] = 0;
     parent::process_admin_options();
 }