Changeset 2754548
- Timestamp:
- 07/11/2022 12:15:00 PM (4 years ago)
- Location:
- switips
- Files:
-
- 4 added
- 2 deleted
- 8 edited
-
tags/1.2/common/SWSettings.php (modified) (4 diffs)
-
tags/1.2/debug.txt (deleted)
-
tags/1.2/languages/switips-es_ES.mo (added)
-
tags/1.2/languages/switips-es_ES.po (added)
-
tags/1.2/sw_log.log (modified) (1 diff)
-
tags/1.2/switips-core.php (modified) (6 diffs)
-
tags/1.2/wc-switips.php (modified) (3 diffs)
-
trunk/common/SWSettings.php (modified) (4 diffs)
-
trunk/debug.txt (deleted)
-
trunk/languages/switips-es_ES.mo (added)
-
trunk/languages/switips-es_ES.po (added)
-
trunk/sw_log.log (modified) (1 diff)
-
trunk/switips-core.php (modified) (6 diffs)
-
trunk/wc-switips.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
switips/tags/1.2/common/SWSettings.php
r2551253 r2754548 1 1 <?php 2 3 if (!class_exists('Switips')) { 4 require_once( 'switips-core.php' ); 5 } 6 2 7 if ( !class_exists('switips_settings') ) { 3 8 class switips_settings { … … 47 52 48 53 public function settings_save() { 49 $opts = $this->merge_settings_post(); 54 $opts = $this->merge_settings_post(); 55 56 if($opts['url_api'] == ''){ 57 $SwitipsCls = new Switips('empty'); 58 $opts['url_api'] = $SwitipsCls->getDefaultDomain(); 59 } 50 60 51 61 // treat boolean values … … 302 312 $value = $this->get_option($name); 303 313 314 $obj = new Switips('empty'); 315 $api_url = $obj->getDefaultDomain(); 316 $available = $obj->getAvailableCurrencies($api_url); 317 304 318 ?> 305 319 <tr valign="top"> … … 310 324 <select name="<?php echo $name ?>"> 311 325 <?php foreach ( (array) $options as $optVal => $optLabel ): ?> 326 327 <?php if(in_array($optVal, $available)):?> 328 329 312 330 <option <?php if ( $value == $optVal ): ?>selected<?php endif; ?> 313 331 value="<?php echo $optVal ?>"><?php echo $optLabel; ?></option> 332 <?php endif; ?> 314 333 <?php endforeach; ?> 315 334 </select> -
switips/tags/1.2/sw_log.log
r2551253 r2754548 1 [Thu Apr 29 08:24:32 2021] {"merchant_id":"merchant_id","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":127,"transaction_amount":"333.00","currency":"RUB","transaction_amount_currency":"333.00","tt_date":1619684672,"stat":"new","secret_key":"secret_key","commission_amount":15,"switips_status":"error","sw_error":"Internal server error"}2 [Thu Apr 29 08:24:32 2021] {"merchant_id":"merchant_id","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":127,"transaction_amount":"333.00","currency":"RUB","transaction_amount_currency":"333.00","tt_date":1619684672,"stat":"new","secret_key":"secret_key","commission_amount":15,"switips_status":"error","sw_error":"Internal server error"}3 [Thu Apr 29 08:28:22 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":128,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1619684901,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":14,"switips_status":"ok","sw_error":null}4 [Mon Jun 07 10:21:09 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":130,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1623061268,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":24,"switips_status":"error","sw_error":"merchant not active"}5 [Mon Jun 07 10:21:10 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":130,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1623061270,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":24,"switips_status":"error","sw_error":"merchant not active"}6 [Mon Jun 07 10:26:00 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":131,"transaction_amount":"318.00","currency":"RUB","transaction_amount_currency":"318.00","tt_date":1623061559,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":12,"switips_status":"ok","sw_error":null}7 [Wed Jun 09 12:50:55 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":132,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243055,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}8 [Wed Jun 09 12:54:51 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":133,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243291,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}9 [Wed Jun 09 12:57:54 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":134,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243474,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}10 [Wed Jun 09 12:58:14 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":135,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243494,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}11 [Wed Jun 09 12:59:31 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":136,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243571,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}12 [Wed Jun 09 13:07:07 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":137,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623244027,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}13 [Wed Jun 09 13:08:23 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":137,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623244103,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}14 [Tue Jun 15 11:58:54 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":138,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758333,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}15 [Tue Jun 15 11:58:55 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":138,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758335,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}16 [Tue Jun 15 12:00:24 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":139,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758423,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}17 [Tue Jun 15 12:00:25 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":139,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758424,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"} -
switips/tags/1.2/switips-core.php
r2551253 r2754548 1 1 <?php 2 2 /** 3 * Switips API 4 * @link http://outcode.ru 3 * @package Switips 4 * @author Outcode https://outcode.ru/ 5 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only 5 6 */ 6 7 … … 8 9 9 10 public $api_url; 10 public $currencies = [ 11 'RUB', // Российский рубль 12 'UAH', // Украинская гривна 13 'USD', // Доллар США 14 'EUR', // Евро 15 'GBP', // Фунт стерлингов Великобритании 16 ]; 11 public $currencies = []; 17 12 public $states = [ 18 13 'new', // Создан … … 20 15 'canceled', // Отменен 21 16 'confirmed', // Подтвержден 22 ]; 17 ]; 18 19 public $url_without_domain = '/rest/partner/track'; 23 20 24 21 public function __construct($api_url, $currencies = null, $states = null){ 25 22 26 if( is_null($api_url) || $api_url == ''){23 if((is_null($api_url) || $api_url == '') && $api_url != 'empty'){ 27 24 throw new Exception('Не указан url для запроса к API Switips'); 28 25 } … … 34 31 $this->currencies[] = $currency; 35 32 } 36 } 33 }else{ 34 $this->currencies = $this->getAvailableCurrencies($this->api_url); 35 } 37 36 38 37 if(is_array($states)){ … … 159 158 } 160 159 } 160 161 public function getDefaultDomain($api_url = ''){ 162 if($api_url == ''){ 163 $json = file_get_contents('https://swwwp.s3.eu-central-1.amazonaws.com/d.json'); 164 165 if($json == false){ 166 return $api_url; 167 } 168 169 $json = json_decode($json); 170 171 return 'https://'.$json->mirror->merchant_api.$this->url_without_domain; 172 } 173 174 return $api_url; 175 } 176 177 public function getAvailableCurrencies($api_url = ''){ 178 179 if($api_url == ''){ 180 $api_url = $this->api_url; 181 } 182 183 $url = parse_url($api_url); 184 185 if(isset($url['scheme'])){ 186 $api_url = $url['scheme'].'://'.$url['host'].'/rest/partner/available_currencies'; 187 188 if ($curl = curl_init()) { 189 curl_setopt($curl, CURLOPT_URL, $api_url); 190 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 191 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 192 curl_setopt($curl, CURLOPT_HTTPHEADER, [ 193 'Accept: */*' 194 ]); 195 196 $out = curl_exec($curl); 197 curl_close($curl); 198 199 if($out == false){ 200 return ['MXN', 'EUR', 'KZT', 'MDL', 'BYN', 'USD', 'UAH', 'RUB']; 201 } 202 203 return json_decode($out); 204 }else{ 205 throw new Exception('cURL - не установлен'); 206 } 207 } 208 } 161 209 162 210 public function sendRequestPost($args){ 163 211 164 212 if (is_array($args)) { 165 213 166 214 $args = $this->campaignId($args); 167 215 $args = $this->commissionAmount($args); … … 178 226 } 179 227 180 $response = wp_remote_post( $this->api_url, array( 181 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 182 'body' => $args, 183 'method' => 'POST', 184 'data_format' => 'body', 185 )); 186 187 if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) { 188 return json_decode('{"status" : "error", "error" : "Service unavailable"}'); 189 } 190 191 return json_decode(wp_remote_retrieve_body($response)); 228 if ($curl = curl_init()) { 229 curl_setopt($curl, CURLOPT_URL, $this->api_url); 230 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 231 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 232 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 233 curl_setopt($curl, CURLOPT_POST, true); 234 curl_setopt($curl, CURLOPT_POSTFIELDS, $args); 235 curl_setopt($curl, CURLOPT_HTTPHEADER, array( 236 'Content-Type: application/json', 237 )); 238 239 $out = curl_exec($curl); 240 curl_close($curl); 241 242 return json_decode($out); 243 }else{ 244 throw new Exception('cURL - не установлен'); 245 } 192 246 } 193 247 } -
switips/tags/1.2/wc-switips.php
r2617266 r2754548 326 326 function switips_product_custom_fields_save($post_id){ 327 327 $woocommerce_custom_product_commission_amount = sanitize_text_field($_POST['_custom_product_commission_amount']); 328 329 //if (!empty($woocommerce_custom_product_commission_amount)) { 328 if (!empty($woocommerce_custom_product_commission_amount)) { 330 329 update_post_meta($post_id, '_custom_product_commission_amount', esc_attr($woocommerce_custom_product_commission_amount)); 331 //} 332 //esc_attr($woocommerce_custom_product_commission_amount); 330 } 331 esc_attr($woocommerce_custom_product_commission_amount); 332 333 333 } 334 334 … … 346 346 $term_id = $term->term_id; 347 347 $sw_commission = get_term_meta($term_id, '_custom_product_category_commission_amount', true); 348 349 348 ?> 350 349 <tr class="form-field"> … … 358 357 } 359 358 360 //function woocommerce_save_product_category_custom_fields($term_id) { 361 function switips_save_product_category_custom_fields($term_id) { 362 $sw_commission = filter_input(INPUT_POST, '_custom_product_category_commission_amount'); 359 function woocommerce_save_product_category_custom_fields($term_id) { 360 $sw_commission = filter_input(INPUT_POST, '_custom_product_category_commission_amount'); 363 361 update_term_meta($term_id, '_custom_product_category_commission_amount', $sw_commission); 364 362 } -
switips/trunk/common/SWSettings.php
r2531063 r2754548 1 1 <?php 2 3 if (!class_exists('Switips')) { 4 require_once( 'switips-core.php' ); 5 } 6 2 7 if ( !class_exists('switips_settings') ) { 3 8 class switips_settings { … … 47 52 48 53 public function settings_save() { 49 $opts = $this->merge_settings_post(); 54 $opts = $this->merge_settings_post(); 55 56 if($opts['url_api'] == ''){ 57 $SwitipsCls = new Switips('empty'); 58 $opts['url_api'] = $SwitipsCls->getDefaultDomain(); 59 } 50 60 51 61 // treat boolean values … … 302 312 $value = $this->get_option($name); 303 313 314 $obj = new Switips('empty'); 315 $api_url = $obj->getDefaultDomain(); 316 $available = $obj->getAvailableCurrencies($api_url); 317 304 318 ?> 305 319 <tr valign="top"> … … 310 324 <select name="<?php echo $name ?>"> 311 325 <?php foreach ( (array) $options as $optVal => $optLabel ): ?> 326 327 <?php if(in_array($optVal, $available)):?> 328 329 312 330 <option <?php if ( $value == $optVal ): ?>selected<?php endif; ?> 313 331 value="<?php echo $optVal ?>"><?php echo $optLabel; ?></option> 332 <?php endif; ?> 314 333 <?php endforeach; ?> 315 334 </select> -
switips/trunk/sw_log.log
r2551253 r2754548 1 [Thu Apr 29 08:24:32 2021] {"merchant_id":"merchant_id","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":127,"transaction_amount":"333.00","currency":"RUB","transaction_amount_currency":"333.00","tt_date":1619684672,"stat":"new","secret_key":"secret_key","commission_amount":15,"switips_status":"error","sw_error":"Internal server error"}2 [Thu Apr 29 08:24:32 2021] {"merchant_id":"merchant_id","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":127,"transaction_amount":"333.00","currency":"RUB","transaction_amount_currency":"333.00","tt_date":1619684672,"stat":"new","secret_key":"secret_key","commission_amount":15,"switips_status":"error","sw_error":"Internal server error"}3 [Thu Apr 29 08:28:22 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000512263","campaign_id":0,"category_id":0,"transaction_id":128,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1619684901,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":14,"switips_status":"ok","sw_error":null}4 [Mon Jun 07 10:21:09 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":130,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1623061268,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":24,"switips_status":"error","sw_error":"merchant not active"}5 [Mon Jun 07 10:21:10 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":130,"transaction_amount":"336.00","currency":"RUB","transaction_amount_currency":"336.00","tt_date":1623061270,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":24,"switips_status":"error","sw_error":"merchant not active"}6 [Mon Jun 07 10:26:00 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000000001","campaign_id":0,"category_id":0,"transaction_id":131,"transaction_amount":"318.00","currency":"RUB","transaction_amount_currency":"318.00","tt_date":1623061559,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":12,"switips_status":"ok","sw_error":null}7 [Wed Jun 09 12:50:55 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":132,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243055,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}8 [Wed Jun 09 12:54:51 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":133,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243291,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}9 [Wed Jun 09 12:57:54 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":134,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243474,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}10 [Wed Jun 09 12:58:14 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":135,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243494,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}11 [Wed Jun 09 12:59:31 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":136,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623243571,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}12 [Wed Jun 09 13:07:07 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":137,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623244027,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}13 [Wed Jun 09 13:08:23 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"WP0000315659","campaign_id":0,"category_id":0,"transaction_id":137,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623244103,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"ok","sw_error":null}14 [Tue Jun 15 11:58:54 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":138,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758333,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}15 [Tue Jun 15 11:58:55 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":138,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758335,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}16 [Tue Jun 15 12:00:24 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":139,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758423,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"}17 [Tue Jun 15 12:00:25 2021] {"merchant_id":"eccb52e3-7683-44be-8fa6-b4f72c5754b0","user_id":"555555555","campaign_id":0,"category_id":0,"transaction_id":139,"transaction_amount":"15.00","currency":"RUB","transaction_amount_currency":"15.00","tt_date":1623758424,"stat":"new","secret_key":"5a52a6680dc5f9495cd01470e53d095078870ad072b49f9bd12b0b978a8e1441","commission_amount":3,"switips_status":"error","sw_error":"user not found"} -
switips/trunk/switips-core.php
r2531063 r2754548 1 1 <?php 2 2 /** 3 * Switips API 4 * @link http://outcode.ru 3 * @package Switips 4 * @author Outcode https://outcode.ru/ 5 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only 5 6 */ 6 7 … … 8 9 9 10 public $api_url; 10 public $currencies = [ 11 'RUB', // Российский рубль 12 'UAH', // Украинская гривна 13 'USD', // Доллар США 14 'EUR', // Евро 15 'GBP', // Фунт стерлингов Великобритании 16 ]; 11 public $currencies = []; 17 12 public $states = [ 18 13 'new', // Создан … … 20 15 'canceled', // Отменен 21 16 'confirmed', // Подтвержден 22 ]; 17 ]; 18 19 public $url_without_domain = '/rest/partner/track'; 23 20 24 21 public function __construct($api_url, $currencies = null, $states = null){ 25 22 26 if( is_null($api_url) || $api_url == ''){23 if((is_null($api_url) || $api_url == '') && $api_url != 'empty'){ 27 24 throw new Exception('Не указан url для запроса к API Switips'); 28 25 } … … 34 31 $this->currencies[] = $currency; 35 32 } 36 } 33 }else{ 34 $this->currencies = $this->getAvailableCurrencies($this->api_url); 35 } 37 36 38 37 if(is_array($states)){ … … 159 158 } 160 159 } 160 161 public function getDefaultDomain($api_url = ''){ 162 if($api_url == ''){ 163 $json = file_get_contents('https://swwwp.s3.eu-central-1.amazonaws.com/d.json'); 164 165 if($json == false){ 166 return $api_url; 167 } 168 169 $json = json_decode($json); 170 171 return 'https://'.$json->mirror->merchant_api.$this->url_without_domain; 172 } 173 174 return $api_url; 175 } 176 177 public function getAvailableCurrencies($api_url = ''){ 178 179 if($api_url == ''){ 180 $api_url = $this->api_url; 181 } 182 183 $url = parse_url($api_url); 184 185 if(isset($url['scheme'])){ 186 $api_url = $url['scheme'].'://'.$url['host'].'/rest/partner/available_currencies'; 187 188 if ($curl = curl_init()) { 189 curl_setopt($curl, CURLOPT_URL, $api_url); 190 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 191 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 192 curl_setopt($curl, CURLOPT_HTTPHEADER, [ 193 'Accept: */*' 194 ]); 195 196 $out = curl_exec($curl); 197 curl_close($curl); 198 199 if($out == false){ 200 return ['MXN', 'EUR', 'KZT', 'MDL', 'BYN', 'USD', 'UAH', 'RUB']; 201 } 202 203 return json_decode($out); 204 }else{ 205 throw new Exception('cURL - не установлен'); 206 } 207 } 208 } 161 209 162 210 public function sendRequestPost($args){ 163 211 164 212 if (is_array($args)) { 165 213 166 214 $args = $this->campaignId($args); 167 215 $args = $this->commissionAmount($args); … … 178 226 } 179 227 180 $response = wp_remote_post( $this->api_url, array( 181 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 182 'body' => $args, 183 'method' => 'POST', 184 'data_format' => 'body', 185 )); 186 187 if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) { 188 return json_decode('{"status" : "error", "error" : "Service unavailable"}'); 189 } 190 191 return json_decode(wp_remote_retrieve_body($response)); 228 if ($curl = curl_init()) { 229 curl_setopt($curl, CURLOPT_URL, $this->api_url); 230 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 231 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 232 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 233 curl_setopt($curl, CURLOPT_POST, true); 234 curl_setopt($curl, CURLOPT_POSTFIELDS, $args); 235 curl_setopt($curl, CURLOPT_HTTPHEADER, array( 236 'Content-Type: application/json', 237 )); 238 239 $out = curl_exec($curl); 240 curl_close($curl); 241 242 return json_decode($out); 243 }else{ 244 throw new Exception('cURL - не установлен'); 245 } 192 246 } 193 247 } -
switips/trunk/wc-switips.php
r2617263 r2754548 326 326 function switips_product_custom_fields_save($post_id){ 327 327 $woocommerce_custom_product_commission_amount = sanitize_text_field($_POST['_custom_product_commission_amount']); 328 329 //if (!empty($woocommerce_custom_product_commission_amount)) { 328 if (!empty($woocommerce_custom_product_commission_amount)) { 330 329 update_post_meta($post_id, '_custom_product_commission_amount', esc_attr($woocommerce_custom_product_commission_amount)); 331 //} 332 //esc_attr($woocommerce_custom_product_commission_amount); 330 } 331 esc_attr($woocommerce_custom_product_commission_amount); 332 333 333 } 334 334 … … 346 346 $term_id = $term->term_id; 347 347 $sw_commission = get_term_meta($term_id, '_custom_product_category_commission_amount', true); 348 349 348 ?> 350 349 <tr class="form-field"> … … 358 357 } 359 358 360 //function woocommerce_save_product_category_custom_fields($term_id) { 361 function switips_save_product_category_custom_fields($term_id) { 362 $sw_commission = filter_input(INPUT_POST, '_custom_product_category_commission_amount'); 359 function woocommerce_save_product_category_custom_fields($term_id) { 360 $sw_commission = filter_input(INPUT_POST, '_custom_product_category_commission_amount'); 363 361 update_term_meta($term_id, '_custom_product_category_commission_amount', $sw_commission); 364 362 }
Note: See TracChangeset
for help on using the changeset viewer.