#2nd Webhook changes WooCommerce order status to Paid after Chargeback is processed

1 messages · Page 1 of 1 (latest)

wet knot
#

Currently, when a Chargeback is processed, for instance because for the DirectDebit payment, the customer did not have enough funds in his / her bank account, Mollie calls a Webhook to update the WooCommerce Order. The order status is changed from Processing to On hold. This is great and how we expect this to work.

But... exactly one minute later, a second Webhook is sent to WooCommerce. I suppose this 2nd Webhook is also coming from Mollie, but have not verified this 100% yet.

I did track how this 2nd Webhook moves through the code though by checking the logs and the source code.

These are the important parts of the log files of the second webhook:

onWebhookPaid called for payment 123
onWebhookPaid WooCommerce payment_complete() processed and returned to Mollie\WooCommerce\Payment\MolliePayment::onWebhookPaid for payment 123
onWebhookPaid processing paid payment via Mollie plugin fully completed for order 123

This leads to the Order satus to be changed from On Hold back to Processing, even though one minute ago we got a Webhook call telling us about a Chargeback.
Also an Order Note is being added to the WooCommerce order (translated from Dutch): Order status changed from On hold to Processing

As mentioned, i tracked the Webhook in the code as well. In mollie-payments-for-woocommerce\src\Payment\MollieOrderService.php in the public function onWebhookAction(), the Payment object is loaded from Mollie and should bypass the cache, see line 97:

// Load the payment from Mollie, do not use cache
try {
$payment_object = $this->paymentFactory->getPaymentObject($payment_object_id);
}

But the $payment->status is 'paid', this is wrong since the order was just Charged back one minute ago.

My guess is $this->paymentFactory->getPaymentObject($payment_object_id) returns old information from Mollie where the data of the Chargeback is not stored yet or the answer still returns cached data on Mollie's side.

#

We have seen this happening for a while now (more than a month) and finally had time to dive a little deeper into this.

The 2nd Webhook call is always exactly one minute after the first.

How can we fix this issue of our Orders getting the Status = Processing (paid) while this is not the case after a Chargeback.

Best regards,
Tim

Ps. i can share more detailed logs / information if needed.

obsidian terrace
#

@willow flicker

wet knot
#

@willow flicker Please let me know if you need more information about this.

willow flicker
#

@wet knot
Thanks a lot for the detailed breakdown and logs they’re very helpful.
We’re currently looking into this issue on our end and will get back to you as soon as we have more information or a proposed fix.
Appreciate your patience, and we’ll keep you posted!

wet knot
#

Thank you for the update!

willow flicker
#

Hola @wet knot ,

We’ve put together a fix that should sort out the conflicting webhooks and stop orders from switching back to “Processing” or “Completed” after a chargeback.

Download the attached test package ⬇️

Would be great if you could try it out on your live setup and let us know how it goes. Specifically, we’re keen to hear if:
The chargeback no longer gets overridden or you notice anything odd.

Appreciate your help!

wet knot
#

Hi Adrian, that's great to hear. I will install this patched version of the plugin immediately. We usually have a few of these orders per week and monitoring in place to detect these. If we never see these cases again in 1 or 2 weeks we can pretty safely assume the fix works! I will keep you updated.

wet knot
#

It's hard to prove the absence of a bug, but your fix seems to work 🙂

I see it is already rolled out in the latest 8.0.3 if i read the patch notes correctly. Can i switch back to 8.03 ?

willow flicker
#

Yes go ahead with the latest version 😉

wet knot
#

Thanks!

wet knot
#

@willow flicker I have a new chargeback bug which has been haunting us for a while now. This looks to be related to this issue above which was fixed in 8.0.3.

I have a specific use case which i think will make it easy to test. I have 1 customer with 1 subscription. This customer did a chargeback on the last 2 orders of his WooCommerce Subscription.

For both chargebacks, Mollie did call the webhook for WooCommerce to update the status to on-hold as the order is not paid for anymore after this chargeback.

I tracked this down in the logs again. For both orders, this hook is called:
Mollie\WooCommerce\Payment\MollieOrderService::onWebhookAction

BUT... for one order the chargeback is actually found correctly, but for the other order, the chargeback is not found!
This happens in:
Mollie\WooCommerce\Payment\MollieOrderService::processChargebacks

This leads to the situation where WooCommerce still thinks the order is paid, although there was a chargeback.

In a single day (november 5th) i can pinpoint 4 WooCommerce Orders with a chargeback where the webhook is called.
For 2 orders the chargebacks are found correctly and all is well
For 2 orders the chargebacks are NOT found, leading to incorrect order status

Please let me know if it helps if i share order ids, mollie transactions ids, dates, etc. There are still inconsistencies with Chargebacks, just like before the 8.0.3 update as mentioned above.

We currently are using 8.1.1

drowsy musk
#

I think this behavior is related to what we see in this question #1435633021268004914 message. We are investigating

#

Just to confirm, if you turn on debug logging, you do see the "No chargebacks to process for tr_..." message in the logs, or does it fail at a different stage of processChargebacks()?

wet knot
#

Hi Flo, yes it looks to be related to that other question. And exactly, in the logs i see this exact message "No chargebacks to process for tr_..." for some orders, even though there are chargebacks

drowsy musk
#

Thanks!

wet knot
#

Quick question, i'm writing some test scripts to check of the WooCommerce order status matches the Mollie Transaction status to see if we somehow missed recurring payments. When a Mollie Transaction has a chargeback, the Mollie Transaction status is still 'paid':

$mollie_payment = $mollie->payments->get($mollie_payment_id);
$mollie_status = $mollie_payment->status; // PRINTS: 'paid'

Is this correct? When i view this transaction in the Mollie dashboard, the status line in the table says 'Chargeback'

supple gazelle
#

there is a amountChargedBack property in a payment as well

wet knot
#

thanks, so the status = paid is correct
i just need to double check with amountChargedBack

supple gazelle
#

Yeah, the status=paid is a final state

wet knot
#

aha, thanks! even though the dashboard shows 'chargeback', the underlying status is paid and i need to check amountChargedBack to know for sure

#

thanks for listing that documentation

supple gazelle
#

I think that in the dashboard they just check if the amountChargedBack is set. If set the payment has a chargeback.