mijireh gateway

This commit is contained in:
Mike Jolley 2012-06-08 11:46:10 +01:00
parent 0fce6aecaa
commit 0f905e9cd0
24 changed files with 1549 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -116,6 +116,12 @@
#wc_get_started .main-button { position: absolute; right: 20px; top: 27px; }
#wc_get_started p { margin: 1em 0 .5em; }
#wc_get_started.mijireh { background: #5bc0de url(../images/mijireh-logo.png) no-repeat 15px 18px; border: 1px solid #339bb9; padding: 15px 15px 15px 152px; box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 ); -moz-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 ); -webkit-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 ); }
#wc_get_started.mijireh span { color: #fff; text-shadow: 0 1px 0 #4a94ac; }
#wc_get_started.mijireh span a { color: #fff; }
#wc_get_started.mijireh a.button { border-color: #fff; box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.1 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.1 ), 0 1px 3px #206d8b; -moz-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.1 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.1 ), 0 1px 3px #206d8b; -webkit-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.1 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.1 ), 0 1px 3px #206d8b; }
#wc_get_started.mijireh a.button-primary { background: #2b7e9f; border-color: #266e8b; }
#icon-woocommerce, .woocommerce_icon, .icon32-posts-product, .icon32-posts-shop_order, .icon32-posts-shop_coupon, .icon32-posts-product_variation {
background-image: url(../images/icons/woocommerce-icons.png) !important;
background-position: -11px -6px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -758,7 +758,7 @@ class WC_Order {
$this->update_status( $new_order_status );
add_post_meta( $this->id, '_paid_date', $meta_value, $unique);
add_post_meta( $this->id, '_paid_date', current_time('mysql'), true );
$this_order = array(
'ID' => $this->id,

View File

@ -0,0 +1,116 @@
<?php
$root_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
// Require the mijireh library classes
require_once $root_dir . 'Mijireh/Rest.php';
require_once $root_dir . 'Mijireh/RestJSON.php';
require_once $root_dir . 'Mijireh/Model.php';
require_once $root_dir . 'Mijireh/Address.php';
require_once $root_dir . 'Mijireh/Item.php';
require_once $root_dir . 'Mijireh/Order.php';
class Mijireh_Exception extends Exception {}
class Mijireh_ClientError extends Mijireh_Exception {} /* Status: 400-499 */
class Mijireh_BadRequest extends Mijireh_ClientError {} /* Status: 400 */
class Mijireh_Unauthorized extends Mijireh_ClientError {} /* Status: 401 */
class Mijireh_NotFound extends Mijireh_ClientError {} /* Status: 404 */
class Mijireh_ServerError extends Mijireh_Exception {} /* Status: 500-599 */
class Mijireh_InternalError extends Mijireh_ServerError {} /* Status: 500 */
class Mijireh {
/* Live server urls */
public static $base_url = 'https://secure.mijireh.com/';
public static $url = 'https://secure.mijireh.com/api/1/';
public static $access_key;
/**
* Return the job id of the slurp
*/
public static function slurp($url) {
$url_format = '/^(https?):\/\/'. // protocol
'(([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+'. // username
'(:([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+)?'. // password
'@)?(?#'. // auth requires @
')((([a-z0-9][a-z0-9-]*[a-z0-9]\.)*'. // domain segments AND
'[a-z][a-z0-9-]*[a-z0-9]'. // top level domain OR
'|((\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5])\.){3}'.
'(\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5])'. // IP address
')(:\d+)?'. // port
')(((\/+([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)*'. // path
'(\?([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)'. // query string
'?)?)?'. // path and query string optional
'(#([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)?'. // fragment
'$/i';
if(!preg_match($url_format, $url)) {
throw new Mijireh_NotFound('Unable to slurp invalid URL: $url');
}
try {
$rest = new Mijireh_Rest($url);
$html = $rest->get('');
$data = array(
'url' => $url,
'html' => $html,
);
$rest = new Mijireh_RestJSON(self::$url);
$rest->setupAuth(self::$access_key, '');
$result = $rest->post('slurps', $data);
return $result['job_id'];
}
catch(Mijireh_Rest_Unauthorized $e) {
throw new Mijireh_Unauthorized("Unauthorized. Please check your api access key");
}
catch(Mijireh_Rest_NotFound $e) {
throw new Mijireh_NotFound("Mijireh resource not found: " . $rest->last_request['url']);
}
catch(Mijireh_Rest_ClientError $e) {
throw new Mijireh_ClientError($e->getMessage());
}
catch(Mijireh_Rest_ServerError $e) {
throw new Mijireh_ServerError($e->getMessage());
}
catch(Mijireh_Rest_UnknownResponse $e) {
throw new Mijireh_Exception('Unable to slurp the URL: $url');
}
}
/**
* Return an array of store information
*/
public static function get_store_info() {
$rest = new Mijireh_RestJSON(self::$url);
$rest->setupAuth(self::$access_key, '');
try {
$result = $rest->get('store');
return $result;
}
catch(Mijireh_Rest_BadRequest $e) {
throw new Mijireh_BadRequest($e->getMessage());
}
catch(Mijireh_Rest_Unauthorized $e) {
throw new Mijireh_Unauthorized("Unauthorized. Please check your api access key");
}
catch(Mijireh_Rest_NotFound $e) {
throw new Mijireh_NotFound("Mijireh resource not found: " . $rest->last_request['url']);
}
catch(Mijireh_Rest_ClientError $e) {
throw new Mijireh_ClientError($e->getMessage());
}
catch(Mijireh_Rest_ServerError $e) {
throw new Mijireh_ServerError($e->getMessage());
}
}
public static function preview_checkout_link() {
if(empty(Mijireh::$access_key)) {
throw new Mijireh_Exception('Access key required to view checkout preview');
}
return self::$base_url . 'checkout/' . self::$access_key;
}
}

View File

@ -0,0 +1,45 @@
<?php
class Mijireh_Address extends Mijireh_Model {
public function __construct() {
$this->init();
}
public function init() {
$this->_data = array(
'first_name' => '',
'last_name' => '',
'street' => '',
'city' => '',
'state_province' => '',
'zip_code' => '',
'country' => '',
'company' => '',
'apt_suite' => '',
'phone' => ''
);
}
public function validate() {
$is_valid = $this->_check_required_fields();
return $is_valid;
}
/**
* Return true if all of the required fields have a non-empty value
*
* @return boolean
*/
private function _check_required_fields() {
$pass = true;
$fields = array('street', 'city', 'state_province', 'zip_code', 'country');
foreach($fields as $f) {
if(empty($this->_data[$f])) {
$pass = false;
$this->add_error("$f is required");
}
}
return $pass;
}
}

View File

@ -0,0 +1,57 @@
<?php
class Mijireh_Item extends Mijireh_Model {
private function _init() {
$this->_data = array(
'name' => null,
'price' => null,
'quantity' => 1,
'sku' => null
);
}
private function _check_required_fields() {
if(empty($this->_data['name'])) {
$this->add_error('item name is required.');
}
if(!is_numeric($this->_data['price'])) {
$this->add_error('price must be a number.');
}
}
private function _check_quantity() {
if($this->_data['quantity'] < 1) {
$this->add_error('quantity must be greater than or equal to 1');
}
}
public function __construct() {
$this->_init();
}
public function __get($key) {
$value = false;
if($key == 'total') {
$value = $this->_data['price'] * $this->_data['quantity'];
$value = number_format($value, 2, '.', '');
}
else {
$value = parent::__get($key);
}
return $value;
}
public function get_data() {
$data = parent::get_data();
$data['total'] = $this->total;
return $data;
}
public function validate() {
$this->_check_required_fields();
$this->_check_quantity();
return count($this->_errors) == 0;
}
}

View File

@ -0,0 +1,133 @@
<?php
class Mijireh_Model {
protected $_data = array();
protected $_errors = array();
/**
* Set the value of one of the keys in the private $_data array.
*
* @param string $key The key in the $_data array
* @param string $value The value to assign to the key
* @return boolean
*/
public function __set($key, $value) {
$success = false;
if(array_key_exists($key, $this->_data)) {
$this->_data[$key] = $value;
$success = true;
}
return $success;
}
/**
* Get the value for the key from the private $_data array.
*
* Return false if the requested key does not exist
*
* @param string $key The key from the $_data array
* @return mixed
*/
public function __get($key) {
$value = false;
if(array_key_exists($key, $this->_data)) {
$value = $this->_data[$key];
}
/*
elseif(method_exists($this, $key)) {
$value = call_user_func_array(array($this, $key), func_get_args());
}
*/
return $value;
}
/**
* Return true if the given $key in the private $_data array is set
*
* @param string $key
* @return boolean
*/
public function __isset($key) {
return isset($this->_data[$key]);
}
/**
* Set the value of the $_data array to null for the given key.
*
* @param string $key
* @return void
*/
public function __unset($key) {
if(array_key_exists($key, $this->_data)) {
$this->_data[$key] = null;
}
}
/**
* Return the private $_data array
*
* @return mixed
*/
public function get_data() {
return $this->_data;
}
/**
* Return true if the given $key exists in the private $_data array
*
* @param string $key
* @return boolean
*/
public function field_exists($key) {
return array_key_exists($key, $this->_data);
}
public function copy_from(array $data) {
foreach($data as $key => $value) {
if(array_key_exists($key, $this->_data)) {
$this->_data[$key] = $value;
}
}
}
public function clear() {
foreach($this->_data as $key => $value) {
if($key == 'id') {
$this->_data[$key] = null;
}
else {
$this->_data[$key] = '';
}
}
}
public function add_error($error_message) {
if(!empty($error_message)) {
$this->_errors[] = $error_message;
}
}
public function clear_errors() {
$this->_errors = array();
}
public function get_errors() {
return $this->_errors;
}
public function get_error_lines($glue="\n") {
$error_lines = '';
if(count($this->_errors)) {
$error_lines = implode($glue, $this->_errors);
}
return $error_lines;
}
public function is_valid() {
return count($this->_errors) == 0;
}
}

View File

@ -0,0 +1,340 @@
<?php
class Mijireh_Order extends Mijireh_Model {
private function _init() {
$this->_data = array(
'partner_id' => null,
'order_number' => null,
'mode' => null,
'status' => null,
'order_date' => null,
'ip_address' => null,
'checkout_url' => null,
'total' => '',
'return_url' => '',
'items' => array(),
'email' => '',
'first_name' => '',
'last_name' => '',
'meta_data' => array(),
'tax' => '',
'shipping' => '',
'discount' => '',
'shipping_address' => array(),
'billing_address' => array()
);
}
public function __construct($order_number=null) {
$this->_init();
if(isset($order_number)) {
$this->load($order_number);
}
}
public function load($order_number) {
if(strlen(Mijireh::$access_key) < 5) {
throw new Mijireh_Exception('missing mijireh access key');
}
$rest = new Mijireh_RestJSON(Mijireh::$url);
$rest->setupAuth(Mijireh::$access_key, '');
try {
$order_data = $rest->get("orders/$order_number");
$this->copy_from($order_data);
return $this;
}
catch(Mijireh_Rest_BadRequest $e) {
throw new Mijireh_BadRequest($e->getMessage());
}
catch(Mijireh_Rest_Unauthorized $e) {
throw new Mijireh_Unauthorized("Unauthorized. Please check your api access key");
}
catch(Mijireh_Rest_NotFound $e) {
throw new Mijireh_NotFound("Mijireh resource not found: " . $rest->last_request['url']);
}
catch(Mijireh_Rest_ClientError $e) {
throw new Mijireh_ClientError($e->getMessage());
}
catch(Mijireh_Rest_ServerError $e) {
throw new Mijireh_ServerError($e->getMessage());
}
}
public function copy_from($order_data) {
foreach($order_data as $key => $value) {
if($key == 'items') {
if(is_array($value)) {
$this->clear_items(); // Clear current items before adding new items.
foreach($value as $item_array) {
$item = new Mijireh_Item();
$item->copy_from($item_array);
$this->add_item($item);
}
}
}
elseif($key == 'shipping_address') {
if(is_array($value)) {
$address = new Mijireh_Address();
$address->copy_from($value);
$this->set_shipping_address($address);
}
}
elseif($key == 'billing_address') {
if(is_array($value)) {
$address = new Mijireh_Address();
$address->copy_from($value);
$this->set_billing_address($address);
}
}
elseif($key == 'meta_data') {
if(is_array($value)) {
$this->clear_meta_data(); // Clear current meta data before adding new meta data
$this->_data['meta_data'] = $value;
}
}
else {
$this->$key = $value;
}
}
if(!$this->validate()) {
throw new Mijireh_Exception('invalid order hydration: ' . $this->get_errors_lines());
}
return $this;
}
public function create() {
if(strlen(Mijireh::$access_key) < 5) {
throw new Mijireh_Exception('missing mijireh access key');
}
if(!$this->validate()) {
$error_message = 'unable to create order: ' . $this->get_error_lines();
throw new Mijireh_Exception($error_message);
}
$rest = new Mijireh_RestJSON(Mijireh::$url);
$rest->setupAuth(Mijireh::$access_key, '');
try {
$result = $rest->post('orders', $this->get_data());
$this->copy_from($result);
return $this;
}
catch(Mijireh_Rest_BadRequest $e) {
throw new Mijireh_BadRequest($e->getMessage());
}
catch(Mijireh_Rest_Unauthorized $e) {
throw new Mijireh_Unauthorized("Unauthorized. Please check your api access key");
}
catch(Mijireh_Rest_NotFound $e) {
throw new Mijireh_NotFound("Mijireh resource not found: " . $rest->last_request['url']);
}
catch(Mijireh_Rest_ClientError $e) {
throw new Mijireh_ClientError($e->getMessage());
}
catch(Mijireh_Rest_ServerError $e) {
throw new Mijireh_ServerError($e->getMessage());
}
}
/**
* If meta_data or shipping_address are empty, exclude them altogether.
*/
public function get_data() {
$data = parent::get_data();
if(count($data['meta_data']) == 0) { unset($data['meta_data']); }
if(count($data['shipping_address']) == 0) { unset($data['shipping_address']); }
if(count($data['billing_address']) == 0) { unset($data['billing_address']); }
return $data;
}
/**
* Add the specified item and price to the order.
*
* Return the total number of items in the order (including the one that was just added)
*
* @return int
*/
public function add_item($name, $price=0, $quantity=1, $sku='') {
$item = '';
if(is_object($name) && get_class($name) == 'Mijireh_Item') {
$item = $name;
}
else {
$item = new Mijireh_Item();
$item->name = $name;
$item->price = $price;
$item->quantity = $quantity;
$item->sku = $sku;
}
if($item->validate()) {
$this->_data['items'][] = $item->get_data();
return $this->item_count();
}
else {
$errors = implode(' ', $item->get_errors());
throw new Mijireh_Exception('unable to add invalid item to order :: ' . $errors);
}
}
public function add_meta_data($key, $value) {
if(!is_array($this->_data['meta_data'])) {
$this->_data['meta_data'] = array();
}
$this->_data['meta_data'][$key] = $value;
}
/**
* Return the value associated with the given key in the order's meta data.
*
* If the key does not exist, return false.
*/
public function get_meta_value($key) {
$value = false;
if(isset($this->_data['meta_data'][$key])) {
$value = $this->_data['meta_data'][$key];
}
return $value;
}
public function item_count() {
$item_count = 0;
if(is_array($this->_data['items'])) {
$item_count = count($this->_data['items']);
}
return $item_count;
}
public function get_items() {
$items = array();
foreach($this->_data['items'] as $item_data) {
$item = new Mijireh_Item();
$item->copy_from($item_data);
}
}
public function clear_items() {
$this->_data['items'] = array();
}
public function clear_meta_data() {
$this->_data['meta_data'] = array();
}
public function validate() {
$this->_check_total();
$this->_check_return_url();
$this->_check_items();
return count($this->_errors) == 0;
}
/**
* Alias for set_shipping_address()
*/
public function set_address(Mijireh_Address $address){
$this->set_shipping_address($address);
}
public function set_shipping_address(Mijireh_Address $address) {
if($address->validate()) {
$this->_data['shipping_address'] = $address->get_data();
}
else {
throw new Mijireh_Exception('invalid shipping address');
}
}
public function set_billing_address(Mijireh_Address $address) {
if($address->validate()) {
$this->_data['billing_address'] = $address->get_data();
}
else {
throw new Mijireh_Exception('invalid shipping address');
}
}
/**
* Alias for get_shipping_address()
*/
public function get_address() {
return $this->get_shipping_address();
}
public function get_shipping_address() {
$address = false;
if(is_array($this->_data['shipping_address'])) {
$address = new Mijireh_Address();
$address->copy_from($this->_data['shipping_address']);
}
return $address;
}
public function get_billing_address() {
$address = false;
if(is_array($this->_data['billing_address'])) {
$address = new Mijireh_Address();
$address->copy_from($this->_data['billing_address']);
}
return $address;
}
/**
* The order total must be greater than zero.
*
* Return true if valid, otherwise false.
*
* @return boolean
*/
private function _check_total() {
$is_valid = true;
if($this->_data['total'] <= 0) {
$this->add_error('order total must be greater than zero');
$is_valid = false;
}
return $is_valid;
}
/**
* The return url must be provided and must start with http.
*
* Return true if valid, otherwise false
*
* @return boolean
*/
private function _check_return_url() {
$is_valid = false;
if(!empty($this->_data['return_url'])) {
$url = $this->_data['return_url'];
if('http' == strtolower(substr($url, 0, 4))) {
$is_valid = true;
}
else {
$this->add_error('return url is invalid');
}
}
else {
$this->add_error('return url is required');
}
return $is_valid;
}
/**
* An order must contain at least one item
*
* Return true if the order has at least one item, otherwise false.
*
* @return boolean
*/
private function _check_items() {
$is_valid = true;
if(count($this->_data['items']) <= 0) {
$is_valid = false;
$this->add_error('the order must contain at least one item');
}
return $is_valid;
}
}

View File

@ -0,0 +1,244 @@
<?php
/**
* Mijireh_Rest is a REST client for PHP.
*
* This code is licensed for use, modification, and distribution
* under the terms of the MIT License (see http://en.wikipedia.org/wiki/MIT_License)
*/
class Mijireh_Rest {
public $curl_opts = array(
CURLOPT_RETURNTRANSFER => true, // return result instead of echoing
CURLOPT_SSL_VERIFYPEER => false, // stop cURL from verifying the peer's certificate
CURLOPT_MAXREDIRS => 10 // but dont redirect more than 10 times
);
public $base_url;
public $last_response;
public $last_request;
public $throw_exceptions = true;
public function __construct($base_url, $curl_options=null) {
if (!function_exists('curl_init')) {
throw new Exception('CURL module not available! Mijireh_Rest requires CURL. See http://php.net/manual/en/book.curl.php');
}
if(isset($curl_options) && is_array($curl_options)) {
foreach($curl_options as $key => $value) {
if($key == 'CURLOPT_FOLLOWLOCATION') {
// only enable CURLOPT_FOLLOWLOCATION if safe_mode and open_base_dir are not in use
if(ini_get('open_basedir') == '' && !ini_get('safe_mode')) {
$this->curl_opts['CURLOPT_FOLLOWLOCATION'] = true;
}
}
else {
$this->curl_opts[$key] = $value;
}
}
}
$this->base_url = $base_url;
}
// $auth can be 'basic' or 'digest'
public function setupAuth($user, $pass, $auth = 'basic') {
$this->curl_opts[CURLOPT_HTTPAUTH] = constant('CURLAUTH_'.strtoupper($auth));
$this->curl_opts[CURLOPT_USERPWD] = $user . ":" . $pass;
}
public function get($url) {
$curl = $this->prepRequest($this->curl_opts, $url);
$body = $this->doRequest($curl);
$body = $this->processBody($body);
return $body;
}
public function post($url, $data, $headers=array()) {
$data = (is_array($data)) ? http_build_query($data) : $data;
$curl_opts = $this->curl_opts;
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'POST';
$headers[] = 'Content-Length: '.strlen($data);
$curl_opts[CURLOPT_HTTPHEADER] = $headers;
$curl_opts[CURLOPT_POSTFIELDS] = $data;
$curl = $this->prepRequest($curl_opts, $url);
$body = $this->doRequest($curl);
$body = $this->processBody($body);
return $body;
}
public function put($url, $data, $headers=array()) {
$data = (is_array($data)) ? http_build_query($data) : $data;
$curl_opts = $this->curl_opts;
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
$headers[] = 'Content-Length: '.strlen($data);
$curl_opts[CURLOPT_HTTPHEADER] = $headers;
$curl_opts[CURLOPT_POSTFIELDS] = $data;
$curl = $this->prepRequest($curl_opts, $url);
$body = $this->doRequest($curl);
$body = $this->processBody($body);
return $body;
}
public function delete($url) {
$curl_opts = $this->curl_opts;
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
$curl = $this->prepRequest($curl_opts, $url);
$body = $this->doRequest($curl);
$body = $this->processBody($body);
return $body;
}
public function lastBody() {
return $this->last_response['body'];
}
public function lastStatus() {
return $this->last_response['meta']['http_code'];
}
protected function processBody($body) {
// Override this in classes that extend Mijireh_Rest.
// The body of every GET/POST/PUT/DELETE response goes through
// here prior to being returned.
return $body;
}
protected function processError($body) {
// Override this in classes that extend Mijireh_Rest.
// The body of every erroneous (non-2xx/3xx) GET/POST/PUT/DELETE
// response goes through here prior to being used as the 'message'
// of the resulting Mijireh_Rest_Exception
return $body;
}
protected function prepRequest($opts, $url) {
if (strncmp($url, $this->base_url, strlen($this->base_url)) != 0) {
$url = $this->base_url . $url;
}
$curl = curl_init($url);
foreach ($opts as $opt => $val) {
@curl_setopt($curl, $opt, $val);
}
$this->last_request = array(
'url' => $url
);
if (isset($opts[CURLOPT_CUSTOMREQUEST]))
$this->last_request['method'] = $opts[CURLOPT_CUSTOMREQUEST];
else
$this->last_request['method'] = 'GET';
if (isset($opts[CURLOPT_POSTFIELDS]))
$this->last_request['data'] = $opts[CURLOPT_POSTFIELDS];
return $curl;
}
private function doRequest($curl) {
$body = curl_exec($curl);
$meta = curl_getinfo($curl);
$this->last_response = array(
'body' => $body,
'meta' => $meta
);
curl_close($curl);
$this->checkLastResponseForError();
return $body;
}
protected function checkLastResponseForError() {
if ( !$this->throw_exceptions)
return;
$meta = $this->last_response['meta'];
$body = $this->last_response['body'];
if (!$meta)
return;
$err = null;
switch ($meta['http_code']) {
case 400:
throw new Mijireh_Rest_BadRequest($this->processError($body));
break;
case 401:
throw new Mijireh_Rest_Unauthorized($this->processError($body));
break;
case 403:
throw new Mijireh_Rest_Forbidden($this->processError($body));
break;
case 404:
throw new Mijireh_Rest_NotFound($this->processError($body));
break;
case 405:
throw new Mijireh_Rest_MethodNotAllowed($this->processError($body));
break;
case 409:
throw new Mijireh_Rest_Conflict($this->processError($body));
break;
case 410:
throw new Mijireh_Rest_Gone($this->processError($body));
break;
case 422:
// Unprocessable Entity -- see http://www.iana.org/assignments/http-status-codes
// This is now commonly used (in Rails, at least) to indicate
// a response to a request that is syntactically correct,
// but semantically invalid (for example, when trying to
// create a resource with some required fields missing)
throw new Mijireh_Rest_InvalidRecord($this->processError($body));
break;
default:
if ($meta['http_code'] >= 400 && $meta['http_code'] <= 499)
throw new Mijireh_Rest_ClientError($this->processError($body));
elseif ($meta['http_code'] >= 500 && $meta['http_code'] <= 599)
throw new Mijireh_Rest_ServerError($this->processError($body));
elseif (!$meta['http_code'] || $meta['http_code'] >= 600) {
throw new Mijireh_Rest_UnknownResponse($this->processError($body));
}
}
}
}
class Mijireh_Rest_Exception extends Exception { }
class Mijireh_Rest_UnknownResponse extends Mijireh_Rest_Exception { }
/* 401-499 */ class Mijireh_Rest_ClientError extends Mijireh_Rest_Exception {}
/* 400 */ class Mijireh_Rest_BadRequest extends Mijireh_Rest_ClientError {}
/* 401 */ class Mijireh_Rest_Unauthorized extends Mijireh_Rest_ClientError {}
/* 403 */ class Mijireh_Rest_Forbidden extends Mijireh_Rest_ClientError {}
/* 404 */ class Mijireh_Rest_NotFound extends Mijireh_Rest_ClientError {}
/* 405 */ class Mijireh_Rest_MethodNotAllowed extends Mijireh_Rest_ClientError {}
/* 409 */ class Mijireh_Rest_Conflict extends Mijireh_Rest_ClientError {}
/* 410 */ class Mijireh_Rest_Gone extends Mijireh_Rest_ClientError {}
/* 422 */ class Mijireh_Rest_InvalidRecord extends Mijireh_Rest_ClientError {}
/* 500-599 */ class Mijireh_Rest_ServerError extends Mijireh_Rest_Exception {}

View File

@ -0,0 +1,22 @@
<?php
class Mijireh_RestJSON extends Mijireh_Rest {
public function post($url, $data, $headers=array()) {
return parent::post($url, json_encode($data), $headers);
}
public function put($url, $data, $headers=array()) {
return parent::put($url, json_encode($data), $headers);
}
protected function prepRequest($opts, $url) {
$opts[CURLOPT_HTTPHEADER][] = 'Accept: application/json';
$opts[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json';
return parent::prepRequest($opts, $url);
}
public function processBody($body) {
return json_decode($body, true);
}
}

View File

@ -0,0 +1,367 @@
<?php
/**
* Mijireh Checkout Gateway
*
* Provides WooCommerce with Mijireh Checkout integration.
*
* @since 1.5.7
* @class WC_Mijireh_Checkout
* @package WooCommerce
* @category Payment Gateways
* @author Mijireh (http://www.mijireh.com/)
*/
class WC_Mijireh_Checkout extends WC_Payment_Gateway {
var $access_key;
/**
* __construct function.
*
* @access public
*/
public function __construct() {
global $woocommerce;
$this->id = 'mijireh_checkout';
$this->method_title = __( 'Mijireh Checkout', 'woocommerce' );
$this->icon = apply_filters( 'woocommerce_mijireh_checkout_icon', $woocommerce->plugin_url() . '/classes/gateways/mijireh/images/credit_cards.png' );
$this->has_fields = false;
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Define user set variables
$this->access_key = $this->settings['access_key'];
$this->title = $this->settings['title'];
$this->description = $this->settings['description'];
if ( $this->enabled && is_admin() ) {
$this->install_slurp_page();
// Hooks
add_action( 'add_meta_boxes', array( &$this, 'add_page_slurp_meta' ) );
add_action( 'wp_ajax_page_slurp', array( &$this, 'page_slurp' ) );
add_action( 'woocommerce_update_options_payment_gateways', array( &$this, 'process_admin_options' ) );
}
// Payment listener/API hook
add_action( 'woocommerce_api_wc_mijireh_checkout', array( &$this, 'mijireh_notification' ) );
}
/**
* init_mijireh function.
*
* @access public
*/
public function init_mijireh() {
if ( ! class_exists( 'Mijireh' ) ) {
require_once 'Mijireh.php';
Mijireh::$access_key = $this->access_key;
}
}
/**
* install_slurp_page function.
*
* @access public
*/
public function install_slurp_page() {
$slurp_page_installed = get_option( 'slurp_page_installed', false );
if ( $slurp_page_installed != 1 ) {
if( ! get_page_by_path( 'mijireh-secure-checkout' ) ) {
$page = array(
'post_title' => 'Mijireh Secure Checkout',
'post_name' => 'mijireh-secure-checkout',
'post_parent' => 0,
'post_status' => 'private',
'post_type' => 'page',
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_content' => "<h1>Checkout</h1>\n\n{{mj-checkout-form}}",
);
wp_insert_post( $page );
}
update_option( 'slurp_page_installed', 1 );
}
}
/**
* page_slurp function.
*
* @access public
* @return void
*/
public function page_slurp() {
$this->init_mijireh();
$page = get_page( absint( $_POST['page_id'] ) );
$url = get_permalink( $page->ID );
wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'publish' ) );
$job_id = Mijireh::slurp( $url );
wp_update_post( array( 'ID' => $page->ID, 'post_status' => 'private' ) );
echo $job_id;
die;
}
/**
* mijireh_notification function.
*
* @access public
* @return void
*/
public function mijireh_notification() {
global $woocommerce;
$this->init_mijireh();
try {
$mj_order = new Mijireh_Order( esc_attr( $_GET['order_number'] ) );
$wc_order_id = $mj_order->get_meta_value( 'wc_order_id' );
$wc_order = new WC_Order( absint( $wc_order_id ) );
// Mark order complete
$wc_order->payment_complete();
// Empty cart and clear session
$woocommerce->cart->empty_cart();
wp_redirect( $this->get_return_url( $wc_order ) );
exit;
} catch (Mijireh_Exception $e) {
$woocommerce->add_error( __( 'Mijireh error:', 'woocommerce' ) . $e->getMessage() );
}
}
/**
* init_form_fields function.
*
* @access public
* @return void
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable Mijireh Checkout', 'woocommerce' ),
'default' => 'no'
),
'access_key' => array(
'title' => __('Access Key', 'woocommerce'),
'type' => 'text',
'description' => __('The Mijireh access key for your store.', 'woocommerce'),
'default' => ''
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Credit Card', 'woocommerce' )
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'textarea',
'default' => __( 'Pay securely with you credit card.', 'woocommerce' ),
'description' => 'This controls the description which the user sees during checkout.'
),
);
}
public function admin_options() {
?>
<h3><?php _e('Mijireh Checkout', 'woocommerce');?></h3>
<?php if ( empty( $this->access_key ) ) : ?>
<div id="wc_get_started" class="mijireh">
<span class="main"><?php _e('Get started with Mijireh Checkout', 'woocommerce'); ?></span>
<span><a href="http://www.mijireh.com/integrations/woocommerce/">Mijireh Checkout</a> <?php _e('provides a fully PCI Compliant, secure way to collect and transmit credit card data to your payment gateway while keeping you in control of the design of your site. Mijireh supports a wide variety of payment gateways: Stripe, Authorize.net, PayPal, eWay, SagePay, Braintree, PayLeap, and more.', 'woocommerce'); ?></span>
<p><a href="http://secure.mijireh.com/signup" target="_blank" class="button button-primary"><?php _e('Join for free', 'woocommerce'); ?></a> <a href="http://www.mijireh.com/integrations/woocommerce/" target="_blank" class="button"><?php _e('Learn more about WooCommerce and Mijireh', 'woocommerce'); ?></a></p>
</div>
<?php else : ?>
<p><a href="http://www.mijireh.com/integrations/woocommerce/">Mijireh Checkout</a> <?php _e('provides a fully PCI Compliant, secure way to collect and transmit credit card data to your payment gateway while keeping you in control of the design of your site.', 'woocommerce'); ?></p>
<?php endif; ?>
<table class="form-table">
<?php $this->generate_settings_html(); ?>
</table><!--/.form-table-->
<?php
}
/**
* payment_fields function.
*
* There are no payment fields for Mijireh Checkout, but show the description if available.
*
* @access public
* @return void
*/
public function payment_fields() {
if ( $this->description )
echo wpautop(wptexturize($this->description));
}
/**
* process_payment function.
*
* @access public
* @param mixed $order_id
*/
public function process_payment( $order_id ) {
global $woocommerce;
$this->init_mijireh();
$mj_order = new Mijireh_Order();
$wc_order = new WC_Order( $order_id );
// add items to order
$items = $wc_order->get_items();
foreach($items as $item) {
$product = $wc_order->get_product_from_item( $item );
$mj_order->add_item( $item['name'], $wc_order->get_item_subtotal($item), $item['qty'], $product->get_sku() );
}
// add billing address to order
$billing = new Mijireh_Address();
$billing->first_name = $wc_order->billing_first_name;
$billing->last_name = $wc_order->billing_last_name;
$billing->street = $wc_order->billing_address_1;
$billing->apt_suite = $wc_order->billing_address_2;
$billing->city = $wc_order->billing_city;
$billing->state_province = $wc_order->billing_state;
$billing->zip_code = $wc_order->billing_postcode;
$billing->country = $wc_order->billing_country;
$billing->company = $wc_order->billing_company;
$billing->phone = $wc_order->billing_phone;
if ( $billing->validate() )
$mj_order->set_billing_address( $billing );
// add shipping address to order
$shipping = new Mijireh_Address();
$shipping->first_name = $wc_order->shipping_first_name;
$shipping->last_name = $wc_order->shipping_last_name;
$shipping->street = $wc_order->shipping_address_1;
$shipping->apt_suite = $wc_order->shipping_address_2;
$shipping->city = $wc_order->shipping_city;
$shipping->state_province = $wc_order->shipping_state;
$shipping->zip_code = $wc_order->shipping_postcode;
$shipping->country = $wc_order->shipping_country;
$shipping->company = $wc_order->shipping_company;
if ( $shipping->validate() )
$mj_order->set_shipping_address( $shipping );
// set order name
$mj_order->first_name = $wc_order->billing_first_name;
$mj_order->last_name = $wc_order->billing_last_name;
$mj_order->email = $wc_order->billing_email;
// set order totals
$mj_order->total = $wc_order->get_order_total();
$mj_order->tax = $wc_order->get_total_tax();
$mj_order->discount = $wc_order->get_total_discount();
$mj_order->shipping = $wc_order->get_shipping();
// add meta data to identify woocommerce order
$mj_order->add_meta_data( 'wc_order_id', $order_id );
// Set URL for mijireh payment notificatoin - use WC API
$mj_order->return_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Mijireh_Checkout', home_url( '/' ) ) );
// Identify woocommerce
$mj_order->partner_id = 'woo';
try {
$mj_order->create();
$result = array(
'result' => 'success',
'redirect' => $mj_order->checkout_url
);
return $result;
} catch (Mijireh_Exception $e) {
$woocommerce->add_error( __('Mijireh error:', 'woocommerce' ) . $e->getMessage() );
}
}
/**
* add_page_slurp_meta function.
*
* @access public
* @return void
*/
public function add_page_slurp_meta() {
global $woocommerce;
if ( $this->is_slurp_page() ) {
wp_enqueue_style( 'mijireh_css', $woocommerce->plugin_url() . '/classes/gateways/mijireh/mijireh.css' );
wp_enqueue_script( 'pusher', 'https://d3dy5gmtp8yhk7.cloudfront.net/1.11/pusher.min.js', null, false, true );
wp_enqueue_script( 'page_slurp', $woocommerce->plugin_url() . '/classes/gateways/mijireh/page_slurp.js', array('jquery'), false, true );
add_meta_box(
'slurp_meta_box', // $id
'Mijireh Page Slurp', // $title
array( &$this, 'draw_page_slurp_meta_box' ), // $callback
'page', // $page
'normal', // $context
'high' // $priority
);
}
}
/**
* is_slurp_page function.
*
* @access public
* @return void
*/
public function is_slurp_page() {
global $post;
$is_slurp = false;
if ( isset( $post ) && is_object( $post ) ) {
$content = $post->post_content;
if ( strpos( $content, '{{mj-checkout-form}}') !== false ) {
$is_slurp = true;
}
}
return $is_slurp;
}
/**
* draw_page_slurp_meta_box function.
*
* @access public
* @param mixed $post
* @return void
*/
public function draw_page_slurp_meta_box( $post ) {
global $woocommerce;
$this->init_mijireh();
echo "<div id='mijireh_notice' class='mijireh-info alert-message info' data-alert='alert'>";
echo "<h2>Slurp your custom checkout page!</h2>";
echo "<p>Get the page designed just how you want and when you're ready, click the button below and slurp it right up.</p>";
echo "<div id='slurp_progress' class='meter progress progress-info progress-striped active' style='display: none;'><div id='slurp_progress_bar' class='bar' style='width: 20%;'>Slurping...</div></div>";
echo "<p><a href='#' id='page_slurp' rel=". $post->ID ." class='button-primary'>Slurp This Page!</a> ";
echo '<a class="nobold" href="' . Mijireh::preview_checkout_link() . '" id="view_slurp" target="_new">Preview Checkout Page</a></p>';
echo "</div>";
}
}
/**
* Add the gateway to WooCommerce
**/
function add_mijireh_gateway( $methods ) {
$methods[] = 'WC_Mijireh_Checkout'; return $methods;
}
add_filter( 'woocommerce_payment_gateways', 'add_mijireh_gateway' );

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,155 @@
#mijireh_notice {
background: #5bc0de url(../../../assets/images/mijireh-logo.png) no-repeat 15px 18px;
border: 1px solid #339bb9;
padding: 15px 15px 15px 152px !important;
box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 );
-moz-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 );
-webkit-box-shadow: inset 1px 1px 0 rgba( 255, 255, 255, 0.5 ), inset -1px -1px 0 rgba( 255, 255, 255, 0.5 );
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
color: #fff;
text-shadow: 0 1px 0 #4a94ac;
}
#mijireh_notice.alert-danger, #mijireh_notice.alert-error {
background-color: #e0534e;
border: 1px solid #e0534e;
text-shadow: 0 1px 0 #e0534e;
}
#mijireh_notice.success {
background-color: #62c462;
border: 1px solid #62c462;
text-shadow: 0 1px 0 #4fbd4f;
}
#slurp_meta_box .inside {
padding:0 !important;
margin:0 !important;
}
#slurp_meta_box .alert-message {
margin:0 !important;
}
#slurp_meta_box h2 {
color:#fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
margin: 0;
}
#slurp_meta_box a {
color: #fff;
}
#slurp_meta_box a.button-primary {
margin-right: 10px;
}
#slurp_meta_box p {
line-height: 22px;
margin-bottom: 1em;
margin-top: 0;
}
/* Progress Bar Styles */
.progress {
overflow: hidden;
line-height:18px!important;
height: 18px!important;
margin-bottom: 18px!important;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #f5f5f5), color-stop(100%, #f9f9f9));
background: -webkit-linear-gradient(#f5f5f5, #f9f9f9);
background: -moz-linear-gradient(#f5f5f5, #f9f9f9);
background: -o-linear-gradient(#f5f5f5, #f9f9f9);
background: -ms-linear-gradient(#f5f5f5, #f9f9f9);
background: linear-gradient(#f5f5f5, #f9f9f9);
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
-o-border-radius: 4px;
border-radius: 4px;
}
.progress .bar {
width: 0%;
height: 18px!important;
line-height: 18px!important;
color: white;
font-size: 12px;
text-align: center;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #149bdf), color-stop(100%, #0480be));
background: -webkit-linear-gradient(#149bdf, #0480be);
background: -moz-linear-gradient(#149bdf, #0480be);
background: -o-linear-gradient(#149bdf, #0480be);
background: -ms-linear-gradient(#149bdf, #0480be);
background: linear-gradient(#149bdf, #0480be);
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.4);
-moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.4);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.4);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: width 0.6s ease;
-moz-transition: width 0.6s ease;
transition: width 0.6s ease;
}
.progress-striped .bar {
background-color: #62c462;
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-webkit-background-size: 40px 40px;
-moz-background-size: 40px 40px;
-o-background-size: 40px 40px;
background-size: 40px 40px;
}
.progress.active .bar {
-webkit-animation: progress-bar-stripes 2s linear infinite;
-moz-animation: progress-bar-stripes 2s linear infinite;
animation: progress-bar-stripes 2s linear infinite;
}
.progress-danger .bar {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ee5f5b), color-stop(100%, #c43c35));
background: -webkit-linear-gradient(#ee5f5b, #c43c35);
background: -moz-linear-gradient(#ee5f5b, #c43c35);
background: -o-linear-gradient(#ee5f5b, #c43c35);
background: -ms-linear-gradient(#ee5f5b, #c43c35);
background: linear-gradient(#ee5f5b, #c43c35);
}
.progress-danger.progress-striped .bar {
background-color: #ee5f5b;
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
}
.progress-success .bar {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #62c462), color-stop(100%, #57a957));
background: -webkit-linear-gradient(#62c462, #57a957);
background: -moz-linear-gradient(#62c462, #57a957);
background: -o-linear-gradient(#62c462, #57a957);
background: -ms-linear-gradient(#62c462, #57a957);
background: linear-gradient(#62c462, #57a957);
}
.progress-success.progress-striped .bar {
background-color: #62c462;
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
}
.progress.info .bar {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #5bc0de), color-stop(100%, #339bb9));
background: -webkit-linear-gradient(#5bc0de, #339bb9);
background: -moz-linear-gradient(#5bc0de, #339bb9);
background: -o-linear-gradient(#5bc0de, #339bb9);
background: -ms-linear-gradient(#5bc0de, #339bb9);
background: linear-gradient(#5bc0de, #339bb9);
}
.progress-info.progress-striped .bar {
background-color: #5bc0de;
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
}

View File

@ -0,0 +1,51 @@
(function($) {
$('#page_slurp').click(function() {
var page_id = $(this).attr('rel');
var data = {
action: 'page_slurp',
page_id: page_id
};
$('#page_slurp').attr('disabled', 'disabled');
$('#slurp_progress').show();
$('#slurp_progress_bar').html('Starting up');
$.post(ajaxurl, data, function(job_id) {
// The job id is the id for the page slurp job or 0 if the slurp failed
if(job_id.substring(0, 4) === 'http') {
var msg = 'Your PHP configuration does not allow for Page Slurp from within WordPress. Please log into your Mijireh account and Slurp the page by pasting in the URL to this page as shown below.\
\n\n' + job_id + '\n\nPlease set this page to be publicly accessible during the Slurp then set it back to private after the Slurp is complete.';
alert(msg);
}
else {
pusher = new Pusher('7dcd33b15307eb9be5fb');
channel_name = 'slurp-' + job_id;
channel = pusher.subscribe(channel_name);
channel.bind('status_changed', function (data) {
// console.log(data);
if(data.level == 'info') {
$('#slurp_progress_bar').html(data.message);
$('#slurp_progress_bar').width(data.progress + '%');
}
if(data.progress == 100) {
pusher.unsubscribe(channel_name);
$('#slurp_progress').hide();
$('#page_slurp').removeAttr('disabled');
}
});
}
})
.error(function(response) {
$('#slurp_progress').hide();
$('#page_slurp').removeAttr('disabled');
alert('Please make sure your Mijireh access key is correct');
});
return false;
});
})(jQuery.noConflict());

View File

@ -32,6 +32,7 @@ Seriously, WooCommerce has got more features than you can shake a stick at. But
WooCommerce has enough power to be used straight out of the box and comes with the following payment gateways, shipping methods and third party integrations:
* PayPal Standard
* Mijireh Checkout
* BACS
* Cheque
* Cash on Delivery
@ -149,6 +150,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== ==
* Feature - Mijireh Checkout Integration
* Feature - Menu count for orders requiring admin action
* Feature - 'supports' function for gateways.
* Tweak - EU states for tax

View File

@ -36,6 +36,10 @@ wp_delete_post( get_option('woocommerce_change_password_page_id'), true );
wp_delete_post( get_option('woocommerce_pay_page_id'), true );
wp_delete_post( get_option('woocommerce_thanks_page_id'), true );
// mijireh checkout page
if ( $mijireh_page = get_page_by_path( 'mijireh-secure-checkout' ) )
wp_delete_post( $mijireh_page->ID, true );
// Tables
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_attribute_taxonomies" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_downloadable_product_permissions" );

View File

@ -117,10 +117,11 @@ class Woocommerce {
// Include Core Payment Gateways
include( 'classes/gateways/class-wc-payment-gateways.php' );
include( 'classes/gateways/class-wc-payment-gateway.php' );
include( 'classes/gateways/class-wc-bacs.php' );
include( 'classes/gateways/class-wc-cheque.php' );
include( 'classes/gateways/class-wc-paypal.php' );
include( 'classes/gateways/class-wc-cod.php' );
include( 'classes/gateways/bacs/class-wc-bacs.php' );
include( 'classes/gateways/cheque/class-wc-cheque.php' );
include( 'classes/gateways/paypal/class-wc-paypal.php' );
include( 'classes/gateways/cod/class-wc-cod.php' );
include( 'classes/gateways/mijireh/class-wc-mijireh-checkout.php' );
// Include Core Shipping Methods
include( 'classes/shipping/class-wc-shipping.php' );