Changeset 2355540
- Timestamp:
- 08/09/2020 11:59:58 AM (6 years ago)
- Location:
- ezcount/trunk
- Files:
-
- 2 edited
-
EZcount.php (modified) (14 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ezcount/trunk/EZcount.php
r2352461 r2355540 4 4 * Plugin URI: 5 5 * Description: invoicing, clearing and paypal integration plugin. 6 * Version: 1. 9.46 * Version: 1.10.1 7 7 * Author: EZcount 8 8 * Author URI: … … 81 81 */ 82 82 public function init_form_fields() { 83 84 83 $env = array( 85 84 'demo.ezcount.co.il' => 'DEMO', … … 89 88 $env['devapp.ezcount.co.il'] = 'DEV'; 90 89 } 91 $current_user = wp_get_current_user();92 $defaultEmail = $current_user->user_email;90 $current_user = wp_get_current_user(); 91 $defaultEmail = $current_user->user_email; 93 92 94 93 $this->form_fields = array( 95 'environment' => array(94 'environment' => array( 96 95 'title' => __( 'Environment', $this->environment ), 97 96 'type' => 'select', … … 101 100 'desc_tip' => true, 102 101 ), 103 'api_key' => array(102 'api_key' => array( 104 103 'title' => __( 'API Key', $this->api_key ), 105 104 'type' => 'text', … … 109 108 'required' => true 110 109 ), 111 'user_email' => array(110 'user_email' => array( 112 111 'title' => __( 'Email Address', $this->user_email ), 113 112 'type' => 'text', … … 117 116 'required' => true 118 117 ), 119 'checkout_window' => array(118 'checkout_window' => array( 120 119 'title' => __( 'Checkout Window Option', $this->environment ), 121 120 'type' => 'select', … … 128 127 'desc_tip' => true, 129 128 ), 130 'doc_type' => array(129 'doc_type' => array( 131 130 'title' => __( 'Doc Type', $this->doc_type ), 132 131 'type' => 'select', … … 160 159 'desc_tip' => true, 161 160 ), 162 'section_title2' => array(161 'section_title2' => array( 163 162 'title' => __( 'Other Settings', '' ), 164 163 'type' => 'title', … … 220 219 ); 221 220 $this->form_fields = array_merge($arr, $this->form_fields); 222 }221 } 223 222 224 223 } … … 263 262 264 263 public function getFormUrl( $order_id ) { 265 $order = new WC_Order( $order_id ); 266 267 $sum = number_format( $order->get_total(), 2, '.', '' ); 264 $order = new WC_Order( $order_id ); 265 $zc_payment = new WC_Gateway_EZcount(); 266 $api_key = $zc_payment->get_option( 'api_key' ); 267 $sum = number_format( $order->get_total(), 2, '.', '' ); 268 268 269 269 $tab_id = base_convert( microtime(), 10, 32 ); … … 295 295 } 296 296 297 if ( ! WC()->session->has_session() ) { 298 $response = "WC session is not working, the plugin must have an open session to work, please consult your developer"; 299 300 return "data:,; $response"; 301 } 302 303 WC()->session->set( 'transaction_id:' . $tab_id, $result->secretTransactionId ); 297 $data = json_encode( array( 298 'order_id' => $order_id, 299 'tab_id' => $tab_id, 300 "secretTransactionId" => $result->secretTransactionId, 301 "creation" => time() 302 ) ); 303 //encrypt the data 304 $dataEncrypted = EZcount_helpers::encrypt( $data, $api_key ); 305 306 $name= "wc-ez-order-$order_id-$tab_id"; 307 $value=$dataEncrypted; 308 //store for 5 days 309 $expire= time() + 60 * 60 * 24 * 5; 310 //https://stackoverflow.com/a/59654832/2992810 311 if (PHP_VERSION_ID < 70300) { 312 setcookie($name, $value, $expire, "/; samesite=Lax", null, is_ssl(), true); 313 } 314 else { 315 setcookie($name, $value, [ 316 'expires' => $expire, 317 'path' => '/', 318 'domain' => null, 319 'samesite' => 'Lax', 320 'secure' => is_ssl(), 321 'httponly' => true, 322 ]); 323 } 324 304 325 305 326 return $result->url; … … 310 331 global $ezcountFormLoaded; 311 332 //if the iframe been called already 312 // some users have this bug in their template and they are calling the iframe multiple times, 333 // some users have this bug in their template and they are calling the iframe multiple times, 313 334 // this creates multiple cookies, and the validation fails 314 335 if ( $ezcountFormLoaded ) { … … 336 357 $zc_payment->init_form_fields(); 337 358 $zc_payment->init_settings(); 359 $api_key = $zc_payment->get_option( 'api_key' ); 338 360 339 361 $order_id = (int) @$_GET['order_id']; 362 $tab_id = $_GET['tab_id']; 340 363 341 364 //get order by id 342 365 $order = new WC_Order( $order_id ); 343 366 344 $secretTransactionId = WC()->session->get( 'transaction_id:' . $_GET['tab_id'] ); 345 if ( ! $secretTransactionId) { 346 $msg = "בעיה באישור הזמנה $order_id, לא הצלחנו לבצע אישור מול חברת האשראי לסליקה, ההזמנה נכנסה לhold אנא בדקו מול חברת האשראי האם הכסף נכנס. \n<br/>\n 347 נראה שהמשתמשים שלכם מאבדים את הsession אנא בדקו את אורך הsession ועקבו אחרי המאמר הבא כדי לטפל בבעיות נפוצות של איבוד session. 348 it's seems the user lost the session, please check your session settings using the next article\n<br/>\n 349 https://en.blogpascher.com/wordpress-tutorial/How-correct-the-loss-of-session-on-wordpress\n<br/>\n 367 368 $cookieName = "wc-ez-order-$order_id-$tab_id"; 369 $dataEncrypted = $_COOKIE[ $cookieName ]; 370 371 // we have an error unless we found the transaction id 372 $errType = 2; 373 374 if ( ! $dataEncrypted ) { 375 $errType = 2.1; 376 } else { 377 $dataDecrypted = EZcount_helpers::decrypt( $dataEncrypted, $api_key ); 378 if ( ! $dataDecrypted ) { 379 $errType = 2.2; 380 } else { 381 $data = json_decode( $dataDecrypted ,true); 382 if ( ! is_array( $data ) ) { 383 $errType = 2.3; 384 } elseif ( $data['order_id'] != $order_id || $data['tab_id'] != $tab_id ) { 385 $errType = 2.4; 386 } elseif ( ! $data['secretTransactionId'] ) { 387 $errType = 2.5; 388 } else { 389 $secretTransactionId = $data['secretTransactionId']; 390 //everything is OK, no error 391 $errType = 0; 392 } 393 } 394 } 395 396 397 if ( $errType || ! $secretTransactionId ) { 398 $msg = "בעיה באישור הזמנה $order_id, לא הצלחנו לבצע אישור מול חברת האשראי לסליקה, ההזמנה נכנסה לhold אנא בדקו מול חברת האשראי האם הכסף נכנס. \n 399 נראה שהמשתמש שלכם איבד את העוגיה של הסליקה, זה יכול לקרות אם הוא ניקה עוגיות, המתין יותר מיומיים עד סיום הסליקה או משתמש בחסימת עוגיות בדפדפן. \n 400 ללא העוגיה של הסליקה לא נוכל לבצע לה אימות. \n 401 \n 402 אנא הכנסו אל ממשק הדוחות->סליקה באיזיקאונט, וודאו שהסליקה עברה לפני שאתם נותנים ללקוח את הטובין\n 403 \n\n\n 404 מצורף מידע טכני 350 405 \n 351 Order ($order_id) transaction Id is empty, can't validate payment \n <br/>\n" .406 Order ($order_id) transaction Id is empty, can't validate payment \n\n" . 352 407 json_encode( [ 353 408 'order_id' => $_GET['order_id'], 354 409 'tab_id' => $_GET['tab_id'], 410 "cookieName" => $cookieName, 411 "dataEncrypted" => $dataEncrypted, 412 "api_key" => "..." . substr( $api_key, - 10 ), 413 "dataDecrypted" => $dataDecrypted, 414 "data" => json_encode( $data, 128 ), 415 'secretTransactionId' => $secretTransactionId, 355 416 'timezone' => date_default_timezone_get(), 356 'server_date' => date(DATE_ATOM), 357 'secretTransactionId' => $secretTransactionId, 417 'server_date' => date( DATE_ATOM ), 358 418 '$_SERVER' => $_SERVER 359 ] ); 360 wp_mail( $this->user_email, 'Order transaction Id is empty, can\'t validate payment', $msg ); 361 echo "VALIDATION ERROR #1.5 לא הצלחנו לבצע אישור לסליקה, אבל יתכן והיא עברה, אנא צרו קשר עם בעל החנות"; 362 $order->update_status( 'on-hold' ); 419 ], 420 128 ); 421 wp_mail( $this->user_email, "VALIDATION ERROR #$errType, לא הצלחנו לבצע אישור לסליקה עבור הזמנה מספר $order_id", $msg ); 422 echo "VALIDATION ERROR #$errType לא הצלחנו לבצע אישור לסליקה, אבל יתכן והיא עברה, אנא צרו קשר עם בעל החנות"; 423 $order->update_status( 'on-hold' ); 363 424 die(); 364 425 } … … 559 620 } 560 621 561 /**562 * We need longer sessions so we add this filters563 */564 //https://stackoverflow.com/a/39707517/2992810565 // https://github.com/ericmann/wp-session-manager/issues/25#issuecomment-299819341566 add_action( 'plugins_loaded',567 function () {568 add_filter( 'wp_session_expiration',569 function () {570 return 48 * 60 * 60;571 } );572 add_filter( 'wp_session_expiration_variant',573 function () {574 return 46 * 60 * 60;575 } );576 },577 1 );578 // not sure which of them will do the job..579 // https://stackoverflow.com/a/62241135/2992810580 add_filter( 'wc_session_expiring', 'wc_custom_session_expiring' );581 add_filter( 'wc_session_expiration', 'wc_custom_session_expiring' );582 function wc_custom_session_expiring( $expiry ) {583 return 60 * 60 * 48;584 }585 586 622 // load the ezcount gateway 587 623 add_filter( 'woocommerce_payment_gateways', 'add_ezcount_gateway' ); -
ezcount/trunk/readme.txt
r2352461 r2355540 4 4 Tags : Invoicing and clearing for Woocommerce, by EasyCount. 5 5 Tested up to: 4.9.8 6 Version : 1. 9.46 Version : 1.10.1 7 7 Stable tag: trunk 8 8 Requires PHP: 5.4 … … 51 51 1.9.4 - improve the fix 52 52 53 1.10.1 - move session to cookies 53 54 == Upgrade notice == 54 55 nothing speacial about upgrading
Note: See TracChangeset
for help on using the changeset viewer.