WC_QuickPay_Settings

WC_QuickPay_Settings class.

Defined (1)

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

/classes/woocommerce-quickpay-settings.php  
  1. class WC_QuickPay_Settings { 
  2.  
  3. /** 
  4. * get_fields function. 
  5. * Returns an array of available admin settings fields 
  6. * @access public static 
  7. * @return array 
  8. */ 
  9. public static function get_fields() 
  10. $fields =  
  11. array( 
  12. 'enabled' => array( 
  13. 'title' => __( 'Enable', 'woo-quickpay' ),  
  14. 'type' => 'checkbox',  
  15. 'label' => __( 'Enable QuickPay Payment', 'woo-quickpay' ),  
  16. 'default' => 'yes' 
  17. ),  
  18.  
  19. '_Account_setup' => array( 
  20. 'type' => 'title',  
  21. 'title' => __( 'API - Integration', 'woo-quickpay' ),  
  22. ),  
  23.  
  24. 'quickpay_privatekey' => array( 
  25. 'title' => __('Private key', 'woo-quickpay') . self::get_required_symbol(),  
  26. 'type' => 'text',  
  27. 'description' => __( 'Your agreement private key. Found in the "Integration" tab inside the QuickPay manager.', 'woo-quickpay' ),  
  28. 'desc_tip' => true,  
  29. ),  
  30. 'quickpay_apikey' => array( 
  31. 'title' => __('Api User key', 'woo-quickpay') . self::get_required_symbol(),  
  32. 'type' => 'text',  
  33. 'description' => __( 'Your API User\'s key. Create a separate API user in the "Users" tab inside the QuickPay manager.' , 'woo-quickpay' ),  
  34. 'desc_tip' => true,  
  35. ),  
  36. '_Autocapture' => array( 
  37. 'type' => 'title',  
  38. 'title' => __('Autocapture settings', 'woo-quickpay' ) 
  39. ),  
  40. 'quickpay_autocapture' => array( 
  41. 'title' => __( 'Physical products (default)', 'woo-quickpay' ),  
  42. 'type' => 'checkbox',  
  43. 'label' => __( 'Enable', 'woo-quickpay' ),  
  44. 'description' => __( 'Automatically capture payments on physical products.', 'woo-quickpay' ),  
  45. 'default' => 'no',  
  46. 'desc_tip' => false,  
  47. ),  
  48. 'quickpay_autocapture_virtual' => array( 
  49. 'title' => __( 'Virtual products', 'woo-quickpay' ),  
  50. 'type' => 'checkbox',  
  51. 'label' => __( 'Enable', 'woo-quickpay' ),  
  52. 'description' => __( 'Automatically capture payments on virtual products. If the order contains both physical and virtual products, this setting will be overwritten by the default setting above.', 'woo-quickpay' ),  
  53. 'default' => 'no',  
  54. 'desc_tip' => false,  
  55. ),  
  56. '_Currency_settings' => array( 
  57. 'type' => 'title',  
  58. 'title' => __('Currency settings', 'woo-quickpay' ) 
  59. ),  
  60. 'quickpay_currency' => array( 
  61. 'title' => __('Fixed Currency', 'woo-quickpay'),  
  62. 'description' => __('Choose a fixed currency. Please make sure to use the same currency as in your WooCommerce currency settings.', 'woo-quickpay' ),  
  63. 'desc_tip' => true,  
  64. 'type' => 'select',  
  65. 'options' => array( 
  66. 'DKK' => 'DKK',  
  67. 'EUR' => 'EUR',  
  68. 'GBP' => 'GBP',  
  69. 'NOK' => 'NOK',  
  70. 'SEK' => 'SEK',  
  71. 'USD' => 'USD' 
  72. ),  
  73. 'quickpay_currency_auto' => array( 
  74. 'title' => __( 'Auto Currency', 'woo-quickpay' ),  
  75. 'type' => 'checkbox',  
  76. 'label' => __( 'Enable', 'woo-quickpay' ),  
  77. 'description' => __( 'Automatically checks out with the order currency. This setting overwrites the "Fixed Currency" setting.', 'woo-quickpay' ),  
  78. 'default' => 'no',  
  79. 'desc_tip' => true,  
  80. ),  
  81. '_Extra_gateway_settings' => array( 
  82. 'type' => 'title',  
  83. 'title' => __('Extra gateway settings', 'woo-quickpay' ) 
  84. ),  
  85. 'quickpay_language' => array( 
  86. 'title' => __('Language', 'woo-quickpay'),  
  87. 'description' => __('Payment Window Language', 'woo-quickpay'),  
  88. 'desc_tip' => true,  
  89. 'type' => 'select',  
  90. 'options' => array( 
  91. 'da' => 'Danish',  
  92. 'de' =>'German',  
  93. 'en' =>'English',  
  94. 'fr' =>'French',  
  95. 'it' =>'Italian',  
  96. 'no' =>'Norwegian',  
  97. 'nl' =>'Dutch',  
  98. 'pl' =>'Polish',  
  99. 'se' =>'Swedish' 
  100. ),  
  101. 'quickpay_currency' => array( 
  102. 'title' => __('Currency', 'woo-quickpay'),  
  103. 'description' => __('Choose your currency. Please make sure to use the same currency as in your WooCommerce currency settings.', 'woo-quickpay' ),  
  104. 'desc_tip' => true,  
  105. 'type' => 'select',  
  106. 'options' => array( 
  107. 'DKK' => 'DKK',  
  108. 'EUR' => 'EUR',  
  109. 'GBP' => 'GBP',  
  110. 'NOK' => 'NOK',  
  111. 'SEK' => 'SEK',  
  112. 'USD' => 'USD' 
  113. ),  
  114. 'quickpay_cardtypelock' => array( 
  115. 'title' => __( 'Payment methods', 'woo-quickpay' ),  
  116. 'type' => 'text',  
  117. 'description' => __( 'Default: creditcard. Type in the cards you wish to accept (comma separated). See the valid payment types here: <b>http://tech.quickpay.net/appendixes/payment-methods/</b>', 'woo-quickpay' ),  
  118. 'default' => 'creditcard',  
  119. ),  
  120. 'quickpay_branding_id' => array( 
  121. 'title' => __( 'Branding ID', 'woo-quickpay' ),  
  122. 'type' => 'text',  
  123. 'description' => __( 'Leave empty if you have no custom branding options', 'woo-quickpay' ),  
  124. 'default' => '',  
  125. 'desc_tip' => true,  
  126. ),  
  127.  
  128. 'quickpay_autofee' => array( 
  129. 'title' => __( 'Enable autofee', 'woo-quickpay' ),  
  130. 'type' => 'checkbox',  
  131. 'label' => __( 'Enable', 'woo-quickpay' ),  
  132. 'description' => __( 'If enabled, the fee charged by the acquirer will be calculated and added to the transaction amount.', 'woo-quickpay' ),  
  133. 'default' => 'no',  
  134. 'desc_tip' => true,  
  135. ),  
  136. 'quickpay_captureoncomplete' => array( 
  137. 'title' => __( 'Capture on complete', 'woo-quickpay' ),  
  138. 'type' => 'checkbox',  
  139. 'label' => __( 'Enable', 'woo-quickpay' ),  
  140. 'description' => __( 'When enabled quickpay payments will automatically be captured when order state is set to "Complete".', 'woo-quickpay'),  
  141. 'default' => 'no',  
  142. 'desc_tip' => true,  
  143. ),  
  144. 'quickpay_text_on_statement' => array( 
  145. 'title' => __( 'Text on statement', 'woo-quickpay' ),  
  146. 'type' => 'text',  
  147. 'description' => __( 'Text that will be placed on cardholder*s bank statement (currently only supported by Clearhaus).', 'woo-quickpay' ),  
  148. 'default' => '',  
  149. 'desc_tip' => true,  
  150. 'custom_attributes' => array( 
  151. 'maxlength' => 22,  
  152. ),  
  153. ),  
  154.  
  155.  
  156. '_Shop_setup' => array( 
  157. 'type' => 'title',  
  158. 'title' => __( 'Shop setup', 'woo-quickpay' ),  
  159. ),  
  160. 'title' => array( 
  161. 'title' => __( 'Title', 'woo-quickpay' ),  
  162. 'type' => 'text',  
  163. 'description' => __( 'This controls the title which the user sees during checkout.', 'woo-quickpay' ),  
  164. 'default' => __( 'QuickPay', 'woo-quickpay' ),  
  165. 'desc_tip' => true,  
  166. ),  
  167. 'description' => array( 
  168. 'title' => __( 'Customer Message', 'woo-quickpay' ),  
  169. 'type' => 'textarea',  
  170. 'description' => __( 'This controls the description which the user sees during checkout.', 'woo-quickpay' ),  
  171. 'default' => __( 'Pay via QuickPay. Allows you to pay with your credit card via QuickPay.', 'woo-quickpay' ),  
  172. 'desc_tip' => true,  
  173. ),  
  174. 'checkout_button_text' => array( 
  175. 'title' => __( 'Order button text', 'woo-quickpay' ),  
  176. 'type' => 'text',  
  177. 'description' => __( 'Text shown on the submit button when choosing payment method.', 'woo-quickpay' ),  
  178. 'default' => __( 'Go to payment', 'woo-quickpay' ),  
  179. 'desc_tip' => true,  
  180. ),  
  181. 'instructions' => array( 
  182. 'title' => __( 'Email instructions', 'woo-quickpay' ),  
  183. 'type' => 'textarea',  
  184. 'description' => __( 'Instructions that will be added to emails.', 'woo-quickpay' ),  
  185. 'default' => '',  
  186. 'desc_tip' => true,  
  187. ),  
  188. 'quickpay_icons' => array( 
  189. 'title' => __( 'Credit card icons', 'woo-quickpay' ),  
  190. 'type' => 'multiselect',  
  191. 'description' => __( 'Choose the card icons you wish to show next to the QuickPay payment option in your shop.', 'woo-quickpay' ),  
  192. 'desc_tip' => true,  
  193. 'class' => 'wc-enhanced-select',  
  194. 'css' => 'width: 450px;',  
  195. 'custom_attributes' => array( 
  196. 'data-placeholder' => __( 'Select icons', 'woo-quickpay' ) 
  197. ),  
  198. 'default' => '',  
  199. 'options' => array( 
  200. 'dankort' => 'Dankort',  
  201. 'edankort' => 'eDankort',  
  202. 'visa' => 'Visa',  
  203. 'visaelectron' => 'Visa Electron',  
  204. 'mastercard' => 'Mastercard',  
  205. 'maestro' => 'Maestro',  
  206. 'jcb' => 'JCB',  
  207. 'americanexpress' => 'American Express',  
  208. 'diners' => 'Diner\'s Club',  
  209. 'discovercard' => 'Discover Card',  
  210. 'viabill' => 'ViaBill',  
  211. 'paypal' => 'Paypal',  
  212. 'danskebank' => 'Danske Bank',  
  213. 'nordea' => 'Nordea',  
  214. 'mobilepay' => 'MobilePay',  
  215. 'forbrugsforeningen' => 'Forbrugsforeningen' 
  216. ),  
  217. ),  
  218. 'quickpay_icons_maxheight' => array( 
  219. 'title' => __( 'Credit card icons maximum height', 'woo-quickpay' ),  
  220. 'type' => 'number',  
  221. 'description' => __( 'Set the maximum pixel height of the credit card icons shown on the frontend.', 'woo-quickpay' ),  
  222. 'default' => 20,  
  223. 'desc_tip' => true,  
  224. ),  
  225. 'Google Analytics' => array( 
  226. 'type' => 'title',  
  227. 'title' => __( 'Google Analytics', 'woo-quickpay' ),  
  228. ),  
  229. 'quickpay_google_analytics_tracking_id' => array( 
  230. 'title' => __( 'Tracking ID', 'woo-quickpay' ),  
  231. 'type' => 'text',  
  232. 'description' => __( 'Your Google Analytics tracking ID. Digits only.', 'woo-quickpay' ),  
  233. 'default' => '',  
  234. 'desc_tip' => true,  
  235. ),  
  236. 'ShopAdminSetup' => array( 
  237. 'type' => 'title',  
  238. 'title' => __( 'Shop Admin Setup', 'woo-quickpay' ),  
  239. ),  
  240.  
  241. 'quickpay_orders_transaction_info' => array( 
  242. 'title' => __( 'Fetch Transaction Info', 'woo-quickpay' ),  
  243. 'type' => 'checkbox',  
  244. 'label' => __( 'Enable', 'woo-quickpay' ),  
  245. 'description' => __( 'Show transaction information in the order overview.', 'woo-quickpay' ),  
  246. 'default' => 'yes',  
  247. 'desc_tip' => false,  
  248. ),  
  249.  
  250. 'CustomVariables' => array( 
  251. 'type' => 'title',  
  252. 'title' => __( 'Custom Variables', 'woo-quickpay' ),  
  253. ),  
  254. 'quickpay_custom_variables' => array( 
  255. 'title' => __( 'Select Information', 'woo-quickpay' ),  
  256. 'type' => 'multiselect',  
  257. 'class' => 'wc-enhanced-select',  
  258. 'css' => 'width: 450px;',  
  259. 'default' => '',  
  260. 'description' => __( 'Selected options will store the specific data on your transaction inside your QuickPay Manager.', 'woo-quickpay' ),  
  261. 'options' => self::custom_variable_options(),  
  262. 'desc_tip' => true,  
  263. 'custom_attributes' => array( 
  264. 'data-placeholder' => __( 'Select order data', 'woo-quickpay' ) 
  265. ),  
  266. ); 
  267.  
  268. if( WC_QuickPay_Subscription::plugin_is_active() ) 
  269. $fields['woocommerce-subscriptions'] = array( 
  270. 'type' => 'title',  
  271. 'title' => 'Subscriptions' 
  272. ); 
  273.  
  274. $fields['subscription_autocomplete_renewal_orders'] = array( 
  275. 'title' => __( 'Complete renewal orders', 'woo-quickpay' ),  
  276. 'type' => 'checkbox',  
  277. 'label' => __( 'Enable', 'woo-quickpay' ),  
  278. 'description' => __( 'Automatically mark a renewal order as complete on successful recurring payments.', 'woo-quickpay' ),  
  279. 'default' => 'no',  
  280. 'desc_tip' => true,  
  281. ); 
  282.  
  283. return $fields; 
  284.  
  285.  
  286. /** 
  287. * custom_variable_options function. 
  288. * Provides a list of custom variable options used in the settings 
  289. * @access private 
  290. * @return array 
  291. */  
  292. private static function custom_variable_options() 
  293. $options = array( 
  294. 'billing_all_data' => __( 'Billing: Complete Customer Details', 'woo-quickpay' ),  
  295. 'browser_useragent' => __( 'Browser: User Agent', 'woo-quickpay' ),  
  296. 'customer_email' => __( 'Customer: Email Address', 'woo-quickpay' ),  
  297. 'customer_phone' => __( 'Customer: Phone Number', 'woo-quickpay' ),  
  298. 'shipping_all_data' => __( 'Shipping: Complete Customer Details', 'woo-quickpay' ),  
  299. 'shipping_method' => __( 'Shipping: Shipping Method', 'woo-quickpay' ),  
  300. ); 
  301.  
  302. asort($options); 
  303.  
  304. return $options; 
  305.  
  306. /** 
  307. * Clears the log file. 
  308. * @return void 
  309. */ 
  310. public static function clear_logs_section() { 
  311. printf( '<h3 class="wc-settings-sub-title">%s</h3>', __( 'Debug', 'woo-quickpay' ) ); 
  312. printf( '<a id="wcqp_wiki" class="button button-primary" href="%s" target="_blank">%s</a>', self::get_wiki_link(), __( 'Got problems? Check out the Wiki.', 'woo-quickpay' ) ); 
  313. printf( '<a id="wcqp_logs" class="button" href="%s">%s</a>', WC_QP()->log->get_admin_link(), __( 'View debug logs', 'woo-quickpay' ) ); 
  314. printf( '<button id="wcqp_logs_clear" class="button">%s</button>', __( 'Empty debug logs', 'woo-quickpay' ) ); 
  315. printf( '<br/>'); 
  316. printf( '<h3 class="wc-settings-sub-title">%s</h3>', __( 'Enable', 'woo-quickpay' ) ); 
  317.  
  318. /** 
  319. * Returns the link to the gateway settings page. 
  320. * @return mixed 
  321. */ 
  322. public static function get_settings_page_url() { 
  323. return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=wc_quickpay' ); 
  324.  
  325. /** 
  326. * Shows an admin notice if the setup is not complete. 
  327. * @return void 
  328. */ 
  329. public static function show_admin_setup_notices() { 
  330. $error_fields = array(); 
  331.  
  332. $mandatory_fields = array( 
  333. 'quickpay_privatekey' => __('Private key', 'woo-quickpay'),  
  334. 'quickpay_apikey' => __('Api User key', 'woo-quickpay') 
  335. ); 
  336.  
  337. foreach($mandatory_fields as $mandatory_field_setting => $mandatory_field_label) { 
  338. if (self::has_empty_mandatory_post_fields($mandatory_field_setting)) { 
  339. $error_fields[] = $mandatory_field_label; 
  340.  
  341. if (!empty($error_fields)) { 
  342. $message = sprintf('<h2>%s</h2>', __( "WooCommerce QuickPay", 'woo-quickpay' ) ); 
  343. $message .= sprintf('<p>%s</p>', sprintf(__('You have missing or incorrect settings. Go to the <a href="%s">settings page</a>.', 'woo-quickpay'), self::get_settings_page_url()) ); 
  344. $message .= '<ul>'; 
  345. foreach($error_fields as $error_field) { 
  346. $message .= "<li>" . sprintf(__('<strong>%s</strong> is mandatory.', 'woo-quickpay'), $error_field) . "</li>"; 
  347. $message .= '</ul>'; 
  348.  
  349. printf('<div class="%s">%s</div>', 'notice notice-error', $message); 
  350.  
  351.  
  352. /** 
  353. * @return string 
  354. */ 
  355. public static function get_wiki_link() { 
  356. return 'http://quickpay.perfect-solution.dk'; 
  357.  
  358. /** 
  359. * Logic wrapper to check if some of the mandatory fields are empty on post request. 
  360. * @return bool 
  361. */ 
  362. private static function has_empty_mandatory_post_fields($settings_field) { 
  363. $post_key = 'woocommerce_quickpay_' . $settings_field; 
  364. $setting_key = WC_QP()->s($settings_field); 
  365. return empty($_POST[$post_key]) && empty($setting_key); 
  366.  
  367.  
  368. /** 
  369. * @return string 
  370. */ 
  371. private static function get_required_symbol() { 
  372. return '<span style="color: red;">*</span>';