Changeset 2381907
- Timestamp:
- 09/15/2020 01:08:40 PM (6 years ago)
- Location:
- ezcount/trunk
- Files:
-
- 2 edited
-
EZcount.php (modified) (16 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ezcount/trunk/EZcount.php
r2380267 r2381907 4 4 * Plugin URI: 5 5 * Description: invoicing, clearing and paypal integration plugin. 6 * Version: 1.1 0.76 * Version: 1.11.2 7 7 * Author: EZcount 8 8 * Author URI: … … 24 24 add_action( 'plugins_loaded', 'init_ezcount_gateway_class', 0 ); 25 25 26 // if the user will set the ?TEST_COOKIES=1 param, we will show the cookies27 if(@$_GET['EZ_TEST_COOKIES']){28 header('Content-Type: text/plain; charset=utf-8');29 var_dump($_COOKIE);30 var_dump($_SERVER);31 die();32 }33 26 34 27 function init_ezcount_gateway_class() { … … 99 92 100 93 $this->form_fields = array( 101 'environment' => array(94 'environment' => array( 102 95 'title' => __( 'Environment', $this->environment ), 103 96 'type' => 'select', … … 107 100 'desc_tip' => true, 108 101 ), 109 'api_key' => array(102 'api_key' => array( 110 103 'title' => __( 'API Key', $this->api_key ), 111 104 'type' => 'text', … … 115 108 'required' => true 116 109 ), 117 'user_email' => array(118 'title' => __( ' Email Address', $this->user_email ),110 'user_email' => array( 111 'title' => __( 'Developer(!) email address', $this->user_email ), 119 112 'type' => 'text', 120 'description' => __( ' Please insert developer emailaddress.', $this->user_email ),113 'description' => __( 'We will send technical emails, to this address.', $this->user_email ), 121 114 'default' => $defaultEmail, 122 115 'desc_tip' => true, 123 116 'required' => true 124 117 ), 125 'checkout_window' => array(118 'checkout_window' => array( 126 119 'title' => __( 'Checkout Window Option', $this->environment ), 127 120 'type' => 'select', … … 134 127 'desc_tip' => true, 135 128 ), 136 'doc_type' => array(129 'doc_type' => array( 137 130 'title' => __( 'Doc Type', $this->doc_type ), 138 131 'type' => 'select', … … 145 138 'desc_tip' => true, 146 139 ), 147 148 140 'language_list' => array( 149 141 'title' => __( 'Defult language list', $this->language_list ), … … 216 208 ); 217 209 218 $runIntegrationTest = @$_GET['page'] == 'wc-settings' && @$_GET['tab'] == 'checkout' && @$_GET['section'] == "ezcount";219 if ( $runIntegrationTest){220 $integrationStatus = EZcount_helpers::testIntegration($this->environment,$this->api_key,$defaultEmail);221 $arr = array();222 $arr['integrationStatus'] = array(223 'title' => $integrationStatus[0]?"INTEGRATION TEST SUCCESS":"INTEGRATION TESTING ERROR! please fix the next issue",210 $runIntegrationTest = @$_GET['page'] == 'wc-settings' && @$_GET['tab'] == 'checkout' && @$_GET['section'] == "ezcount"; 211 if ( $runIntegrationTest ) { 212 $integrationStatus = EZcount_helpers::testIntegration( $this->environment, $this->api_key, $defaultEmail ); 213 $arr = array(); 214 $arr['integrationStatus'] = array( 215 'title' => $integrationStatus[0] ? "INTEGRATION TEST SUCCESS" : "INTEGRATION TESTING ERROR! please fix the next issue", 224 216 'description' => $integrationStatus[1], 225 'type' => 'title',217 'type' => 'title', 226 218 ); 227 $this->form_fields = array_merge($arr, $this->form_fields); 228 } 229 219 $this->form_fields = array_merge( $arr, $this->form_fields ); 220 } 230 221 } 231 222 … … 274 265 $sum = number_format( $order->get_total(), 2, '.', '' ); 275 266 276 $tab_id = base_convert( microtime(), 10, 32 );277 267 //create a one time token... 278 // some users open the clearing twice, and we want to user the right cookie for it 279 280 $api_url = EZcount_helpers::getApiBase() . 'payment/prepareSafeUrl/clearingFormForWeb'; 281 $data = array( 282 "sum" => $sum, 283 "payments" => $this->maxpayments_list, 284 "currency" => "ILS", 285 "successUrl" => get_site_url() . '?wc-api=WC_Gateway_EZcount&response=success&order_id=' . $order_id . '&tab_id=' . $tab_id, 286 "failedUrl" => get_site_url() . '?wc-api=WC_Gateway_EZcount&response=failed&order_id=' . $order_id . '&tab_id=' . $tab_id, 268 // some users open the clearing twice, and we want to user the right cookie for it 269 $secretTransactionId = wp_generate_uuid4(); 270 $session = EZcount_helpers::encrypt( $secretTransactionId . "|" . $order_id, $api_key ); 271 $sessionBase64Encoded = base64_encode( $session ); 272 $api_url = EZcount_helpers::getApiBase() . 'payment/prepareSafeUrl/clearingFormForWeb'; 273 $data = array( 274 "sum" => $sum, 275 "payments" => $this->maxpayments_list, 276 "currency" => "ILS", 277 "secretTransactionId" => $secretTransactionId, 278 "successUrl" => get_site_url() . '?wc-api=WC_Gateway_EZcount&response=success&order_id=' . $order_id . '&ezs=' . $sessionBase64Encoded, 279 "failedUrl" => get_site_url() . '?wc-api=WC_Gateway_EZcount&response=failed&order_id=' . $order_id . '&ezs=' . $sessionBase64Encoded, 287 280 ); 288 289 281 290 282 $result = EZcount_helpers::sendJsonRequest( $api_url, $data ); … … 302 294 } 303 295 304 $data = json_encode( array(305 'order_id' => $order_id,306 'tab_id' => $tab_id,307 "secretTransactionId" => $result->secretTransactionId,308 "creation" => time()309 ) );310 //encrypt the data311 $dataEncrypted = EZcount_helpers::encrypt( $data, $api_key );312 313 $name= "wc-ez-order-$order_id-$tab_id";314 $value=$dataEncrypted;315 //store for 5 days316 $expire= time() + 60 * 60 * 24 * 5;317 318 setcookie($name, $value, $expire, '/', null, is_ssl(), true);319 320 //https://stackoverflow.com/a/59654832/2992810321 // if (PHP_VERSION_ID < 70300) {322 // setcookie($name, $value, $expire, "/; samesite=Lax", null, is_ssl(), true);323 // }324 // else {325 // setcookie($name, $value, [326 // 'expires' => $expire,327 // 'path' => '/',328 // 'domain' => null,329 // 'samesite' => 'Lax',330 // 'secure' => is_ssl(),331 // 'httponly' => true,332 // ]);333 // }334 335 336 296 return $result->url; 337 297 } … … 364 324 } 365 325 326 366 327 $zc_payment = new WC_Gateway_EZcount(); 367 328 $zc_payment->init_form_fields(); 368 329 $zc_payment->init_settings(); 369 $api_key = $zc_payment->get_option( 'api_key' ); 370 330 $api_key = $zc_payment->get_option( 'api_key' ); 371 331 $order_id = (int) @$_GET['order_id']; 372 $tab_id = $_GET['tab_id'];373 374 332 //get order by id 375 333 $order = new WC_Order( $order_id ); 376 334 377 378 $cookieName = "wc-ez-order-$order_id-$tab_id"; 379 $dataEncrypted = $_COOKIE[ $cookieName ]; 335 $sessionBase64Encoded = $_GET["ezs"]; 380 336 381 337 // we have an error unless we found the transaction id 382 338 $errType = 2; 383 339 384 if ( ! $ dataEncrypted ) {340 if ( ! $sessionBase64Encoded ) { 385 341 $errType = 2.1; 386 342 } else { 343 $dataEncrypted = base64_decode( $sessionBase64Encoded ); 387 344 $dataDecrypted = EZcount_helpers::decrypt( $dataEncrypted, $api_key ); 388 345 if ( ! $dataDecrypted ) { 389 346 $errType = 2.2; 390 347 } else { 391 $data = json_decode( $dataDecrypted ,true);392 if ( ! is_array( $data )) {348 list( $secretTransactionId, $sessionOrderId ) = explode( "|", $dataDecrypted ); 349 if ( ! $secretTransactionId ) { 393 350 $errType = 2.3; 394 } elseif ( $data['order_id'] != $order_id || $data['tab_id'] != $tab_id ) { 395 $errType = 2.4; 396 } elseif ( ! $data['secretTransactionId'] ) { 351 } elseif ( $sessionOrderId != $order_id ) { 397 352 $errType = 2.5; 398 353 } else { 399 $secretTransactionId = $data['secretTransactionId'];400 354 //everything is OK, no error 401 355 $errType = 0; … … 410 364 אנא הכנסו אל ממשק הדוחות->סליקה באיזיקאונט, וודאו שהסליקה עברה לפני שאתם נותנים ללקוח את הטובין\n 411 365 כרגע ההזמנה נכנסה לhold ולא יצאה לה חשבונית.\n\n 412 טכנית - נראה שהמשתמש שלכם איבד את העוגיה של הסליקה בגלל אחת מהסיבות הבאות:\n 413 * הוא ניקה עוגיות בדפדפן.\n 414 * המתין יותר מיומיים עד סיום הסליקה.\n 415 * משתמש בחסימת עוגיות בדפדפן.\n 416 ללא העוגיה של הסליקה לא נוכל לבצע לה אימות. \n 366 טכנית - ההודעה הזו יכולה לקרות או במקרה של FRAUD או במקרה שעדכנתם את התוסף תוך כדי שהמשתמש היה בתהליך רכישה:\n 417 367 \n 418 368 מצורף מידע טכני … … 421 371 json_encode( [ 422 372 'order_id' => $_GET['order_id'], 423 'tab_id' => $_GET['tab_id'], 424 "cookieName" => $cookieName, 373 "sessionBase64Encoded" => $sessionBase64Encoded, 425 374 "dataEncrypted" => $dataEncrypted, 426 375 "api_key" => "..." . substr( $api_key, - 10 ), 427 376 "dataDecrypted" => $dataDecrypted, 428 "data" => json_encode( $data, 128 ),429 377 'secretTransactionId' => $secretTransactionId, 378 'sessionOrderId' => $sessionOrderId, 430 379 'timezone' => date_default_timezone_get(), 431 380 'server_date' => date( DATE_ATOM ), 432 '$_ COOKIE' => $_COOKIE,433 ' $_SERVER' => $_SERVER381 '$_SERVER' => $_SERVER, 382 'siteurl' => get_site_url() 434 383 ], 435 384 128 ); 436 385 wp_mail( $this->user_email, "VALIDATION ERROR #$errType, לא הצלחנו לבצע אישור לסליקה עבור הזמנה מספר $order_id", $msg ); 437 386 echo "VALIDATION ERROR #$errType לא הצלחנו לבצע אישור לסליקה, אבל יתכן והיא עברה, אנא צרו קשר עם בעל החנות"; 438 $order->update_status( 'on-hold' );387 $order->update_status( 'on-hold' ); 439 388 die(); 440 389 } 441 390 442 $api_url = EZcount_helpers::getApiBase() . 'payment/validate/' .$secretTransactionId;391 $api_url = EZcount_helpers::getApiBase() . 'payment/validate/'.$secretTransactionId; 443 392 $result = EZcount_helpers::sendJsonRequest( $api_url ); 444 445 393 $sum = number_format( $order->get_total(), 2, '.', '' ); 446 394 … … 506 454 $item['price'] = $itemPrice; 507 455 } else {//WC>3 508 $qty = $item_data->get_quantity();509 $product = $item_data->get_product();456 $qty = $item_data->get_quantity(); 457 $product = $item_data->get_product(); 510 458 $productName = $product->get_name(); 511 if (!$productName){512 $productName ="General item";459 if ( ! $productName ) { 460 $productName = "General item"; 513 461 } 514 462 $item['catalog_number'] = $product->get_id(); … … 572 520 array( 573 521 // CUSTOMER credentials 574 'api_key' => $zc_payment->get_option( 'api_key' ),575 'developer_email' => $zc_payment->get_option( 'user_email' ),576 'type' => $zc_payment->get_option( 'doc_type' ),577 'lang' => $zc_payment->get_option( 'language_list' ),578 'customer_name' => $customer_first_name . " " . $customer_last_name,579 'customer_email' => $customer_email,580 'customer_address' => $customer_address,581 'item' => $itemArray,582 'payment' =>522 'api_key' => $zc_payment->get_option( 'api_key' ), 523 'developer_email' => $zc_payment->get_option( 'user_email' ), 524 'type' => $zc_payment->get_option( 'doc_type' ), 525 'lang' => $zc_payment->get_option( 'language_list' ), 526 'customer_name' => $customer_first_name . " " . $customer_last_name, 527 'customer_email' => $customer_email, 528 'customer_address' => $customer_address, 529 'item' => $itemArray, 530 'payment' => 583 531 array( 584 532 array( … … 591 539 ) 592 540 ), 593 'price_total' => $paymentTotal,594 'comment' => "",595 'transaction_id' => $secretTransactionId,596 "cgp_ids" => array( $cgp_id ),597 'ua_uuid' => $this->different_account_uuid,598 "send_copy" => true,541 'price_total' => $paymentTotal, 542 'comment' => "", 543 'transaction_id' => $secretTransactionId, 544 "cgp_ids" => array( $cgp_id ), 545 'ua_uuid' => $this->different_account_uuid, 546 "send_copy" => true, 599 547 // reciept will include 600 548 "forceItemsIntoNonItemsDocument" => true, 601 // rebalance the values602 "auto_balance" => true,603 );549 // rebalance the values 550 "auto_balance" => true, 551 ); 604 552 605 553 //invoice! -
ezcount/trunk/readme.txt
r2380267 r2381907 4 4 Tags : Invoicing and clearing for Woocommerce, by EasyCount. 5 5 Tested up to: 4.9.8 6 Version : 1.1 0.76 Version : 1.11.2 7 7 Stable tag: trunk 8 8 Requires PHP: 5.4 … … 55 55 1.10.4 - add items back to receipts 56 56 1.10.5 - add $_COOKIE to the debug data 57 1.11.2 - move cookies to url encrypted session 57 58 == Upgrade notice == 58 59 nothing speacial about upgrading
Note: See TracChangeset
for help on using the changeset viewer.