Changeset 2900759
- Timestamp:
- 04/18/2023 02:08:02 PM (3 years ago)
- Location:
- totalprocessing-card-payments
- Files:
-
- 82 added
- 4 edited
-
tags/5.3.3 (added)
-
tags/5.3.3/LICENSE.txt (added)
-
tags/5.3.3/README.md (added)
-
tags/5.3.3/admin (added)
-
tags/5.3.3/admin/class-totalprocessing-card-payments-and-gateway-woocommerce-admin.php (added)
-
tags/5.3.3/admin/css (added)
-
tags/5.3.3/admin/css/totalprocessing-card-payments-and-gateway-woocommerce-admin.css (added)
-
tags/5.3.3/admin/index.php (added)
-
tags/5.3.3/admin/js (added)
-
tags/5.3.3/admin/js/totalprocessing-card-payments-and-gateway-woocommerce-admin.js (added)
-
tags/5.3.3/admin/partials (added)
-
tags/5.3.3/admin/partials/admin-options.php (added)
-
tags/5.3.3/admin/partials/totalprocessing-card-payments-and-gateway-woocommerce-admin-display.php (added)
-
tags/5.3.3/admin/testtstes.txt (added)
-
tags/5.3.3/assets (added)
-
tags/5.3.3/assets/css (added)
-
tags/5.3.3/assets/css/cards_style.min.css (added)
-
tags/5.3.3/assets/css/cardsv2-style.css (added)
-
tags/5.3.3/assets/frames (added)
-
tags/5.3.3/assets/frames/3d.php (added)
-
tags/5.3.3/assets/frames/index.php (added)
-
tags/5.3.3/assets/img (added)
-
tags/5.3.3/assets/img/AMEX-3d.svg (added)
-
tags/5.3.3/assets/img/AMEX-inline.svg (added)
-
tags/5.3.3/assets/img/AMEX.svg (added)
-
tags/5.3.3/assets/img/MAESTRO-3d.svg (added)
-
tags/5.3.3/assets/img/MAESTRO-inline.svg (added)
-
tags/5.3.3/assets/img/MAESTRO.svg (added)
-
tags/5.3.3/assets/img/MASTER-3d.svg (added)
-
tags/5.3.3/assets/img/MASTER-inline.svg (added)
-
tags/5.3.3/assets/img/MASTER.svg (added)
-
tags/5.3.3/assets/img/TP-Logo-white.png (added)
-
tags/5.3.3/assets/img/VISA-3d.svg (added)
-
tags/5.3.3/assets/img/VISA-inline.svg (added)
-
tags/5.3.3/assets/img/VISA.svg (added)
-
tags/5.3.3/assets/img/default.svg (added)
-
tags/5.3.3/assets/img/tp-logo.png (added)
-
tags/5.3.3/assets/img/tpcp-ajax-loader.gif (added)
-
tags/5.3.3/assets/js (added)
-
tags/5.3.3/assets/js/jquery-3.5.1.min.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2_logging.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2_logging_off.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2_orderpay.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2_registration.js (added)
-
tags/5.3.3/assets/js/tpJs-cardsv2x.js (added)
-
tags/5.3.3/includes (added)
-
tags/5.3.3/includes/class-totalprocessing-card-payments-and-gateway-woocommerce-activator.php (added)
-
tags/5.3.3/includes/class-totalprocessing-card-payments-and-gateway-woocommerce-deactivator.php (added)
-
tags/5.3.3/includes/class-totalprocessing-card-payments-and-gateway-woocommerce-i18n.php (added)
-
tags/5.3.3/includes/class-totalprocessing-card-payments-and-gateway-woocommerce-loader.php (added)
-
tags/5.3.3/includes/class-totalprocessing-card-payments-and-gateway-woocommerce.php (added)
-
tags/5.3.3/includes/class-totalprocessing-constants.php (added)
-
tags/5.3.3/includes/class-tp-payment-gateway-old-version-helper.php (added)
-
tags/5.3.3/includes/class-tp-payment-gateway.php (added)
-
tags/5.3.3/includes/error-codes-and-messages.php (added)
-
tags/5.3.3/includes/index.php (added)
-
tags/5.3.3/includes/payment-gateway-faqs-array.php (added)
-
tags/5.3.3/includes/payment-gateway-setting-fields.php (added)
-
tags/5.3.3/includes/payment-gateway-static-data-array.php (added)
-
tags/5.3.3/includes/tp-payment-gateway-helper-trait.php (added)
-
tags/5.3.3/index.php (added)
-
tags/5.3.3/languages (added)
-
tags/5.3.3/languages/totalprocessing-card-payments-and-gateway-woocommerce.pot (added)
-
tags/5.3.3/log (added)
-
tags/5.3.3/log/cronjobcheck.txt (added)
-
tags/5.3.3/public (added)
-
tags/5.3.3/public/class-totalprocessing-card-payments-and-gateway-woocommerce-public.php (added)
-
tags/5.3.3/public/css (added)
-
tags/5.3.3/public/css/totalprocessing-card-payments-and-gateway-woocommerce-public.css (added)
-
tags/5.3.3/public/index.php (added)
-
tags/5.3.3/public/js (added)
-
tags/5.3.3/public/js/jquery-3.5.1.min.js (added)
-
tags/5.3.3/public/js/totalprocessing-card-payments-and-gateway-woocommerce-public.js (added)
-
tags/5.3.3/public/partials (added)
-
tags/5.3.3/public/partials/totalprocessing-card-payments-and-gateway-woocommerce-public-display.php (added)
-
tags/5.3.3/readme.txt (added)
-
tags/5.3.3/templates (added)
-
tags/5.3.3/templates/pci-frame-external.php (added)
-
tags/5.3.3/templates/pci-frame-templatev3.php (added)
-
tags/5.3.3/totalprocessing-card-payments-and-gateway-woocommerce.php (added)
-
tags/5.3.3/uninstall.php (added)
-
trunk/includes/class-tp-payment-gateway.php (modified) (60 diffs)
-
trunk/includes/tp-payment-gateway-helper-trait.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/totalprocessing-card-payments-and-gateway-woocommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
totalprocessing-card-payments/trunk/includes/class-tp-payment-gateway.php
r2875305 r2900759 443 443 $resourcePath = (string)$_REQUEST['resourcePath']; 444 444 445 $this->writeLog( '----- checkForVerifyTx [Querystring values Array] -----', 'debug' ); 446 $this->writeLog( $_GET, 'info' ); 445 $this->writeLog( '----- checkForVerifyTx [Querystring values Array] -----', $_GET, 'debug' ); 447 446 448 447 if(isset($_REQUEST['platformBase'])){ … … 459 458 $platformBase = $this->platformBase; 460 459 } 461 $this->writeLog( '----- checkForVerifyTx [requesting transaction status for modal view request or orderpay request] -----', 'debug' );460 $this->writeLog( '----- checkForVerifyTx [requesting transaction status for modal view request or orderpay request] -----', null, 'debug' ); 462 461 $responseObject = $this->requestTransactionStatus( $platformBase, $id, $resourcePath, $order_id); 463 462 … … 468 467 if(isset($responseObject->registrationId)){ 469 468 $id = (string)$responseObject->registrationId; 470 $this->writeLog( '----- checkForVerifyTx [requesting transaction status when registarion id exists] -----', 'debug' );469 $this->writeLog( '----- checkForVerifyTx [requesting transaction status when registarion id exists] -----', null, 'debug' ); 471 470 $responseObject = $this->requestTransactionStatus($platformBase, $id, false, $order_id); 472 471 } … … 475 474 } 476 475 } 477 $this->writeLog( '----- checkForVerifyTx [response data for modal view request or orderpay request] -----', 'debug' );476 $this->writeLog( '----- checkForVerifyTx [response data for modal view request or orderpay request] -----', null, 'debug' ); 478 477 $responseResult = $this->parseResponseData($responseObject); 479 478 if(isset($responseResult['result'])){ … … 614 613 } 615 614 if((float)$amount === 0){ 616 $this->writeLog( '----- createCheckoutArray [amount is zero] -----', 'debug' ); 617 $this->writeLog( $amount, 'debug' ); 615 $this->writeLog( '----- createCheckoutArray [amount is zero, amount:' . $amount . '] -----', null, 'debug' ); 618 616 return false; 619 617 } … … 635 633 if((float)$amount === -0.01){ 636 634 if(is_user_logged_in() !== true){ 637 $this->writeLog( '----- createCheckoutArray [user is not logged in] -----', 'debug' ); 638 $this->writeLog( $amount, 'debug' ); 635 $this->writeLog( '----- createCheckoutArray [user is not logged in with amount:'.$amount.'] -----', null, 'debug' ); 639 636 return false; 640 637 } … … 647 644 if($this->createRegistration === true && is_user_logged_in() === true){ 648 645 if($registrationId !== false){ 649 $this->writeLog( '----- createCheckoutArray [registration id = ' . $registrationId . '] -----', 'debug' );646 $this->writeLog( '----- createCheckoutArray [registration id = ' . $registrationId . '] -----', null, 'debug' ); 650 647 $registrationIds = [$registrationId]; 651 648 } else { 652 $this->writeLog( '----- createCheckoutArray [generating tokens] -----', 'debug' );653 649 $registrationIds = $this->retrieveUnlimitedTokens( get_current_user_id(), $this->id, $this->platformBase ); 654 $this->writeLog( $registrationIds, 'info' );650 $this->writeLog( '----- createCheckoutArray [generating tokens] -----', $registrationIds, 'debug' ); 655 651 } 656 652 if(count($registrationIds) > 0){ … … 679 675 } 680 676 $response = wp_remote_request( $remoteUrl , $array); 681 $this->writeLog( '----- createCheckoutArray [calling to generate checkout id] -----', 'debug' ); 682 $this->writeLog( ['requestURL' => $remoteUrl, 'payload' => $array, 'response' => $response], 'info' ); 683 //$this->shouldLogResponseHandler($response, [$array, $payload]); 684 //return false; 677 $this->writeLog( '----- createCheckoutArray [calling to generate checkout id] -----', ['params' => $array, 'response' => $response], 'debug' ); 678 685 679 if( is_wp_error( $response ) ){ 686 680 $errorMessage = $response->get_error_message(); 687 $this->writeLog( '----- createCheckoutArray [returned wp_error -> url:'.$remoteUrl.'] -----', 'critical' ); 688 $this->writeLog( $errorMessage, 'critical' ); 689 $this->writeLog( '----- createCheckoutArray [params] -----', 'critical' ); 690 $this->writeLog( $array, 'critical' ); 691 $this->writeLog( '----- createCheckoutArray [response] -----', 'critical' ); 692 $this->writeLog( $response, 'critical' ); 681 $this->writeLog( '----- createCheckoutArray [returned wp_error -> url:'.$remoteUrl.'] -----', $errorMessage, 'critical' ); 693 682 return false; 694 683 } … … 714 703 ]; 715 704 WC()->session->set('tp_checkoutData', $checkoutDataArray); 716 $this->writeLog( '----- createCheckoutArray [success in getting checout id and saved in session] -----', 'debug' ); 717 $this->writeLog( $checkoutDataArray, 'info' ); 705 $this->writeLog( '----- createCheckoutArray [success in getting checout id and saved in session] -----', $checkoutDataArray, 'debug' ); 718 706 return (string)$responseData->id; 719 707 } 720 708 } 721 709 } else { 722 $this->writeLog( '----- createCheckoutArray [failed in getting checout id] -----', 'debug' );710 $this->writeLog( '----- createCheckoutArray [failed in getting checout id] -----', null, 'debug' ); 723 711 WC()->session->set('tp_checkoutData', null); 724 712 } … … 727 715 728 716 public function genCheckoutId(){ 729 $this->writeLog( '----- genCheckoutId [initiating Create Checkout ID with amount -0.01]-----', 'debug' );717 $this->writeLog( '----- genCheckoutId [initiating Create Checkout ID with amount -0.01]-----', null, 'debug' ); 730 718 $responseData = $this->createCheckoutArray(false,-0.01); 731 719 732 720 if($responseData){ 733 $this->writeLog( '----- genCheckoutId [success in calling Create Checkout ID with amount -0.01]-----', 'debug' );721 $this->writeLog( '----- genCheckoutId [success in calling Create Checkout ID with amount -0.01]-----', null, 'debug' ); 734 722 wp_send_json_success($responseData); 735 723 } else { 736 $this->writeLog( '----- genCheckoutId [failed in calling Create Checkout ID with amount -0.01]-----', 'debug' );724 $this->writeLog( '----- genCheckoutId [failed in calling Create Checkout ID with amount -0.01]-----', null, 'debug' ); 737 725 wp_send_json_error(); 738 726 } … … 743 731 */ 744 732 public function genCheckoutIdOrder(){ 745 $this->writeLog( '----- genCheckoutIdOrder [initiating Create Checkout ID] -----', 'debug' );733 $this->writeLog( '----- genCheckoutIdOrder [initiating Create Checkout ID] -----', null, 'debug' ); 746 734 $responseData = $this->createCheckoutArray(); 747 735 … … 750 738 if(isset($responseData->result->code)){ 751 739 if(in_array($responseData->result->code,['000.200.000','000.200.100','000.200.101'])){ 752 $this->writeLog( '----- genCheckoutIdOrder [success in Create Checkout ID -> '.$responseData->id.'] -----', 'debug' );740 $this->writeLog( '----- genCheckoutIdOrder [success in Create Checkout ID -> '.$responseData->id.'] -----', null, 'debug' ); 753 741 wp_send_json_success([ 754 742 'uuid' => $responseData->id, … … 759 747 } 760 748 } 761 $this->writeLog( '----- genCheckoutIdOrder [failed in Create Checkout ID] -----', 'debug' );749 $this->writeLog( '----- genCheckoutIdOrder [failed in Create Checkout ID] -----', null, 'debug' ); 762 750 wp_send_json_error(); 763 751 } … … 780 768 if(is_array($levelData)){ 781 769 if(isset($levelData[1])){ 782 $this->writeLog('--------shouldLogResponseHandler -------', 'debug');783 $this->writeLog($array,$levelData[1]);784 $this->writeLog($responseData,$levelData[1]);785 770 return true; 786 771 } … … 809 794 $level = 'info'; 810 795 } 811 812 $this->writeLog('--------shouldLogResponseHandler -------', 'debug');813 $this->writeLog($array,$level);814 $this->writeLog($responseData,$level);815 796 } 816 797 } … … 828 809 $level = $postArr['level']; 829 810 } 830 $this->writeLog('------------feLogger---------','debug'); 831 $this->writeLog($array,'error'); 811 $this->writeLog('------------feLogger---------', $array,'debug'); 832 812 wp_send_json_success($postArr); 833 813 } else { … … 842 822 public function tpOrderPay(){ 843 823 global $woocommerce; 824 $this->writeLog('------------tpOrderPay initiated---------', null,'debug'); 844 825 $payment_method = wc_get_post_data_by_key('payment_method',false); 845 826 $terms_field = wc_get_post_data_by_key('terms-field',false); … … 908 889 } 909 890 $validate['result'] = 'failure'; 891 $this->writeLog('------------tpOrderPay initiated---------', $validate,'debug'); 910 892 wp_send_json_error($validate); 911 893 } … … 936 918 } 937 919 if(count($validation['errors']) > 0){ 920 $this->writeLog('------------validatePayForOrder error---------', $validation,'debug'); 938 921 return $validation; 939 922 } 940 923 if(!wp_verify_nonce($postArr['tp_payment_nonce'],'tp_payment_nonce')){ 941 924 $validation['errors'][] = 'nonce validation failed'; 925 $this->writeLog('------------validatePayForOrder nonce error---------', $validation,'debug'); 942 926 return $validation; 943 927 } … … 954 938 } 955 939 if(count($validation['errors']) > 0){ 940 $this->writeLog('------------validatePayForOrder error---------', $validation,'debug'); 956 941 return $validation; 957 942 } … … 959 944 if(!isset($parseUrl['query'])){ 960 945 $validation['errors'][] = 'no query args'; 946 $this->writeLog('------------validatePayForOrder no query error---------', $validation,'debug'); 961 947 return $validation; 962 948 } … … 964 950 if(!isset($parseStr['key'])){ 965 951 $validation['errors'][] = 'no key in query args'; 952 $this->writeLog('------------validatePayForOrder no query error---------', $validation,'debug'); 966 953 return $validation; 967 954 } … … 991 978 } 992 979 } 980 $this->writeLog('------------validatePayForOrder finished ---------', $validation,'debug'); 993 981 return $validation; 994 982 } … … 1031 1019 $order_id = wc_get_post_data_by_key( 'order_id', false ); 1032 1020 $resourcePath = sanitize_text_field( $resourcePath ); 1021 $this->writeLog('------------checkTransactionStatus init [time:'.time().'] ---------', null,'debug'); 1033 1022 $responseObject = $this->verifyTransactionStatus( $resourcePath, $order_id ); 1023 $this->writeLog('------------checkTransactionStatus request done [time:'.time().'] ---------', null,'debug'); 1034 1024 $transaction_id = (int)( isset( $responseObject->merchantTransactionId ) ? $responseObject->merchantTransactionId : 0 ); 1035 1025 $payment_id = isset( $responseObject->id ) ? $responseObject->id : ""; … … 1047 1037 ) 1048 1038 ); 1039 $this->writeLog('------------checkTransactionStatus db tnxtbl updated with response [time:'.time().', orderid:'.$order_id.'] ---------', null,'debug'); 1049 1040 1050 1041 if( !empty( $payment_code ) ){ … … 1063 1054 public function lookupTransaction(){ 1064 1055 global $wpdb; 1065 $this->writeLog('------------lookupTransaction initiated ---------','debug'); 1056 $this->writeLog('------------lookupTransaction initiated [orderid:'.$order_id.'] ---------', null,'debug'); 1057 $checkoutHash = WC()->cart->get_cart_hash(); 1066 1058 $url = wc_get_checkout_url(); 1067 1059 $resourcePath = wc_get_post_data_by_key('resourcePath',false); … … 1071 1063 $debugArray['time'][0] = time(); 1072 1064 if($order_id && $order_id > 0){ 1073 $this->writeLog('------------lookupTransaction [requesting transaction status] ---------','debug');1074 $this->writeLog(['resourcepath' => $resourcePath, 'order_id' => $order_id],'debug');1075 1065 $ordertnxData = $wpdb->get_row( 1076 1066 $wpdb->prepare( … … 1080 1070 ARRAY_A 1081 1071 ); 1072 $this->writeLog('------------lookupTransaction [requesting transaction status from db tnxtbl] ---------', null,'debug'); 1082 1073 $responseObject = json_decode( $ordertnxData['result_json'] ); 1083 1074 //$responseObject = $this->requestTransactionStatus( $this->platformBase, false, $resourcePath, $order_id ); … … 1089 1080 if(isset($responseObject->registrationId)){ 1090 1081 $id = (string)$responseObject->registrationId; 1091 $this->writeLog('------------lookupTransaction [requested transaction status again] ---------', 'debug');1082 $this->writeLog('------------lookupTransaction [requested transaction status again] ---------', null,'debug'); 1092 1083 $responseObject = $this->requestTransactionStatus( $this->platformBase, $id, false, $order_id ); 1093 1084 $debugArray['time'][2] = time(); … … 1097 1088 } 1098 1089 $responseResult = $this->parseResponseData($responseObject); 1099 $this->writeLog('------------lookupTransaction [responseResult] ---------', 'debug');1090 $this->writeLog('------------lookupTransaction [responseResult] ---------', null,'debug', $checkoutHash); 1100 1091 $order_id = (int)$responseObject->merchantTransactionId; 1101 1092 $payment_id = $responseObject->id; … … 1110 1101 } 1111 1102 1112 $this->writeLog('------------lookupTransaction 1 ---------','debug'); 1113 $this->writeLog($debugArray,'info'); 1103 $this->writeLog('------------lookupTransaction 1 ---------', $debugArray,'debug', $checkoutHash); 1114 1104 wp_send_json_success(['valid' => true, /*'resourcePath'=> $resourcePath,*/ 'responseObject' => $responseObject, "responseResult" => $responseResult, "url" => $url]); 1115 1105 } else { 1116 $this->writeLog('------------lookupTransaction 2 ---------','debug'); 1117 $this->writeLog($debugArray,'info'); 1106 $this->writeLog('------------lookupTransaction 2 ---------', $debugArray,'debug', $checkoutHash); 1118 1107 wp_send_json_error(['error' => 'responseObject','message' => 'is not object', 'data' => $ordertnxData]); 1119 1108 } 1120 1109 } 1121 1110 1122 $this->writeLog('------------lookupTransaction 3 ---------','debug'); 1123 $this->writeLog($debugArray,'info'); 1111 $this->writeLog('------------lookupTransaction 3 ---------', $debugArray,'debug', $checkoutHash); 1124 1112 wp_send_json_error(['error' => 'resourcePath error','message' => 'error']); 1125 1113 } … … 1174 1162 public function verifyTransactionStatus( $resourcePath, $order_id ){ 1175 1163 if( empty( $resourcePath ) ){ 1176 $this->writeLog( '----- verifyTransactionStatus [no resource path] -----', 'debug' ); 1177 $this->writeLog( "Resourcepath:" . $resourcePath, 'debug' ); 1164 $this->writeLog( '----- verifyTransactionStatus [no resource path: ' . $resourcePath . '] -----', null, 'debug' ); 1178 1165 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $resourcePath), 'error'); 1179 1166 return false; 1180 1167 } 1181 1168 if( empty( $order_id ) ){ 1182 $this->writeLog( '----- verifyTransactionStatus [no order id] -----', 'debug' ); 1183 $this->writeLog( "Order id:" . $order_id, 'debug' ); 1169 $this->writeLog( '----- verifyTransactionStatus [no order id: ' . $order_id . '] -----', null, 'debug' ); 1184 1170 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $resourcePath), 'error'); 1185 1171 return false; … … 1204 1190 ]; 1205 1191 $executionTime['verificationInit'] = time(); 1206 $this->writeLog( '------------verifyTransactionStatus [URL and Data Sent] -----------', 'debug' ); 1207 $this->writeLog( [ 'url' => $url, 'params' => $arg ], 'info' ); 1192 $this->writeLog( '------------verifyTransactionStatus [URL and Data Sent] -----------', [ 'url' => $url, 'params' => $arg ], 'debug' ); 1208 1193 1209 1194 $response = wp_remote_request( $url, $arg ); … … 1212 1197 if( is_wp_error( $response ) ) { 1213 1198 $errorMessage = $response->get_error_message(); 1214 $this->writeLog( '----- verifyTransactionStatus [returned wp_error, url:'.$url.'] -----', 'critical' ); 1215 $this->writeLog( $errorMessage, 'critical' ); 1216 $this->writeLog( '----- verifyTransactionStatus [params] -----', 'critical' ); 1217 $this->writeLog( $arg, 'critical' ); 1218 $this->writeLog( '----- verifyTransactionStatus [response] -----', 'critical' ); 1219 $this->writeLog( $response, 'critical' ); 1199 $this->writeLog( '----- verifyTransactionStatus [returned wp_error, url:'.$url.'] -----', ['errMsg' => $errorMessage, 'response' => $response], 'critical' ); 1220 1200 $secondaryCall = true; 1221 1201 }elseif( !isset( $response['body'] ) ) { 1222 $this->writeLog( '----- verifyTransactionStatus [returned no status, url:'.$url.'] -----', 'critical' ); 1223 $this->writeLog( $response, 'critical' ); 1202 $this->writeLog( '----- verifyTransactionStatus [returned no status, url:'.$url.'] -----', ['response' => $response], 'critical' ); 1224 1203 $secondaryCall = true; 1225 1204 } … … 1230 1209 $url .= "&merchantTransactionId=" . (int)$order_id; 1231 1210 1232 $this->writeLog( '----- verifyTransactionStatus [secondary API call init] -----', 'debug' );1233 $this->writeLog( $url, 'debug' );1234 1235 1211 $executionTime['secondaryapiInit'] = time(); 1236 1212 $response = wp_remote_request( $url, $arg ); 1213 $this->writeLog( '----- verifyTransactionStatus [secondary API call init] -----', ['url' => $url, 'args' => $arg, 'response' => $response], 'debug' ); 1237 1214 if( is_wp_error( $response ) ) { 1238 1215 $errorMessage = $response->get_error_message(); 1239 $this->writeLog( '----- verifyTransactionStatus [returned wp_error, url:'.$url.'] -----', 'critical' ); 1240 $this->writeLog( $errorMessage, 'critical' ); 1241 $this->writeLog( '----- verifyTransactionStatus [params] -----', 'critical' ); 1242 $this->writeLog( $args, 'critical' ); 1243 $this->writeLog( '----- verifyTransactionStatus [response] -----', 'critical' ); 1244 $this->writeLog( $response, 'critical' ); 1245 } 1246 $this->writeLog( '----- verifyTransactionStatus [secondary api call response data] -----', 'debug' ); 1247 $this->writeLog( $response, 'info' ); 1216 $this->writeLog( '----- verifyTransactionStatus [returned wp_error, url:'.$url.'] -----', $errorMessage, 'critical' ); 1217 } 1248 1218 $executionTime['secondaryapiResponseAt'] = time(); 1249 1219 } 1250 $this->writeLog( '----- verifyTransactionStatus [API Call execution time array] -----', 'debug' ); 1251 $this->writeLog( $executionTime, 'info' ); 1252 1220 $this->writeLog( '----- verifyTransactionStatus [API Call execution time array] -----', $executionTime, 'debug' ); 1221 1253 1222 if( is_wp_error( $response ) ) { 1254 1223 $errorMessage = $response->get_error_message(); 1255 $this->writeLog( '----- verifyTransactionStatus [returned wp_error, url:'.$url.'] -----', 'debug' ); 1256 $this->writeLog( $errorMessage, 'debug' ); 1224 $this->writeLog( '----- verifyTransactionStatus [Uncertain response and returned wp_error, url:'.$url.'] -----', null, 'debug' ); 1257 1225 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $resourcePath), 'error'); 1258 1226 return false; 1259 1227 }elseif( !isset( $response['body'] ) ) { 1260 $this->writeLog( '----- verifyTransactionStatus [returned no status] -----', 'debug' ); 1261 $this->writeLog( $response, 'info' ); 1228 $this->writeLog( '----- verifyTransactionStatus [returned no status] -----', null, 'debug' ); 1262 1229 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $resourcePath), 'error'); 1263 1230 return false; … … 1267 1234 $responseData = json_decode($responseResult); 1268 1235 $responseData = ( $secondaryCall === true ) ? ( isset($responseData->payments[0]) ? $responseData->payments[ ( count( $responseData->payments ) - 1 ) ] : new stdClass) : $responseData; 1269 $this->writeLog( '----- verifyTransactionStatus [final response data] -----', 'debug' ); 1270 $this->writeLog( ['header' => $array, 'response' => $responseData], 'info' ); 1236 $this->writeLog( '----- verifyTransactionStatus [final response data] -----', $responseData, 'debug' ); 1271 1237 return $responseData; 1272 1238 } … … 1274 1240 public function verifyTransactionStatusByIDOrOrderID( $id, $order_id ){ 1275 1241 if( empty( $id ) ){ 1276 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [no payment id] -----', 'debug' ); 1277 $this->writeLog( "Resourcepath:" . $id, 'debug' ); 1242 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [no payment id] -----', null, 'debug' ); 1278 1243 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful.'), 'error'); 1279 1244 return false; … … 1281 1246 //$resourcePath = "/v1/checkouts/".$id."/payment"; 1282 1247 if( empty( $order_id ) ){ 1283 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [no order id] -----', 'debug' );1284 $this->writeLog( "Order id:" . $order_id, 'debug' ); 1248 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [no order id] -----', null, 'debug' ); 1249 1285 1250 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $id), 'error'); 1286 1251 return false; … … 1304 1269 ]; 1305 1270 $executionTime['verificationInit'] = time(); 1306 $this->writeLog( '------------verifyTransactionStatusByIDOrOrderID [URL and Data Sent] -----------', 'debug' ); 1307 $this->writeLog( [ 'url' => $url, 'params' => $arg ], 'info' ); 1271 $this->writeLog( '------------verifyTransactionStatusByIDOrOrderID [URL and Data Sent] -----------', [ 'url' => $url, 'params' => $arg ], 'debug' ); 1308 1272 1309 1273 $response = wp_remote_request( $url, $arg ); … … 1312 1276 if( is_wp_error( $response ) ) { 1313 1277 $errorMessage = $response->get_error_message(); 1314 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error] -----', 'critical' ); 1315 $this->writeLog( $errorMessage, 'critical' ); 1278 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error] -----', ['errMsg' => $errorMessage, 'response' => $response], 'critical' ); 1316 1279 $secondaryCall = true; 1317 1280 }elseif( !isset( $response['body'] ) ) { 1318 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned no status] -----', 'warning' ); 1319 $this->writeLog( $response, 'warning' ); 1281 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned no status] -----', $response, 'warning' ); 1320 1282 $secondaryCall = true; 1321 1283 } … … 1326 1288 $url .= "&merchantTransactionId=" . (int)$order_id; 1327 1289 1328 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [secondary API call init] -----', 'debug' ); 1329 $this->writeLog( $url, 'debug' ); 1290 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [secondary API call init, url:' . $url . '] -----', null, 'debug' ); 1330 1291 1331 1292 $executionTime['secondaryapiInit'] = time(); … … 1333 1294 if( is_wp_error( $response ) ) { 1334 1295 $errorMessage = $response->get_error_message(); 1335 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error] -----', 'critical' ); 1336 $this->writeLog( $errorMessage, 'critical' ); 1296 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error for secondary api call] -----', ['errMsg' => $errorMessage, 'response' => $response], 'critical' ); 1337 1297 return false; 1338 1298 } 1339 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [secondary api call response data] -----', 'debug' ); 1340 $this->writeLog( $response, 'info' ); 1299 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [secondary api call response data] -----', $response, 'debug' ); 1341 1300 $executionTime['secondaryapiResponseAt'] = time(); 1342 1301 } 1343 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [API Call execution time array] -----', 'debug' ); 1344 $this->writeLog( $executionTime, 'info' ); 1302 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [API Call execution time array] -----', $executionTime, 'debug' ); 1345 1303 1346 1304 if( is_wp_error( $response ) ) { 1347 1305 $errorMessage = $response->get_error_message(); 1348 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error] -----', 'critical' ); 1349 $this->writeLog( $errorMessage, 'critical' ); 1306 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned wp_error] -----', ['err' => $errorMessage, 'response' => $response], 'critical' ); 1350 1307 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $id), 'error'); 1351 1308 return false; 1352 1309 }elseif( !isset( $response['body'] ) ) { 1353 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned no status] -----', 'warning' ); 1354 $this->writeLog( $response, 'warning' ); 1310 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [returned no status] -----', $response, 'warning' ); 1355 1311 wc_add_notice( __('Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful. Ref:' . $id), 'error'); 1356 1312 return false; 1357 1313 } 1358 //$this->shouldLogResponseHandler($response, $array);1359 1314 $responseResult = $response['body']; 1360 1315 $responseData = json_decode($responseResult); 1361 1316 $responseData = ( $secondaryCall === true ) ? ( isset($responseData->payments[0]) ? $responseData->payments[ ( count( $responseData->payments ) - 1 ) ] : new stdClass) : $responseData; 1362 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [final response data] -----', 'debug' ); 1363 $this->writeLog( ['header' => $array, 'response' => $responseData], 'info' ); 1317 $this->writeLog( '----- verifyTransactionStatusByIDOrOrderID [final response data] -----', $responseData, 'debug' ); 1364 1318 return $responseData; 1365 1319 } … … 1381 1335 $url = $this->proxyUrl; 1382 1336 } 1383 $this->writeLog('------------prepareRemoteRequest [preparing request from API] -----------','debug');1384 $this->writeLog($url,'debug');1385 1337 1386 1338 $response = wp_remote_request( $url , $array); 1339 $this->writeLog( '------------prepareRemoteRequest [preparing request from API] -----------', [ 1340 'url' => $url, 1341 'response' => $response, 1342 ], 'debug' ); 1387 1343 1388 1344 if( is_wp_error( $response ) ) { 1389 1345 $errorMessage = $response->get_error_message(); 1390 $this->writeLog( '----- prepareRemoteRequest [returned wp_error] -----', 'critical' ); 1391 $this->writeLog( $errorMessage, 'critical' ); 1392 $this->writeLog( $response, 'critical' ); 1393 } 1394 1395 $this->writeLog( ['request' => $array, 'response' => $response], 'info' ); 1396 1397 //$this->shouldLogResponseHandler($response, $array); 1398 1399 $responseData = json_decode($response['body']); 1400 //$this->writeLog( ['header' => $array, 'response' => $responseData], 'info' ); 1346 $this->writeLog( '----- prepareRemoteRequest [returned wp_error] -----', ['error' => $errorMessage], 'critical' ); 1347 } 1348 1349 $responseData = json_decode($response['body']); 1401 1350 return $responseData; 1402 1351 } … … 1457 1406 return $notes; 1458 1407 } 1459 1408 1460 1409 public function parseResponseData($responseData){ 1461 1410 global $woocommerce; 1462 1411 $debugTimeArray[0] = time(); 1463 1412 $array = ['notices'=>[]]; 1464 $this->writeLog('------parseResponseData ---------','debug'); 1465 $this->writeLog($responseData,'info'); 1413 $this->writeLog('------parseResponseData ---------', null,'debug'); 1466 1414 $paymentSuccess = false; 1467 1415 if(isset($responseData->id)){ 1468 $this->writeLog('------parseResponseData [response id valid]---------', 'debug');1416 $this->writeLog('------parseResponseData [response id valid]---------', null,'debug'); 1469 1417 $transaction_id = (string)$responseData->id; 1470 1418 if(isset($responseData->result->code)){ … … 1483 1431 $debugTimeArray[1] = time(); 1484 1432 $order = wc_get_order( $order_id ); 1485 $this->writeLog('------parseResponseData [order_details for orderid:'.$order_id.']---------','debug'); 1486 $this->writeLog($order,'info'); 1487 $this->writeLog('payment status code:' . $payment_result_code,'info'); 1433 $this->writeLog( '------parseResponseData [order_details for orderid:'.$order_id.']---------', [ 1434 'paymentstatuscode' => $payment_result_code 1435 ], 'debug' ); 1436 1488 1437 $amount = number_format($order->get_total(), 2, '.', ''); 1489 1438 $order_data = $order->get_data(); 1490 if($order_data['payment_method'] !== $this->id){1439 /*if($order_data['payment_method'] !== $this->id){ 1491 1440 $checks = false; 1492 1441 $array['notices'][] = 'payment_method not tpcards'; … … 1511 1460 $checks = false; 1512 1461 $array['notices'][] = 'Cart items/amount have changed, please retry paying for this order.'; 1513 } 1462 }*/ 1514 1463 if($checks){ 1515 1464 if($paymentSuccess === true){ 1516 $this->writeLog( '------parseResponseData [payment is successful] ---------','debug');1465 $this->writeLog( '------parseResponseData [payment is successful] ---------', null,'debug'); 1517 1466 //good to go.. 1518 1467 $order->payment_complete( $transaction_id ); 1519 $this->writeLog('------parseResponseData [set order with payment complete] ---------', 'debug');1468 $this->writeLog('------parseResponseData [set order with payment complete] ---------', null,'debug'); 1520 1469 $debugTimeArray[2] = time(); 1521 1470 //if PA// capture … … 1536 1485 } 1537 1486 $order->save(); 1538 $this->writeLog('------parseResponseData [order updated after all set of data] ---------', 'debug');1487 $this->writeLog('------parseResponseData [order updated after all set of data] ---------', null,'debug'); 1539 1488 $debugTimeArray[6] = time(); 1540 1489 $array['result'] = 'success'; 1541 1490 $array['redirect'] = $this->get_return_url( $order ); 1542 1491 $debugTimeArray[7] = time(); 1492 $cartHash = WC()->cart->get_cart_hash(); 1543 1493 $woocommerce->cart->empty_cart(); 1544 1494 $debugTimeArray[8] = time(); 1545 $this->writeLog('------------parseResponseData [paymentsuccess] ---------','debug'); 1546 $this->writeLog($debugTimeArray,'info'); 1495 $this->writeLog('------------parseResponseData [paymentsuccess] ---------', $debugTimeArray,'debug', $cartHash); 1547 1496 } else { 1548 $this->writeLog('------parseResponseData [payment not success] ---------','debug'); 1549 $this->writeLog(['code' => $code, 'description' => $description],'info'); 1497 $this->writeLog('------parseResponseData [payment not success] ---------', ['code' => $code, 'description' => $description, 'checks' => $array],'debug'); 1550 1498 $order->add_order_note( $code, false ); 1551 1499 $order->add_order_note( $description, false ); … … 1559 1507 if( $paymentSuccess === true ){ 1560 1508 $array['notices'][] = 'Payment is successful, but due to some error we can not process further. Please contact support with payment reference ' . $responseData->id; 1509 $this->writeLog('------parseResponseData [payment success, but after payment check failed] ---------', ['checks' => $array],'debug'); 1561 1510 }else{ 1562 1511 $array['notices'][] = 'Payment failed'; 1512 $this->writeLog('------parseResponseData [payment failed and after payment check failed] ---------', ['checks' => $array],'debug'); 1563 1513 } 1564 1514 $array['notices'][] = 'checks failed.'; … … 1567 1517 $array['notices'][] = 'No order_id found, please retry payment.'; 1568 1518 //perform reversal on $paymentSuccess && $responseData->id 1569 $this->writeLog('----------parseResponseData [no order id found] ----------','debug'); 1570 $this->writeLog($array['notices'],'info'); 1519 $this->writeLog('----------parseResponseData [no order id found / merchantTransactionId not found] ----------', ['checks' => $array],'debug'); 1571 1520 } 1572 1521 } else { 1573 1522 $array['notices'][] = 'No transaction id found, please retry payment.'; 1574 $this->writeLog('----------parseResponseData no transaction id found------------','critical'); 1575 $this->writeLog($array['notices'],'critical'); 1576 } 1577 $this->writeLog($array,'info'); 1523 $this->writeLog('----------parseResponseData no transaction id found------------', ['checks' => $array],'critical'); 1524 } 1578 1525 wc_clear_notices(); 1579 1526 foreach($array['notices'] as $notice){ … … 1683 1630 public function process_payment($order_id){ 1684 1631 //first write to log if set. 1685 $this->writeLog('-----------process_payment [POST] -----------', 'debug'); 1686 $this->writeLog($_POST,'info'); 1632 $this->writeLog('-----------process_payment [POST initiated] -----------', null, 'debug'); 1687 1633 1688 1634 //check the order_id exists. 1689 1635 $order = wc_get_order($order_id); 1690 1636 if($order===false){ 1691 $this->writeLog('-----------process_payment [Order does not exists]-----------', 'debug');1637 $this->writeLog('-----------process_payment [Order does not exists]-----------', null, 'debug'); 1692 1638 wc_add_notice('There was a problem creating your order, please try again.', 'error'); 1693 1639 return; … … 1704 1650 if(!isset($handler['pending'])){ 1705 1651 if(isset($handler['messages'])){ 1706 $this->writeLog('-----------process_payment [pending order has message issue]------------', 'debug');1652 $this->writeLog('-----------process_payment [pending order has message issue]------------', null,'debug'); 1707 1653 foreach($handler['messages'] as $noticeType => $noticeItems){ 1708 1654 foreach($noticeItems as $notice){ … … 1711 1657 } 1712 1658 } 1713 $this->writeLog('-----------process_payment [if pending order does not have message] ----------','debug'); 1714 $this->writeLog($handler,'info'); 1659 $this->writeLog('-----------process_payment [if pending order does not have message] ----------', $handler,'debug'); 1715 1660 return $handler; 1716 1661 } … … 1726 1671 } 1727 1672 $additionalParams['shopperResultUrl'] = $shopperResultUrl; 1728 $this->writeLog('-----------process_payment [shopperResultUrl as additionalParameters] ----------','debug'); 1729 $this->writeLog($additionalParams,'info'); 1673 $this->writeLog('-----------process_payment [shopperResultUrl as additionalParameters] ----------', $additionalParams,'debug'); 1730 1674 1731 1675 //check for RG slick … … 1748 1692 } 1749 1693 if($checkoutId === false){ 1750 $this->writeLog('-----------process_payment [checkout id missing and create new checkout id] -----------', 'debug');1694 $this->writeLog('-----------process_payment [checkout id missing and create new checkout id] -----------', null,'debug'); 1751 1695 $checkoutId = $this->createCheckoutArray(false,false,$registrationId); 1752 1696 } … … 1755 1699 $handler['uuid'] = $checkoutId; 1756 1700 $handler['pay_url'] = $order->get_checkout_payment_url( false ); 1757 $this->writeLog('-----------process_payment [checkout id not missing]----------', 'debug'); 1758 $this->writeLog($handler,'info'); 1701 $this->writeLog('-----------process_payment [checkout id not missing]----------', null, 'debug'); 1759 1702 } else { 1760 $this->writeLog('-----------process_payment [still checkoutid missing]-----------', 'debug');1703 $this->writeLog('-----------process_payment [still checkoutid missing]-----------', null,'debug'); 1761 1704 wc_add_notice($responseUpdate->result->description, 'error'); 1762 1705 $handler['refresh'] = true; … … 1779 1722 $checkoutJson = json_encode($payload); 1780 1723 1781 $this->writeLog('-----------process_payment [after payload is prepared]----------','debug'); 1782 $this->writeLog($payload,'info'); 1724 $this->writeLog('-----------process_payment [after payload is prepared]----------', $payload,'debug'); 1783 1725 1784 1726 if($this->jsLogging === true){ … … 1791 1733 $handler['responseUpdate'] = $responseUpdate; 1792 1734 } 1793 $this->writeLog('----------process_payment [after transaction data updated]--------','debug'); 1794 $this->writeLog($responseUpdate,'info'); 1735 $this->writeLog('----------process_payment [after transaction data updated]--------', $responseUpdate,'debug'); 1795 1736 if(isset($responseUpdate->result->code)){ 1796 1737 $checkoutCode = $responseUpdate->result->code; … … 1800 1741 } else { 1801 1742 if($updateCheckout === true){ 1802 $this->writeLog('-------process_payment [successfully transaction data updated on successfull payment]---------', 'debug');1743 $this->writeLog('-------process_payment [successfully transaction data updated on successfull payment]---------', null,'debug'); 1803 1744 $handler['execute'] = true; 1804 1745 } else { … … 1807 1748 } 1808 1749 } else { 1809 $this->writeLog('-------process_payment [Could not update checkout]---------', 'debug');1750 $this->writeLog('-------process_payment [Could not update checkout]---------', null,'debug'); 1810 1751 wc_add_notice('Could not update checkout', 'error'); 1811 1752 $handler['refresh']=true; … … 1816 1757 $handler['sqlRes'] = $this->insTxDbRecord($order_data,$this->platformBase,$checkoutId,$checkoutCode,$checkoutJson); 1817 1758 1818 $this->writeLog('---------process_payment [insTxDbRecord called] -----------','debug'); 1819 $this->writeLog($handler,'info'); 1759 $this->writeLog('---------process_payment [insTxDbRecord called] -----------', $handler,'debug'); 1820 1760 1821 1761 return $handler; -
totalprocessing-card-payments/trunk/includes/tp-payment-gateway-helper-trait.php
r2862579 r2900759 335 335 $order->save(); 336 336 } 337 338 protected function writeLog( $ obj, $level = false){337 338 protected function writeLog( $label, $obj, $level = false, $uuid = null ){ 339 339 $debug = $this->get_option( 'serversidedebug' ); 340 340 if( $debug != 'yes' ){ … … 345 345 return; 346 346 } 347 348 $logger = wc_get_logger(); 349 347 348 $logger = wc_get_logger(); 349 $GLOBALS['logcounter'] = isset( $GLOBALS['logcounter'] ) ? $GLOBALS['logcounter'] + 1 : 1; 350 350 351 $context = array( 'source' => TP_CONSTANTS::GATEWAY_ID ); 352 $cartHash = !empty( $uuid ) ? $uuid : WC()->cart->get_cart_hash(); 353 $logMessage = '['.$cartHash.'] Stack #' . $GLOBALS['logcounter'] . " : " . $label . ( $obj != null ? "\n" . wc_print_r( $obj, true ) : '' ); 351 354 352 355 switch ( $level ) { 353 356 case 'critical': 354 $logger->critical( wc_print_r( $obj , true ), $context );357 $logger->critical( $logMessage, $context ); 355 358 break; 356 359 case 'debug': 357 $logger->debug( wc_print_r( $obj , true ), $context );360 $logger->debug( $logMessage, $context ); 358 361 break; 359 362 case 'emergency': 360 $logger->emergency( wc_print_r( $obj , true ), $context );363 $logger->emergency( $logMessage, $context ); 361 364 break; 362 365 case 'error': 363 $logger->error( wc_print_r( $obj , true ), $context );366 $logger->error( $logMessage, $context ); 364 367 break; 365 368 case 'warning': 366 $logger->warning( wc_print_r( $obj , true ), $context );369 $logger->warning( $logMessage, $context ); 367 370 break; 368 371 default: 369 $logger->info( wc_print_r( $obj , true ), $context );370 } 371 372 $logger->info( $logMessage, $context ); 373 } 374 372 375 return true; 373 376 } -
totalprocessing-card-payments/trunk/readme.txt
r2888976 r2900759 4 4 Requires at least: 5.2.0 5 5 Tested up to: 6.1.1 6 Stable tag: 5.3. 26 Stable tag: 5.3.3 7 7 Requires PHP: 7.0 8 8 License: GPLv3 … … 48 48 == Changelog == 49 49 50 = 5.3.3 - 18-04-2023 19:30 = 51 52 * Optimized log system 53 * removed unwanted validations 54 50 55 = 5.3.2 - 29-03-2023 14:00 = 51 56 -
totalprocessing-card-payments/trunk/totalprocessing-card-payments-and-gateway-woocommerce.php
r2888976 r2900759 10 10 * Plugin URI: https://www.totalprocessing.com/woocommerce/cards 11 11 * Description: Accept all major credit and debit cards. Fast, seamless, and flexible. 12 * Version: 5.3. 212 * Version: 5.3.3 13 13 * Author: Total Processing Limited 14 14 * Copyright: 2022 Total Processing Limited.
Note: See TracChangeset
for help on using the changeset viewer.