2011-08-09 15:16:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2011-08-10 17:11:11 +00:00
|
|
|
* WooCommerce Payment Gateway class
|
|
|
|
*
|
|
|
|
* Extended by individual payment gateways to handle payments.
|
|
|
|
*
|
2012-01-21 09:01:41 +00:00
|
|
|
* @class Woocommerce_Payment_Gateway
|
2011-08-10 17:11:11 +00:00
|
|
|
* @package WooCommerce
|
|
|
|
* @category Payment Gateways
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
2012-01-21 09:01:41 +00:00
|
|
|
class Woocommerce_Payment_Gateway extends Woocommerce_Settings_Api {
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
var $id;
|
|
|
|
var $title;
|
|
|
|
var $chosen;
|
|
|
|
var $has_fields;
|
|
|
|
var $countries;
|
|
|
|
var $availability;
|
|
|
|
var $enabled;
|
|
|
|
var $icon;
|
|
|
|
var $description;
|
|
|
|
|
2011-10-23 11:25:22 +00:00
|
|
|
/**
|
|
|
|
* Get the return url (thank you page)
|
|
|
|
*
|
|
|
|
* @since 1.1.2
|
|
|
|
*/
|
|
|
|
function get_return_url( $order = '' ) {
|
|
|
|
|
2012-01-06 17:14:31 +00:00
|
|
|
$thanks_page_id = woocommerce_get_page_id('thanks');
|
2011-10-23 11:25:22 +00:00
|
|
|
if ($thanks_page_id) :
|
|
|
|
$return_url = get_permalink($thanks_page_id);
|
|
|
|
else :
|
|
|
|
$return_url = home_url();
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( $order ) :
|
|
|
|
$return_url = add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, $return_url));
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if (is_ssl() || get_option('woocommerce_force_ssl_checkout')=='yes') $return_url = str_replace('http:', 'https:', $return_url);
|
|
|
|
|
2012-01-06 17:14:31 +00:00
|
|
|
return apply_filters('woocommerce_get_return_url', $return_url);
|
2011-10-23 11:25:22 +00:00
|
|
|
}
|
2011-09-07 09:39:40 +00:00
|
|
|
|
2011-09-27 08:41:38 +00:00
|
|
|
/**
|
|
|
|
* Check If The Gateway Is Available For Use
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
2011-08-09 15:16:18 +00:00
|
|
|
function is_available() {
|
|
|
|
|
|
|
|
if ($this->enabled=="yes") :
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-27 08:41:38 +00:00
|
|
|
/**
|
|
|
|
* Set As Current Gateway.
|
|
|
|
*
|
|
|
|
* Set this as the current gateway.
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
2011-08-09 15:16:18 +00:00
|
|
|
function set_current() {
|
|
|
|
$this->chosen = true;
|
|
|
|
}
|
|
|
|
|
2011-09-27 08:41:38 +00:00
|
|
|
/**
|
|
|
|
* The Gateway Icon
|
|
|
|
*
|
|
|
|
* Display the gateway's icon.
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
2011-08-09 15:16:18 +00:00
|
|
|
function icon() {
|
2011-09-06 11:11:22 +00:00
|
|
|
global $woocommerce;
|
2011-08-09 15:16:18 +00:00
|
|
|
if ($this->icon) :
|
2011-09-06 11:11:22 +00:00
|
|
|
return '<img src="'. $woocommerce->force_ssl($this->icon).'" alt="'.$this->title.'" />';
|
2011-08-09 15:16:18 +00:00
|
|
|
endif;
|
|
|
|
}
|
|
|
|
|
2011-09-27 08:41:38 +00:00
|
|
|
/**
|
|
|
|
* Process Payment
|
|
|
|
*
|
|
|
|
* Process the payment. Override this in your gateway.
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
2011-08-09 15:16:18 +00:00
|
|
|
function process_payment() {}
|
|
|
|
|
2011-09-27 08:41:38 +00:00
|
|
|
/**
|
|
|
|
* Validate Frontend Fields
|
|
|
|
*
|
|
|
|
* Validate payment fields on the frontend.
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
2011-08-09 15:16:18 +00:00
|
|
|
function validate_fields() { return true; }
|
2011-09-07 09:39:40 +00:00
|
|
|
|
2011-12-20 15:44:46 +00:00
|
|
|
/**
|
|
|
|
* If There are no payment fields show the description if set.
|
|
|
|
* Override this in your gateway if you have some.
|
|
|
|
*/
|
|
|
|
function payment_fields() {
|
|
|
|
if ($this->description) echo wpautop(wptexturize($this->description));
|
|
|
|
}
|
2011-09-27 09:38:29 +00:00
|
|
|
|
2011-08-09 15:16:18 +00:00
|
|
|
}
|