Changeset 3031381
- Timestamp:
- 02/05/2024 07:50:12 AM (2 years ago)
- Location:
- twispay/trunk
- Files:
-
- 10 edited
-
helpers/Twispay_TW_Helper_Response.php (modified) (2 diffs)
-
helpers/Twispay_TW_Status_Updater.php (modified) (17 diffs)
-
includes/admin/transaction/requests.php (modified) (1 diff)
-
includes/admin/transaction/transaction.php (modified) (1 diff)
-
includes/class-tw-server-to-server.php (modified) (3 diffs)
-
includes/scripts.php (modified) (3 diffs)
-
lang/en/lang.php (modified) (1 diff)
-
lang/ro/lang.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
twispay.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
twispay/trunk/helpers/Twispay_TW_Helper_Response.php
r2997774 r3031381 64 64 65 65 /** Check if the decryption was successful. */ 66 if (NULL === $decodedResponse) {66 if (NULL === $decodedResponse) { 67 67 /** Log the last error occurred during the last JSON encoding/decoding. */ 68 68 switch (json_last_error()) { 69 69 case JSON_ERROR_DEPTH: 70 70 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_DEPTH']); 71 break;71 break; 72 72 73 73 case JSON_ERROR_STATE_MISMATCH: 74 74 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_STATE_MISMATCH']); 75 break;75 break; 76 76 77 77 case JSON_ERROR_CTRL_CHAR: 78 78 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_CTRL_CHAR']); 79 break;79 break; 80 80 81 81 case JSON_ERROR_SYNTAX: 82 82 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_SYNTAX']); 83 break;83 break; 84 84 85 85 case JSON_ERROR_UTF8: 86 86 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_UTF8']); 87 break;87 break; 88 88 89 89 case JSON_ERROR_RECURSION: 90 90 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_RECURSION']); 91 break;91 break; 92 92 93 93 case JSON_ERROR_INF_OR_NAN: 94 94 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_INF_OR_NAN']); 95 break;95 break; 96 96 97 97 case JSON_ERROR_UNSUPPORTED_TYPE: 98 98 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_UNSUPPORTED_TYPE']); 99 break;99 break; 100 100 101 101 case JSON_ERROR_INVALID_PROPERTY_NAME: 102 102 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_INVALID_PROPERTY_NAME']); 103 break;103 break; 104 104 105 105 case JSON_ERROR_UTF16: 106 106 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_UTF16']); 107 break;107 break; 108 108 109 109 default: 110 110 Twispay_TW_Logger::twispay_tw_log($tw_lang['JSON_ERROR_UNKNOWN']); 111 break;111 break; 112 112 } 113 113 … … 136 136 137 137 if ( empty( $tw_response['status'] ) && empty( $tw_response['transactionStatus'] ) ) { 138 $tw_errors[] = $tw_lang['log_error_empty_status'];138 $tw_errors[] = $tw_lang['log_error_empty_status']; 139 139 } 140 140 -
twispay/trunk/helpers/Twispay_TW_Status_Updater.php
r3030007 r3031381 26 26 /* Array containing the possible result statuses. */ 27 27 public static $RESULT_STATUSES = [ 28 'UNCERTAIN' => 'uncertain' /* No response from provider */28 'UNCERTAIN' => 'uncertain' /* No response from provider */ 29 29 , 'IN_PROGRESS' => 'in-progress' /* Authorized */ 30 30 , 'COMPLETE_OK' => 'complete-ok' /* Captured */ … … 97 97 </div> 98 98 <?php 99 break;99 break; 100 100 101 101 case Twispay_TW_Status_Updater::$RESULT_STATUSES['THREE_D_PENDING']: … … 131 131 </div> 132 132 <?php 133 break;133 break; 134 134 135 135 case Twispay_TW_Status_Updater::$RESULT_STATUSES['IN_PROGRESS']: … … 139 139 if(class_exists('WC_Subscriptions') && wcs_order_contains_subscription($order)){ 140 140 141 $subscription = wcs_get_subscriptions_for_order($order);142 $subscription = reset($subscription);143 144 /* First payment on order, process payment & activate subscription. */145 if ( 0 == $subscription->get_payment_count() ) {146 147 $order->payment_complete();148 149 if(class_exists('WC_Subscriptions') ){150 WC_Subscriptions_Manager::activate_subscriptions_for_order( $order );151 }152 } else {153 if(class_exists('WC_Subscriptions') ){154 WC_Subscriptions_Manager::process_subscription_payments_on_order( $order );155 }156 }157 141 $subscription = wcs_get_subscriptions_for_order($order); 142 $subscription = reset($subscription); 143 144 /* First payment on order, process payment & activate subscription. */ 145 if ( 0 == $subscription->get_payment_count() ) { 146 147 $order->payment_complete(); 148 149 if(class_exists('WC_Subscriptions') ){ 150 WC_Subscriptions_Manager::activate_subscriptions_for_order( $order ); 151 } 152 } else { 153 if(class_exists('WC_Subscriptions') ){ 154 WC_Subscriptions_Manager::process_subscription_payments_on_order( $order ); 155 } 156 } 157 158 158 } 159 159 try { 160 160 global $wpdb; 161 $query = $wpdb->prepare(162 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s",163 $decrypted['transactionId']161 $query = $wpdb->prepare( 162 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s", 163 $decrypted['transactionId'] 164 164 ); 165 165 166 166 // Execute the query 167 167 $item_count = (int) $wpdb->get_var( $query ); 168 169 // Check if the transaction already exists 168 169 // Check if the transaction already exists 170 170 if ($item_count == 0) { 171 $wpdb->get_results( 171 $wpdb->get_results( 172 172 $wpdb->prepare( " 173 173 INSERT INTO `" . $wpdb->prefix . "twispay_tw_transactions` ( … … 189 189 '%d', 190 190 '%s' 191 );", 192 'complete-ok',193 $order->get_id(),194 $order->get_customer_id(),195 $decrypted['orderId'],196 $decrypted['transactionId'],197 $decrypted['customerId'],198 $decrypted['cardId'],199 $checkout_url )200 );201 Twispay_TW_Logger::twispay_tw_log("Correspondence between twispay transaction and woocommerce order saved in database: orderID: $orderId, transactionID: {$decrypted['transactionId']}, customerID: {$decrypted['customerId']}, cardID: {$decrypted['cardId']}" );202 } else {203 $wpdb->query(204 $wpdb->prepare(205 "UPDATE `" . $wpdb->prefix . "twispay_tw_transactions`191 );", 192 $serverStatus, 193 $order->get_id(), 194 $order->get_customer_id(), 195 $decrypted['orderId'], 196 $decrypted['transactionId'], 197 $decrypted['customerId'], 198 $decrypted['cardId'], 199 $checkout_url ) 200 ); 201 Twispay_TW_Logger::twispay_tw_log("Correspondence between twispay transaction and woocommerce order saved in database: orderID: $orderId, transactionID: {$decrypted['transactionId']}, customerID: {$decrypted['customerId']}, cardID: {$decrypted['cardId']}" ); 202 } else { 203 $wpdb->query( 204 $wpdb->prepare( 205 "UPDATE `" . $wpdb->prefix . "twispay_tw_transactions` 206 206 SET `checkout_url` = %s 207 207 WHERE `transactionId` = %d", 208 $checkout_url,209 $decrypted['transactionId']210 )211 );212 Twispay_TW_Logger::twispay_tw_log("CheckoutURL updated:" . $checkout_url);213 }208 $checkout_url, 209 $decrypted['transactionId'] 210 ) 211 ); 212 Twispay_TW_Logger::twispay_tw_log("CheckoutURL updated:" . $checkout_url); 213 } 214 214 } catch(Throwable | Exception $e) { 215 215 Twispay_TW_Logger::twispay_tw_log("Exception while trying to register transaction: " . $e->getMessage() . " <> " . $e->getTraceAsString()); … … 224 224 new Twispay_TW_Default_Thankyou( $order ); 225 225 } 226 break;226 break; 227 227 228 228 default: … … 260 260 </div> 261 261 <?php 262 break;262 break; 263 263 } 264 264 } … … 287 287 288 288 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_ok_status_failed'] . $orderId); 289 break;289 break; 290 290 291 291 case Twispay_TW_Status_Updater::$RESULT_STATUSES['CANCEL_OK']: … … 301 301 302 302 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_ok_status_refund'] . $orderId); 303 break;303 break; 304 304 305 305 case Twispay_TW_Status_Updater::$RESULT_STATUSES['THREE_D_PENDING']: … … 308 308 309 309 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_ok_status_hold'] . $orderId); 310 break;310 break; 311 311 312 312 case Twispay_TW_Status_Updater::$RESULT_STATUSES['IN_PROGRESS']: … … 317 317 318 318 if(class_exists('WC_Subscriptions') && wcs_order_contains_subscription($order)){ 319 $subscription = wcs_get_subscriptions_for_order($order); 320 $subscription = reset($subscription); 321 322 /* First payment on order, process payment & activate subscription. */ 323 if ( 0 == $subscription->get_payment_count() ) { 324 $order->payment_complete(); 325 $order->update_status('completed', esc_html__( $tw_lang['wa_order_complete_ok'], 'woocommerce' )); 326 327 if(class_exists('WC_Subscriptions') ){ 328 WC_Subscriptions_Manager::activate_subscriptions_for_order( $order ); 329 } 330 } else { 331 if(class_exists('WC_Subscriptions') ){ 332 WC_Subscriptions_Manager::process_subscription_payments_on_order( $order ); 333 } 319 $subscription = wcs_get_subscriptions_for_order($order); 320 $subscription = reset($subscription); 321 322 /* First payment on order, process payment & activate subscription. */ 323 if ( 0 == $subscription->get_payment_count() ) { 324 $order->payment_complete(); 325 $order->update_status('completed', esc_html__( $tw_lang['wa_order_complete_ok'], 'woocommerce' )); 326 327 if(class_exists('WC_Subscriptions') ){ 328 WC_Subscriptions_Manager::activate_subscriptions_for_order( $order ); 329 } 330 } else { 331 if(class_exists('WC_Subscriptions') ){ 332 WC_Subscriptions_Manager::process_subscription_payments_on_order( $order ); 334 333 } 335 334 } 335 336 336 337 337 } else { 338 338 try { 339 339 global $wpdb; 340 $query = $wpdb->prepare(341 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s",342 $decrypted['transactionId']343 );344 345 // Execute the query346 $item_count = (int) $wpdb->get_var( $query );347 348 // Check if the transaction already exists349 if ($item_count == 0) {350 $wpdb->get_results(351 $wpdb->prepare( "340 $query = $wpdb->prepare( 341 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s", 342 $decrypted['transactionId'] 343 ); 344 345 // Execute the query 346 $item_count = (int) $wpdb->get_var( $query ); 347 348 // Check if the transaction already exists 349 if ($item_count == 0) { 350 $wpdb->get_results( 351 $wpdb->prepare( " 352 352 INSERT INTO `" . $wpdb->prefix . "twispay_tw_transactions` ( 353 353 `status`, … … 368 368 '%d', 369 369 '%s' 370 );", 371 'complete-ok',372 $order->get_id(),373 $order->get_customer_id(),374 $decrypted['orderId'],375 $decrypted['transactionId'],376 $decrypted['customerId'],377 $decrypted['cardId'],378 "" )379 );380 Twispay_TW_Logger::twispay_tw_log("Correspondence between twispay transaction and woocommerce order saved in database: orderID: $orderId, transactionID: {$decrypted['transactionId']}, customerID: {$decrypted['customerId']}, cardID: {$decrypted['cardId']}" );381 }370 );", 371 $serverStatus, 372 $order->get_id(), 373 $order->get_customer_id(), 374 $decrypted['orderId'], 375 $decrypted['transactionId'], 376 $decrypted['customerId'], 377 $decrypted['cardId'], 378 "" ) 379 ); 380 Twispay_TW_Logger::twispay_tw_log("Correspondence between twispay transaction and woocommerce order saved in database: orderID: $orderId, transactionID: {$decrypted['transactionId']}, customerID: {$decrypted['customerId']}, cardID: {$decrypted['cardId']}" ); 381 } 382 382 } catch(Throwable | Exception $e) { 383 383 Twispay_TW_Logger::twispay_tw_log("Exception while trying to register transaction: " . $e->getMessage() . " <> " . $e->getTraceAsString()); … … 386 386 387 387 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_ok_status_complete'] . $orderId); 388 break;388 break; 389 389 390 390 default: 391 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_wrong_status'] . $serverStatus);392 break;391 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_wrong_status'] . $serverStatus); 392 break; 393 393 } 394 394 } … … 396 396 397 397 /** 398 * Update the status of an Woocommerce subscription according to the received server status.399 *400 * @param orderId: The ID of the order that is the parent of the subscription.401 * @param serverStatus: The status received from server.402 * @param tw_lang: The array of available messages.403 *404 * @return void405 */398 * Update the status of an Woocommerce subscription according to the received server status. 399 * 400 * @param orderId: The ID of the order that is the parent of the subscription. 401 * @param serverStatus: The status received from server. 402 * @param tw_lang: The array of available messages. 403 * 404 * @return void 405 */ 406 406 public static function updateSubscriptionStatus($orderId, $serverStatus, $tw_lang){ 407 407 /* Check that the subscriptions plugin is installed. */ 408 408 if(!class_exists('WC_Subscriptions') ){ 409 return;409 return; 410 410 } 411 411 … … 424 424 Twispay_TW_Logger::twispay_tw_updateTransactionStatus($orderId, $serverStatus); 425 425 } 426 break;426 break; 427 427 428 428 case Twispay_TW_Status_Updater::$RESULT_STATUSES['COMPLETE_OK']: /* The subscription has been completed. */ … … 436 436 Twispay_TW_Logger::twispay_tw_updateTransactionStatus($orderId, $serverStatus); 437 437 } 438 break;438 break; 439 439 440 440 case Twispay_TW_Status_Updater::$RESULT_STATUSES['EXPIRING']: /* The subscription will expire soon. */ … … 445 445 Twispay_TW_Logger::twispay_tw_updateTransactionStatus($orderId, $serverStatus); 446 446 } 447 break;447 break; 448 448 449 449 default: 450 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_wrong_status'] . $serverStatus);451 break;450 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_wrong_status'] . $serverStatus); 451 break; 452 452 } 453 453 } -
twispay/trunk/includes/admin/transaction/requests.php
r2627254 r3031381 195 195 } 196 196 add_action( 'tw_synchronize_subscriptions', 'tw_twispay_p_synchronize_subscriptions' ); 197 198 199 function tw_twispay_p_synchronize_transactions( $request ) { 200 $orders = []; 201 global $wpdb; 202 $apiKey = ''; 203 $configuration = $wpdb->get_row( "SELECT * FROM " . $wpdb->prefix . "twispay_tw_configuration" ); 204 205 if ( $configuration ) { 206 if ( $configuration->live_mode == 1 ) { 207 $apiKey = sanitize_text_field( $configuration->live_key ); 208 $baseUrl = 'https://api.twispay.com/order?createdAtFrom=2024-01-29T00%3A00%3A00%2B00%3A00&reverseSorting=0'; 209 } else if ( $configuration->live_mode == 0 ) { 210 $apiKey = sanitize_text_field( $configuration->staging_key ); 211 $baseUrl = 'https://api-stage.twispay.com/order?createdAtFrom=2024-01-29T00%3A00%3A00%2B00%3A00&reverseSorting=0'; 212 } 213 } 214 215 216 /* Load languages. */ 217 $lang = explode( '-', get_bloginfo( 'language' ) )[0]; 218 if ( file_exists( TWISPAY_PLUGIN_DIR . 'lang/' . $lang . '/lang.php' ) ) { 219 require( TWISPAY_PLUGIN_DIR . 'lang/' . $lang . '/lang.php' ); 220 } else { 221 require( TWISPAY_PLUGIN_DIR . 'lang/en/lang.php' ); 222 } 223 224 /* Execute the request. This means to perform a "GET"/"PUT" request at the specified URL. */ 225 $args = array('method' => 'GET', 'headers' => ['accept' => 'application/json', 'Authorization' => $apiKey]); 226 $response = wp_remote_request( $baseUrl, $args ); 227 228 if( FALSE === $response ) { 229 Twispay_TW_Logger::twispay_tw_log( $tw_lang['subscriptions_log_error_call_failed'] . WP_Error::get_error_message() ); 230 $skip = TRUE; 231 } 232 $response = json_decode($response['body']); 233 234 if ( 'Success' == $response->message ) { 235 if ($response->pagination->currentItemCount) { 236 foreach ($response->data as $order) { 237 $orders[$order->id]['externalOrderId'] = $order->externalOrderId; 238 } 239 } 240 } 241 242 if ( $configuration ) { 243 if ( $configuration->live_mode == 1 ) { 244 $apiKey = sanitize_text_field( $configuration->live_key ); 245 $baseUrl = 'https://api.twispay.com/transaction?createdAtFrom=2024-01-29T00%3A00%3A00%2B00%3A00&reverseSorting=0'; 246 } else if ( $configuration->live_mode == 0 ) { 247 $apiKey = sanitize_text_field( $configuration->staging_key ); 248 $baseUrl = 'https://api-stage.twispay.com/transaction?createdAtFrom=2024-01-29T00%3A00%3A00%2B00%3A00&reverseSorting=0'; 249 } 250 } 251 252 /* Execute the request. This means to perform a "GET"/"PUT" request at the specified URL. */ 253 $args = array('method' => 'GET', 'headers' => ['accept' => 'application/json', 'Authorization' => $apiKey]); 254 $response = wp_remote_request( $baseUrl, $args ); 255 256 257 if( FALSE === $response ) { 258 Twispay_TW_Logger::twispay_tw_log( $tw_lang['subscriptions_log_error_call_failed'] . WP_Error::get_error_message() ); 259 $skip = TRUE; 260 } 261 262 $response = json_decode($response['body']); 263 264 if ( 'Success' == $response->message ) { 265 if ($response->pagination->currentItemCount) { 266 foreach ($response->data as $transaction) { 267 if (isset($orders[$transaction->orderId])) { 268 if (isset($orders[$transaction->orderId]['transactionId']) && $transaction->id < $orders[$transaction->orderId]['transactionId']) { 269 continue; 270 } 271 $orders[$transaction->orderId]['transactionId'] = $transaction->id; 272 $orders[$transaction->orderId]['cardId'] = $transaction->cardId; 273 $orders[$transaction->orderId]['status'] = $transaction->transactionStatus; 274 } 275 } 276 } 277 } 278 279 foreach ($orders as $orderId => $details) { 280 if (!isset($details['status'])) { 281 Twispay_TW_Logger::twispay_tw_log("Error: Status not found for orderId=$orderId"); 282 continue; 283 } 284 if (!isset($details['externalOrderId'])) { 285 Twispay_TW_Logger::twispay_tw_log("Error: externalOrderId not found for orderId=$orderId"); 286 continue; 287 } 288 if (!isset($details['transactionId'])) { 289 Twispay_TW_Logger::twispay_tw_log("Error: transactionId not found for orderId=$orderId"); 290 continue; 291 } 292 if (!isset($details['cardId'])) { 293 Twispay_TW_Logger::twispay_tw_log("Error: cardId not found for orderId=$orderId"); 294 continue; 295 } 296 // echo "Successfully added woocommerce order no. " . $details['externalOrderId'] . " with status: " . $details['status'] . " and transactionId: " . $details['transactionId'];die; 297 global $wpdb; 298 $query = $wpdb->prepare( 299 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s", 300 $details['transactionId'] 301 ); 302 303 // Execute the query 304 $item_count = (int) $wpdb->get_var( $query ); 305 306 // Check if the transaction already exists 307 if ($item_count == 0) { 308 $wcOrder = wc_get_order($details['externalOrderId']); 309 if (false == $wcOrder) { 310 Twispay_TW_Logger::twispay_tw_log("Invalid externalOrderId: " . $details['orderId'] . ". Transaction has been skipped."); 311 continue; 312 } 313 $wcCustomerId = $wcOrder->get_customer_id(); 314 if (false == $wcCustomerId) { 315 Twispay_TW_Logger::twispay_tw_log("Invalid wcCustomerId. Transaction has been skipped."); 316 continue; 317 } 318 try { 319 $wpdb->get_results( 320 $wpdb->prepare( " 321 INSERT INTO `" . $wpdb->prefix . "twispay_tw_transactions` ( 322 `status`, 323 `id_cart`, 324 `identifier`, 325 `orderId`, 326 `transactionId`, 327 `customerId`, 328 `cardId`, 329 `checkout_url` 330 ) VALUES ( 331 '%s', 332 '%s', 333 '%s', 334 '%d', 335 '%d', 336 '%d', 337 '%d', 338 '%s' 339 );", 340 $details['status'], 341 $details['externalOrderId'], 342 $wcCustomerId, 343 $details['externalOrderId'], 344 $details['transactionId'], 345 $wcCustomerId, 346 $details['cardId'], 347 "" ) 348 ); 349 } catch (Throwable | Exception $e) { 350 Twispay_TW_Logger::twispay_tw_log("Failed to add woocommerce order no. " . $details['externalOrderId'] . " with status " . $details['status'] . " and transactionId: " . $details['transactionId'] . " due to error " . $e->getMessage()); 351 } 352 353 354 Twispay_TW_Logger::twispay_tw_log("Successfully added woocommerce order no. " . $details['externalOrderId'] . " with status " . $details['status'] . " and transactionId: " . $details['transactionId']); 355 } 356 } 357 358 } 359 360 add_action( 'tw_synchronize_transactions', 'tw_twispay_p_synchronize_transactions'); -
twispay/trunk/includes/admin/transaction/transaction.php
r2627254 r3031381 69 69 </form> 70 70 <?php } ?> 71 72 <form method="post" id="synchronize_transactions"> 73 <table class="form-table"> 74 <tr class="form-field" id="contact_email_o"> 75 <th scope="row"><label><?= esc_html( $tw_lang['transactions_sync_label'] ); ?></span></label></th> 76 <td> 77 <input type="hidden" name="tw_general_action" value="synchronize_transactions" /> 78 <?php submit_button( esc_attr( $tw_lang['transactions_sync_button'] ), 'primary', 'createuser', true, array( 'id' => 'synchronizetransactions' ) ); ?> 79 <p class="description"><?= esc_html( $tw_lang['transactions_sync_desc'] ); ?></p> 80 </td> 81 </tr> 82 </table> 83 </form> 71 84 72 85 -
twispay/trunk/includes/class-tw-server-to-server.php
r3030007 r3031381 26 26 } 27 27 28 /** @var array $tw_lang */28 /** @var array $tw_lang */ 29 29 30 30 // Check if the POST is corrupted: doesn't contain the 'opensslResult' and the 'result' fields. 31 31 if (isset($_POST['opensslResult']) === false && isset($_POST['result']) === false) { 32 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_empty_response']);32 Twispay_TW_Logger::twispay_tw_log($tw_lang['log_error_empty_response']); 33 33 die($tw_lang['log_error_empty_response']); 34 34 } … … 70 70 71 71 // Prepare the query to prevent SQL injection 72 $query = $wpdb->prepare( 73 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s", 74 $transactionId 72 $query = $wpdb->prepare( 73 "SELECT COUNT(*) FROM {$wpdb->prefix}twispay_tw_transactions WHERE TransactionId = %s", 74 $transactionId 75 75 ); 76 76 77 77 // Execute the query 78 78 $item_count = (int) $wpdb->get_var( $query ); 79 79 80 // Check if the transaction already exists 80 // Check if the transaction already exists 81 81 //update order status and dont continue with new order 82 82 if ($item_count > 0) { … … 97 97 } 98 98 Twispay_TW_Status_Updater::updateStatus_IPN($order->get_id(), $status, $tw_lang, $decrypted); 99 99 100 100 // Send the 200 OK response back to the Twispay server. 101 101 die('OK'); -
twispay/trunk/includes/scripts.php
r3009867 r3031381 482 482 483 483 484 /**485 * Suppress email functionality486 */487 function twispay_tw_unhook_woo_order_emails( $email_class ) {488 return;489 // New order emails490 remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );491 remove_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );492 remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );493 remove_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );494 remove_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );495 remove_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );496 497 // Processing order emails498 remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );499 remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );500 501 // Completed order emails502 remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );503 }504 505 function twispay_tw_hook_woo_order_emails( $email_class ) {506 return;507 if (! has_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )) {508 add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );509 }510 511 if(! has_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )){512 add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );513 }514 515 if(! has_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )){516 add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );517 }518 519 if(! has_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )){520 add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );521 }522 523 if(! has_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )){524 add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );525 }526 527 if(! has_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) )){528 add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );529 }530 531 if(! has_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) )){532 add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );533 }534 535 if(! has_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) )){536 add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );537 }538 539 if(! has_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) )){540 add_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );541 }542 }543 544 // Get configuration from database545 global $wpdb;546 $suppress_email = $wpdb->get_row( "SELECT suppress_email FROM " . $wpdb->prefix . "twispay_tw_configuration" );547 548 //if ( $suppress_email ) {549 // if ( $suppress_email->suppress_email == 1 ) {550 // add_action( 'woocommerce_email', 'twispay_tw_unhook_woo_order_emails' );551 // } else {552 // add_action('woocommerce_email', 'twispay_tw_hook_woo_order_emails');553 // }554 //}555 556 557 558 484 function subscription_terminated( $subscription ){ 559 485 /* Get configuration from database. */ … … 567 493 ) 568 494 ); 495 569 496 if ( $configuration ) { 570 497 if ( $configuration->live_mode == 1 ) { … … 584 511 require( TWISPAY_PLUGIN_DIR . 'lang/en/lang.php' ); 585 512 } 586 587 513 $args = array( 'method' => 'DELETE' 588 514 , 'headers' => ['accept' => 'application/json', 'Authorization' => $apiKey]); 515 589 516 $response = wp_remote_request($url, $args); 590 517 -
twispay/trunk/lang/en/lang.php
r2923880 r3031381 160 160 $tw_lang['general_error_invalid_order'] = ' Order does not exist.'; 161 161 $tw_lang['general_error_invalid_private'] = ' Private key is not valid.'; 162 $tw_lang['transactions_sync_label'] = 'Update transactions list'; 163 $tw_lang['transactions_sync_desc'] = 'Updates the corespondence between twispay transactions and woocomerce orders.'; 164 $tw_lang['transactions_sync_button'] = 'Update'; 162 165 163 166 -
twispay/trunk/lang/ro/lang.php
r2923880 r3031381 160 160 $tw_lang['general_error_invalid_order'] = ' Comanda nu există.'; 161 161 $tw_lang['general_error_invalid_private'] = ' Cheie privată nevalidă.'; 162 $tw_lang['transactions_sync_label'] = 'Actualizeaza lista de tranzactii'; 163 $tw_lang['transactions_sync_desc'] = 'Actualizeaza corespondenta dintre tranzactiile twispay si comenzile woocommerce.'; 164 $tw_lang['transactions_sync_button'] = 'Actualizeaza'; 162 165 163 166 -
twispay/trunk/readme.txt
r3030007 r3031381 40 40 41 41 == Changelog == 42 43 = 2.0.17 = 44 * Add update transactions list button 42 45 43 46 = 2.0.15 = -
twispay/trunk/twispay.php
r3030007 r3031381 4 4 * Plugin URI: https://wordpress.org/plugins/twispay/ 5 5 * Description: Plugin for Twispay payment gateway. 6 * Version: 2.0.1 56 * Version: 2.0.17 7 7 * Author: twispay 8 8 * Author URI: https://www.twispay.com
Note: See TracChangeset
for help on using the changeset viewer.