Changeset 3282256
- Timestamp:
- 04/26/2025 06:10:58 AM (11 months ago)
- Location:
- woo-razorpay/trunk
- Files:
-
- 3 edited
-
includes/razorpay-webhook.php (modified) (17 diffs)
-
readme.txt (modified) (2 diffs)
-
woo-razorpay.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-razorpay/trunk/includes/razorpay-webhook.php
r3269687 r3282256 11 11 class RZP_Webhook 12 12 { 13 /**14 * @var HTTP CONFLICT Request15 */16 const HTTP_CONFLICT_STATUS = 409;17 18 /**19 * @var Webhook Notify Wait Time20 */21 const WEBHOOK_NOTIFY_WAIT_TIME = (5 * 60);22 23 13 /** 24 14 * Instance of the razorpay payments class … … 148 138 rzpLogError(json_encode($log)); 149 139 150 error_log(json_encode($log));151 140 return; 152 141 } … … 210 199 $integration = "woocommerce"; 211 200 212 $webhookEvents = $wpdb->get_results("SELECT rzp_webhook_data FROM $tableName where order_id=" . $data['woocommerce_order_number'] . " rzp_order_id=" . $rzpOrderId . ";");201 $webhookEvents = $wpdb->get_results("SELECT rzp_webhook_data FROM $tableName where order_id=" . $data['woocommerce_order_number'] . " AND rzp_order_id='" . $rzpOrderId . "';"); 213 202 214 203 $rzpWebhookData = (array) json_decode($webhookEvents['rzp_webhook_data']); … … 290 279 // We don't process subscription/invoice payments here 291 280 if (isset($data['invoice_id']) === true) { 281 rzpLogInfo("We don't process subscription/invoice payments here"); 292 282 return; 293 283 } … … 302 292 if (!empty($orderId)) { 303 293 $order = $this->checkIsObject($orderId); 294 295 if ($order === false) 296 { 297 return; 298 } 304 299 } 305 300 … … 323 318 324 319 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 320 321 if ($payment === false) 322 { 323 return; 324 } 325 325 326 326 $amount = $this->getOrderAmountAsInteger($order); … … 352 352 ); 353 353 354 error_log(json_encode($log));354 rzpLogError(json_encode($log)); 355 355 356 356 // … … 358 358 // 359 359 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 360 361 if ($payment === false) 362 { 363 return; 364 } 360 365 361 366 if ($payment['status'] === 'captured') { … … 395 400 if (!empty($orderId)) { 396 401 $order = $this->checkIsObject($orderId); 402 403 if ($order === false) 404 { 405 return; 406 } 397 407 } 398 408 … … 415 425 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 416 426 427 if ($payment === false) 428 { 429 return; 430 } 431 417 432 $success = false; 418 433 $errorMessage = 'The payment has failed.'; … … 448 463 if (!empty($orderId)) { 449 464 $order = $this->checkIsObject($orderId); 465 466 if ($order === false) 467 { 468 return; 469 } 450 470 } 451 471 // If it is already marked as paid, ignore the event … … 459 479 460 480 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 481 482 if ($payment === false) 483 { 484 return; 485 } 461 486 462 487 $amount = $this->getOrderAmountAsInteger($order); … … 495 520 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 496 521 522 if ($payment === false) 523 { 524 return; 525 } 526 497 527 if ($payment['status'] === 'captured') { 498 528 $success = true; … … 519 549 ); 520 550 521 error_log(json_encode($log));522 523 exit;551 rzpLogError(json_encode($log)); 552 553 return false; 524 554 } 525 555 … … 579 609 $payment = $this->getPaymentEntity($razorpayPaymentId, $data); 580 610 611 if ($payment === false) 612 { 613 return; 614 } 615 581 616 // 582 617 // Order entity should be sent as part of the webhook payload … … 586 621 if (!empty($orderId)) { 587 622 $order = $this->checkIsObject($orderId); 623 624 if ($order === false) 625 { 626 return; 627 } 588 628 } 589 629 … … 652 692 } else { 653 693 rzpLogInfo("Woocommerce order Object does not exist"); 654 exit();694 return false; 655 695 } 656 696 } -
woo-razorpay/trunk/readme.txt
r3269687 r3282256 3 3 Tags: razorpay, payments, india, woocommerce, curlec, malaysia, ecommerce, international, cross border 4 4 Requires at least: 3.9.2 5 Tested up to: 6. 76 Stable tag: 4.7. 25 Tested up to: 6.8 6 Stable tag: 4.7.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 69 69 70 70 == Changelog == 71 72 = 4.7.3 = 73 * Enhanced webhook cron. 71 74 72 75 = 4.7.2 = -
woo-razorpay/trunk/woo-razorpay.php
r3269687 r3282256 4 4 * Plugin URI: https://razorpay.com 5 5 * Description: Razorpay Payment Gateway Integration for WooCommerce.Razorpay Welcome Back Offer: New to Razorpay? Sign up to enjoy FREE payments* of INR 2 lakh till March 31st! Transact before January 10th to grab the offer. 6 * Version: 4.7. 27 * Stable tag: 4.7. 26 * Version: 4.7.3 7 * Stable tag: 4.7.3 8 8 * Author: Team Razorpay 9 9 * WC tested up to: 9.1.2 … … 3095 3095 3096 3096 /** 3097 * Create cron with 5 min interval 3098 **/ 3099 if (!wp_next_scheduled('rzp_webhook_exec_cron')) 3100 { 3101 wp_schedule_event(time(), 'rzp_webhook_cron_interval', 'rzp_webhook_exec_cron'); 3102 rzpLogInfo("rzp_webhook_exec_cron cron created"); 3103 } 3104 3105 /** 3097 3106 * Webhook Cron to execute events 3098 3107 **/ … … 3159 3168 $rzpWebhookSetup = get_option('rzp_webhook_setup'); 3160 3169 3161 if ( empty($rzpWebhookSetup) === true)3170 if (($rzpWebhookSetup === 'yes') === false) 3162 3171 { 3163 3172 try … … 3165 3174 // create table to save triggered webhook events 3166 3175 global $wpdb; 3167 3168 $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}rzp_webhook_requests` ( 3176 $tableName = $wpdb->prefix . 'rzp_webhook_requests'; 3177 3178 $sql = "CREATE TABLE IF NOT EXISTS $tableName ( 3169 3179 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, 3170 3180 `integration` varchar(25) NOT NULL, … … 3176 3186 PRIMARY KEY (`id`)) " . $wpdb->get_charset_collate() . ";"; 3177 3187 3178 // create cron with 5 min interval 3179 if (wp_next_scheduled('rzp_webhook_exec_cron') === false) 3180 { 3181 wp_schedule_event(time(), 'rzp_webhook_cron_interval', 'rzp_webhook_exec_cron'); 3182 } 3183 3184 if ((empty(dbDelta($sql)) === false) and 3185 (empty(wp_next_scheduled('rzp_webhook_exec_cron')) === false)) 3186 { 3187 update_option('rzp_webhook_setup', true); 3188 dbDelta($sql); 3189 3190 if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'" ) === $tableName) 3191 { 3192 update_option('rzp_webhook_setup', 'yes'); 3193 rzpLogInfo("Webhook table Created."); 3188 3194 } 3189 3195 } 3190 3196 catch (Exception $e) 3191 3197 { 3192 rzpLogInfo("Webhook table /croncreation failed: ". $e->getMessage());3198 rzpLogInfo("Webhook table creation failed: ". $e->getMessage()); 3193 3199 delete_option('rzp_webhook_setup'); 3194 3200 }
Note: See TracChangeset
for help on using the changeset viewer.