mollie / mollie-odoo

Mollie Payments plugin for Odoo - an open source CRM and ERP
29 stars 49 forks source link

order stuck in quotation status after payment #145

Closed codeagencybe closed 2 months ago

codeagencybe commented 7 months ago

Odoo version: 16.0

I notice when a payment is confirmed with Mollie via website checkout, the order status remains in "quotation" instead of "order". This means, every single web order has to be confirmed manually by an internal user.

That doesn't seem to be normal behaviour? In the current use case, the client is using both manual quotations for B2B customers AND also online sales for B2C customers.

Any plausible reason why the sale order gets stuck in quotation status while it's been paid succesfully online?

odoo-mvds commented 2 months ago

Hello,

This happens when you close the website page before redirecting back to Odoo. However, Odoo will confirm the order afterwards using the cron:

image

This is not a bug, but standard Odoo behavior.

br,

codeagencybe commented 2 months ago

No that is the problem either. We already have this cronjob running every 10 minutes.

But from what I found in the transaction details, it's a problem that only happens with Mollie.

This is a more "extreme" example, but it shows you very good the problem.

image

The initial payment attempt went wrong, for whatever reason. Sometimes it's a disruption at Mollie, sometimes it's because the customer has not enough money on the card (passing card limits for daily spending etc...) but in any case the payment fails. They redirect back eventually.

And then comes the problem. Odoo creates sub-records as -1, -2, -3, ... which makes sense to me. But the problem is that we are seeing a big delay from Mollie coming back to confirm the final success payment. Sometimes it's even 12-14 hours later while if we check the Odoo account, the payment was already confirmed and captured 12+ hours earlier, except Odoo does not handle it's confirmation.

So the merchant now has to manually check Mollie transaction lines one by one to find out which one have been paid but not registered yet in Odoo or go through the email confirmations they receive from Mollie. Because that is what we are experiencing. Mollie acknowledge successful payment, confirms by email but Odoo is not registering the payment and leaves the order in quotation. Even when the cronjob is running every 10 minutes.

Do notice that the provider reference is also changing every payment.transaction record. I would expect this to remain the same?

image

image

The chatter on the sale order is also full with these messages:

image

Here's another example:

The last confirmation message in the top shows up when Odoo received the final confirmation from Mollie and they are perfectly in sync. And this marks the website cart as "order" so it can be picked and shipped. The problem is that this final confirmation sometimes comes 14 hours or even 24 hours later. Not always but we can track this problem back when the original cart got breakdown into -1, -2, -3, ... For some reason, Odoo is causing a problem with Mollie on this specific behavior when the initial payment failed for whatever reason.

We have also installed other payment gateways and simulated the same scenario, and it only happens for Mollie. We have also simulated the same scenario with WooCommerce and Magento with Mollie, and it only happens with Odoo.

So I'm 300% confident and sure, this is a problem isolated to Odoo. At first we believed it only happened to big amounts as that is an easier trigger for a failed payment (card payment daily/weekly limit). So the customer has to abort payment and increase it's card spent limit first and then try pay for the cart again. But we were able to reproduce the same problem also for small amounts and again, only with combo Odoo + Mollie.

image

For a small store, this might not be too much of a problem, but my client runs hundreds of orders per day. And if they don't get reliable payment confirmation, they are missing on shipping orders. Customers are calling them why their order didn't ship because they paid and got confirmation from Mollie, except Odoo wasn't able to process it. Then the abandoned cart email kicks of 4 hours later to that customer "they still have something in cart" while they already paid for that order making more chaos and confusion.

odoo-mvds commented 2 months ago

Hi,

the failed payment can be check on the backend of Mollie. That should give you an idea why you have up to 5 attempts before the validation of the payment.

In any case, when the payment is confirmed, and the flow of going back to the website is interrupted, it will break the creation of the invoice, and thus the confirmation of the SO.

The cron will only check orders that are in this state +12 hours (i'm not 100% sure, maybe it's even 24h) so even if you check every 10 minutes, it will ignore those fresh orders. This is the reason why it takes so long.

Again, this is default Odoo behavior with all payment providers.

br,

codeagencybe commented 2 months ago

Hi,

the failed payment can be check on the backend of Mollie. That should give you an idea why you have up to 5 attempts before the validation of the payment.

We already checked that. The reasons we see is due to card limit in 99,99% of the cases. But these customers do a new attempt after they raised the limit and at some point it works. The problem is after the successful payment, the confirmation from Mollie back to Odoo is delayed too much (12+ hours up to 24 hours). And it ONLY happens with Mollie. I don't believe this is a "default behavior" as other payment providers with Buckaroo and Stripe don't show this behavior at all.

In any case, when the payment is confirmed, and the flow of going back to the website is interrupted, it will break the creation of the invoice, and thus the confirmation of the SO.

We don't have invoice creating enabled. Invoices are created after delivery manually. The problem is the order is already paid in Mollie systems, but comes delayed to Odoo in 12+ hours which means, my customer their warehouse is late on shipping orders with minimum half a day.

The cron will only check orders that are in this state +12 hours (i'm not 100% sure, maybe it's even 24h) so even if you check every 10 minutes, it will ignore those fresh orders. This is the reason why it takes so long.

Why would it ignore these fresh orders? That doesn't make any sense.

Again, this is default Odoo behavior with all payment providers.

Clearly not, as Buckaroo and Stripe don't show these behavior. We have tested 5 different payment providers in Odoo under exactly same conditions. It only happens with Mollie.

In the Mollie dashboard there is nothing wrong. We can see all the timestamps and the webhooks being fire off immediately with success. It's only Odoo that for some unknown reason is delaying the booking the of the payment that came back from Mollie to 12+ hours if some initial previous payment failed first.

payment expired this is the buyers intent mistake, they waited too long or they got some message in their bank app that payment could not work because of too high amount within their card spent limit.

image

payment success: here you can see the webhooks meta data on the bottom are updated with the new SO number. But in the right side history bar we see an email was sent immediately and the initial payment created but there is no webhook history that calls back. image

We are trying to understand where and how this difference comes from. None of the succesful paid orders show a webhook from Mollie to Odoo, only email notification. When the payment failed, it does do a callback for the failing When the payment is success in 1 go, it's all good in Odoo When the payment is repeat with sucess, it's a lost communication and no call back.

According to Mollie support, they say the problem comes from Odoo as Odoo has to pass the callback request. If it doesn't, Mollie doesn't return a callback because Odoo didn't ask for it.

odoo-mvds commented 2 months ago

Hello,

If the webhook isn't called, the cron will confirm the SO as a fallback system, and if enabled (not in your case) generate the invoice. The behavior i'm talking about ignoring the fresh orders can be found in the source code of Odoo. We also think this can be shorter, but it's not in the scope of Mollie, as it's default Odoo behavior. You can do this customisation easily by editing the behavior of that cron.

The main issue in your case, is that the customer, somehow, is not going back to the redirect URL after a succesfull payment. This can be due to the end user closing his window too soon, or if you have it in 100% of the cases, a misconfigured base URL.

If you have it only for a few cases, than most likely it's the user closing the payment screen too soon.

Your solution in that case, is to alter the default Odoo cron to check even the freshly created ordes, instead of ignoring them the first X hours. Then it will be confirmed after 10 minutes instead after 12h or more.

If you think this behavior is not ok, you should contact Odoo about this, as this cron is not handled by our module.

br,

codeagencybe commented 2 months ago

Hello,

If the webhook isn't called, the cron will confirm the SO as a fallback system, and if enabled (not in your case) generate the invoice. The behavior i'm talking about ignoring the fresh orders can be found in the source code of Odoo. We also think this can be shorter, but it's not in the scope of Mollie, as it's default Odoo behavior. You can do this customisation easily by editing the behavior of that cron.

I will have a look at this to see if it can help us with this issue.

The main issue in your case, is that the customer, somehow, is not going back to the redirect URL after a succesfull payment. This can be due to the end user closing his window too soon, or if you have it in 100% of the cases, a misconfigured base URL.

Not possible. Because if the base url or redirect URL was wrong, then all payments would fail and have this problem. And it would also fail for Buckaroo and Stripe. So no, this is a wrong analysis from your end.

If you have it only for a few cases, than most likely it's the user closing the payment screen too soon.

That could be a scenario, but not something we can control unfortunately.

Your solution in that case, is to alter the default Odoo cron to check even the freshly created ordes, instead of ignoring them the first X hours. Then it will be confirmed after 10 minutes instead after 12h or more.

If you think this behavior is not ok, you should contact Odoo about this, as this cron is not handled by our module.

But even if this is default Odoo behavior, this conflicts with some other default behavior from Odoo. Like abandoned cart emails. How it is designed by default means customers who made a succesful payment, but due to some callback issue, still receive a marketing email about some unpaid cart which they did pay for several hours earlier.

Sorry to say, but this is a very poor designed flow by Odoo. And now we partners have to fix these broken flows? What a weird thing to propose.