Skip to content

Commit

Permalink
Merge pull request #268 from razorpay/1cc-webhook-fix
Browse files Browse the repository at this point in the history
1cc blank order issue fix through webhook
  • Loading branch information
ChetanGN authored May 12, 2022
2 parents 69e19fe + 8bd76a2 commit e17cd99
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
14 changes: 11 additions & 3 deletions includes/razorpay-webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,21 @@ protected function paymentAuthorized(array $data)

set_transient('webhook_trigger_count_for_' . $orderId, $triggerCount, 180);

$orderStatus = $order->get_status();
rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus");

// If it is already marked as paid, ignore the event
if ($order->needs_payment() === false) {
rzpLogInfo("Woocommerce orderId: $orderId webhook process exited");
if ($orderStatus != 'draft' && $order->needs_payment() === false) {
rzpLogInfo("Woocommerce orderId: $orderId webhook process exited with need payment status :". $order->needs_payment());

return;
}


if($orderStatus == 'draft')
{
updateOrderStatus($orderId, 'wc-pending');
}

$razorpayPaymentId = $data['payload']['payment']['entity']['id'];

$payment = $this->getPaymentEntity($razorpayPaymentId, $data);
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: razorpay
Tags: razorpay, payments, india, woocommerce, ecommerce
Requires at least: 3.9.2
Tested up to: 5.9
Stable tag: 3.5.0
Stable tag: 3.5.1
Requires PHP: 5.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -41,6 +41,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has

== Changelog ==

= 3.5.1 =
* Bug fix for magic checkout blank order issue.

= 3.5.0 =
* Feature Auto Enable webhook.
* Tested up to Woocommerce 6.4.1
Expand Down
6 changes: 3 additions & 3 deletions templates/rzp-pdp-checkout-btn.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class="button alt single_add_to_cart_button"

jQuery('.qty').on('change',function(e)
{
let i = 0;
let x = 0;
while (typeof quantity === 'undefined') {
var quantity = document.getElementsByClassName("qty")[i].value;
i++;
var quantity = document.getElementsByClassName("qty")[x].value;
x++;
}
btnPdp.setAttribute('quantity', quantity);

Expand Down
6 changes: 3 additions & 3 deletions woo-razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Plugin Name: Razorpay for WooCommerce
* Plugin URI: https://razorpay.com
* Description: Razorpay Payment Gateway Integration for WooCommerce
* Version: 3.5.0
* Stable tag: 3.5.0
* Version: 3.5.1
* Stable tag: 3.5.1
* Author: Team Razorpay
* WC tested up to: 6.4.1
* Author URI: https://razorpay.com
Expand Down Expand Up @@ -1280,7 +1280,7 @@ public function updateOrder(& $order, $success, $errorMessage, $razorpayPaymentI

rzpLogInfo("updateOrder orderId: $orderId , errorMessage: $errorMessage, razorpayPaymentId: $razorpayPaymentId , success: $success");

if (($success === true) and ($order->needs_payment() === true))
if ($success === true)
{
try
{
Expand Down

0 comments on commit e17cd99

Please sign in to comment.