id = 'skrill';
$this->title = 'Skrill';
$this->icon = jigoshop::assets_url() . '/assets/images/icons/skrill.png';
$this->has_fields = false;
$this->enabled = get_option('jigoshop_skrill_enabled');
$this->title = get_option('jigoshop_skrill_title');
$this->email = get_option('jigoshop_skrill_email');
add_action( 'init', array(&$this, 'check_status_response') );
if(isset($_GET['skrillPayment']) && $_GET['skrillPayment'] == true):
add_action( 'init', array(&$this, 'generate_skrill_form') );
endif;
add_action('valid-skrill-status-report', array(&$this, 'successful_request') );
add_action('jigoshop_update_options', array(&$this, 'process_admin_options'));
add_option('jigoshop_skrill_enabled', 'yes');
add_option('jigoshop_skrill_email', '');
add_option('jigoshop_skrill_title', 'skrill');
add_action('receipt_skrill', array(&$this, 'receipt_skrill'));
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options() {
?>
'.__('Thank you for your order, please complete the secure (SSL) form below to pay with Skrill.', 'jigoshop').'
'; echo ''; } /** * Check Skrill status report validity **/ function check_status_report_is_valid() { // Get Skrill post data array $params = $_POST; if(!isset($params['transaction_id'])) return false; $order_id = $params['transaction_id']; $_skrillmd = strtoupper(get_post_meta($order_id, '_skrillmd', true)); // Check MD5 signiture if($params['md5sig'] == $_skrillmd) return true; return false; } /** * Check for Skrill Status Response **/ function check_status_response() { if (isset($_GET['skrillListener']) && $_GET['skrillListener'] == 'skrill_status'): $_POST = stripslashes_deep($_POST); if (self::check_status_report_is_valid()) : do_action("valid-skrill-status-report", $_POST); endif; endif; } /** * Successful Payment! **/ function successful_request( $posted ) { // Custom holds post ID if ( !empty($posted['mb_transaction_id']) ) { $order = new jigoshop_order( (int) $posted['transaction_id'] ); if ($order->status !== 'completed') : // We are here so lets check status and do actions switch ($posted['status']) : case '2' : // Processed $order->add_order_note( __('Skrill payment completed', 'jigoshop') ); $order->payment_complete(); break; case '0' : // Pending case '-2' : // Failed $order->update_status('on-hold', sprintf(__('Skrill payment failed (%s)', 'jigoshop'), strtolower($posted['status']) ) ); break; case '-1' : // Cancelled $order->update_status('cancelled', __('Skrill payment cancelled', 'jigoshop')); break; default: $order->update_status('cancelled', __('Skrill exception', 'jigoshop')); break; endswitch; endif; exit; } } } /** Add the gateway to JigoShop **/ function add_skrill_gateway( $methods ) { $methods[] = 'skrill'; return $methods; } add_filter('jigoshop_payment_gateways', 'add_skrill_gateway' );