razorpay / razorpay-woocommerce

Razorpay Payment Extension for Woocommerce
https://wordpress.org/plugins/woo-razorpay/
GNU General Public License v2.0
40 stars 30 forks source link

Square inventory sync fails when RazorPay is active. #452

Closed vikrampm1 closed 1 year ago

vikrampm1 commented 1 year ago

After a Checkout using the Square Payment Gateway, the inventory stock is reduced in WooCommerce and synced with Square using background processing. The stock is reduced in Woo using the woocommerce_checkout_order_processed hook and updated in Square, and woocommerce_update_product is used to pull the updated inventory back to Woo. But when RazorPay is active, this sequence is reversed. During Checkout, the stock in Woo is reduced but since woocommerce_update_product is triggered first, Woo Square fetches the unchanged stock from Square and resets it in Woo.

From the original issue:

Hello everyone,

I have investigated the behaviour between 5 payment gateways, in which some of them don't produce this issue.

Gateways with issue:

  1. Klarna
  2. Revolut
  3. RazorPay

Gateways without issue:

  1. Stripe
  2. COD
  3. Square itself

To understand the issue, it's important to understand how Woo Square syncs its inventory and the sequence as well.

This is why when you check stock in Woo immediately after Checkout using these gateways, you can see the stock reduced, but after a few seconds when woocommerce_update_product finishes, Woo product stock reverts back to the original count.

vikrampm1 commented 1 year ago

Issue resolved in Square with the introduction of new hooks in WooCommerce Core 7.6