Sisow_Gateways

The Woocommerce Sisow Payment Methods Sisow Gateways class.

Defined (1)

The class is defined in the following location(s).

/includes/classes/Sisow/Gateways.php  
  1. class Sisow_Gateways 
  2. public static function _getGateways($arrDefault) 
  3.  
  4. $paymentOptions = array( 
  5. 'Sisow_Gateway_Ebill',  
  6. 'Sisow_Gateway_Eps',  
  7. 'Sisow_Gateway_Focum',  
  8. 'Sisow_Gateway_Giropay',  
  9. 'Sisow_Gateway_Homepay',  
  10. 'Sisow_Gateway_Ideal',  
  11. 'Sisow_Gateway_Idealqr',  
  12. 'Sisow_Gateway_Maestro',  
  13. 'Sisow_Gateway_Mastercard',  
  14. 'Sisow_Gateway_Mistercash',  
  15. 'Sisow_Gateway_Overboeking',  
  16. 'Sisow_Gateway_Paypalec',  
  17. 'Sisow_Gateway_Sofort',  
  18. 'Sisow_Gateway_Visa',  
  19. 'Sisow_Gateway_Vpay',  
  20. 'Sisow_Gateway_Vvv',  
  21. 'Sisow_Gateway_Webshopgiftcard',  
  22. 'Sisow_Gateway_Bunq',  
  23. ); 
  24.  
  25. $arrDefault = array_merge($arrDefault, $paymentOptions); 
  26.  
  27. return $arrDefault; 
  28.  
  29. /** 
  30. * This function registers the Sisow Payment Gateways 
  31. */ 
  32. public static function register() 
  33. add_filter('woocommerce_payment_gateways', array(__CLASS__, '_getGateways')); 
  34.  
  35. /** 
  36. * This function adds the Sisow Global Settings to the woocommerce payment method settings 
  37. */ 
  38. public static function addSettings() 
  39. add_filter('woocommerce_payment_gateways_settings', array(__CLASS__, '_addGlobalSettings')); 
  40.  
  41. /** 
  42. * Register the API's to catch the return and exchange 
  43. */ 
  44. public static function registerApi() 
  45. add_action('woocommerce_api_wc_sisow_gateway_return', array(__CLASS__, '_sisowReturn')); 
  46. add_action('woocommerce_api_wc_sisow_gateway_notify', array(__CLASS__, '_sisowNotify')); 
  47.  
  48. public static function _addGlobalSettings($settings) 
  49. $updatedSettings = array(); 
  50.  
  51. $addedSettings = array(); 
  52. $addedSettings[] = array( 
  53. 'title' => __('Sisow settings', 'woocommerce-sisow'),  
  54. 'type' => 'title',  
  55. 'desc' => '<p>' . __('The following options are required to use the Sisow Gateway and are used by all Sisow Payment Methods', 'woocommerce-sisow') . '</p>',  
  56. 'id' => 'sisow_general_settings',  
  57. ); 
  58. $addedSettings[] = array( 
  59. 'name' => __('Merchant ID', 'woocommerce-sisow'),  
  60. 'type' => 'text',  
  61. 'desc' => __('The Merchant ID from Sisow, you can find it in your Sisow account', 'woocommerce-sisow'),  
  62. 'id' => 'sisow_merchantid',  
  63. ); 
  64. $addedSettings[] = array( 
  65. 'name' => __('Merchant Key', 'woocommerce-sisow'),  
  66. 'type' => 'text',  
  67. 'desc' => __('The Merchant Key from Sisow, you can find it in your Sisow account', 'woocommerce-sisow'),  
  68. 'id' => 'sisow_merchantkey',  
  69. ); 
  70. $addedSettings[] = array( 
  71. 'name' => __('Shop ID', 'woocommerce-sisow'),  
  72. 'type' => 'text',  
  73. 'desc' => __('The Shop ID from Sisow, you can find it in your Sisow account', 'woocommerce-sisow'),  
  74. 'id' => 'sisow_shopid',  
  75. ); 
  76. $addedSettings[] = array( 
  77. 'name' => __('Set completed', 'woocommerce-sisow'),  
  78. 'type' => 'checkbox',  
  79. 'desc' => __('Mark the order direct as completed', 'woocommerce-sisow'),  
  80. 'id' => 'sisow_completed',  
  81. ); 
  82. $addedSettings[] = array( 
  83. 'name' => __('Add utm_nooverride=1', 'woocommerce-sisow'),  
  84. 'type' => 'checkbox',  
  85. 'desc' => __('Add utm_nooverride=1 recommended if you use Google Analytics', 'woocommerce-sisow'),  
  86. 'id' => 'sisow_utm_nooverride',  
  87. ); 
  88. $addedSettings[] = array( 
  89. 'type' => 'sectionend',  
  90. 'id' => 'sisow_general_settings',  
  91. ); 
  92. foreach ($settings as $setting) 
  93. if (isset($setting['id']) && $setting['id'] == 'payment_gateways_options' && $setting['type'] != 'sectionend') 
  94. $updatedSettings = array_merge($updatedSettings, $addedSettings); 
  95. $updatedSettings[] = $setting; 
  96.  
  97.  
  98. return $updatedSettings; 
  99.  
  100. public static function _sisowReturn() 
  101. global $woocommerce; 
  102.  
  103. $order = new WC_Order($_GET['ec']); 
  104.  
  105. if($_GET['status'] == 'Success') 
  106. $order = new WC_Order($_GET['ec']); 
  107. $return_url = $order->get_checkout_order_received_url(); 
  108. if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') { 
  109. $return_url = str_replace('http:', 'https:', $return_url); 
  110.  
  111. $utm_nooverride = array_key_exists('utm_nooverride', $_GET); 
  112.  
  113. wp_redirect(apply_filters('woocommerce_get_return_url', $return_url) . ($utm_nooverride ? '&utm_nooverride=1' : '')); 
  114. else 
  115. wp_redirect($woocommerce->cart->get_checkout_url() . ($utm_nooverride ? '&utm_nooverride=1' : '')); 
  116.  
  117. public static function _sisowNotify($return = false) 
  118. if(sha1($_GET['trxid'] . $_GET['ec'] . $_GET['status'] . get_option('sisow_merchantid') . get_option('sisow_merchantkey')) != $_GET['sha1']) 
  119. exit('Invalid Notify'); 
  120. $order = new WC_Order($_GET['ec']); 
  121. $trxid = get_post_meta($order->id, '_trxid', true); 
  122.  
  123. if(empty($trxid)) 
  124. $trxid = $_GET['trxid']; 
  125.  
  126. $sisow = new Sisow_Helper_Sisow(get_option('sisow_merchantid'), get_option('sisow_merchantkey'), get_option('sisow_shopid')); 
  127. if($sisow->StatusRequest($_GET['trxid']) < 0) 
  128. if(!$return) 
  129. exit('StatusRequest failed ' . $ex); 
  130. else 
  131. return; 
  132.  
  133. if($order->status != 'pending' && $order->status != 'on-hold' && $sisow->status != 'Success' && $sisow->status != 'Reservation' && $sisow->status != 'Reversed') 
  134. if(!$return) 
  135. exit('Not open anymore'); 
  136. else 
  137. return; 
  138. else if(($order->status == 'processing' || $order->status == 'completed') && $sisow->status != 'Reversed' && $sisow->status != 'Refund') 
  139. if(!$return) 
  140. exit ('Order already Success (new status forbidden)'); 
  141. else 
  142. return; 
  143.  
  144. switch($sisow->status) 
  145. case "Success": 
  146. $order->add_order_note(sprintf(__('Status recieved from Sisow: %s', 'woocommerce-sisow'), $sisow->status)); 
  147. $order->payment_complete($_GET['trxid']); 
  148. if(get_option('sisow_completed') == "yes") 
  149. $order->update_status('completed'); 
  150. break; 
  151. case "Reservation": 
  152. $order->add_order_note(sprintf(__('Status recieved from Sisow: %s', 'woocommerce-sisow'), $sisow->status)); 
  153. $order->payment_complete($_GET['trxid']); 
  154. break; 
  155. case "Pending": 
  156. $order->update_status('on-hold', sprintf(__('Status recieved from Sisow: %s', 'woocommerce-sisow'), $sisow->status)); 
  157. break; 
  158. default: 
  159. $order->cancel_order(sprintf(__('Status recieved from Sisow: %s', 'woocommerce-sisow'), $sisow->status)); 
  160. break; 
  161.  
  162. if(!$return) 
  163. exit; 
  164. else 
  165. return;