mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
100 stars 53 forks source link

Status of order does not change when webhook is success #598

Closed jesse-deboer closed 1 year ago

jesse-deboer commented 1 year ago

Describe the bug After updating to Magento 2.4.5-p1 and PHP8.1. Everything seems to go well, but somehow the orders are not setting the status to processing when the payment is successful for some orders.

There is no consistency in when it is working and when it is not working.

Important: Manual fetching of the payment status in the admin does work

Used versions

Expected behavior After the webhook is being triggered and there has been a successful iDeal payment it should set the status to processing.

Actual behavior The order will still have pending payment

Additional context The debug log shows the following, also successful at the end but the order will not be updated to processing and the payment will not be added. Parts are redacted for privacy. Everything with null is indeed null

Request request: {"amount":{"currency":"EUR","value":"52.45"},"description":"*******","billingAddress":{"streetAndNumber":"*******","postalCode":"*******","city":"*******","region":null,"country":"NL"},"redirectUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/process\/?order_id=*******&payment_token=*******&utm_nooverride=1","webhookUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/webhook\/?isAjax=1","method":"ideal","metadata":{"order_id":"*******","store_id":"1","payment_token":"*******"},"locale":null,"shippingAddress":{"streetAndNumber":" ******* ","postalCode":"*******","city":"*******","region":null,"country":"NL"}} [] []

Response response: {"resource":"payment","id":"*******","mode":"live","amount":{"value":"52.45","currency":"EUR"},"settlementAmount":null,"amountRefunded":null,"amountRemaining":null,"amountChargedBack":null,"description":"*******","method":"ideal","status":"open","createdAt":"2023-01-02T15:44:58+00:00","paidAt":null,"canceledAt":null,"expiresAt":"2023-01-02T15:59:58+00:00","failedAt":null,"dueDate":null,"billingEmail":null,"profileId":"*******","sequenceType":"oneoff","redirectUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/process\/?order_id=*******&payment_token=*******&utm_nooverride=1","webhookUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/webhook\/?isAjax=1","mandateId":null,"subscriptionId":null,"orderId":null,"settlementId":null,"locale":null,"metadata":{"order_id":"*******","store_id":"1","payment_token":"*******"},"details":null,"restrictPaymentMethodsToCountry":null,"_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/payments\/*******","type":"application\/hal+json"},"checkout":{"href":"https:\/\/www.mollie.com\/checkout\/select-issuer\/ideal\/*******","type":"text\/html"},"dashboard":{"href":"https:\/\/my.mollie.com\/dashboard\/*******\/payments\/*******","type":"text\/html"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/payments-api\/create-payment","type":"text\/html"}},"_embedded":null,"isCancelable":false,"amountCaptured":null,"applicationFee":null,"routing":null,"authorizedAt":null,"expiredAt":null,"customerId":null,"countryCode":null} [] []

Webhook webhook: {"resource":"payment","id":"*******","mode":"live","amount":{"value":"52.45","currency":"EUR"},"settlementAmount":{"value":"52.45","currency":"EUR"},"amountRefunded":{"value":"0.00","currency":"EUR"},"amountRemaining":{"value":"77.45","currency":"EUR"},"amountChargedBack":null,"description":"*******","method":"ideal","status":"paid","createdAt":"2023-01-02T15:44:58+00:00","paidAt":"2023-01-02T15:45:12+00:00","canceledAt":null,"expiresAt":null,"failedAt":null,"dueDate":null,"billingEmail":null,"profileId":"*******","sequenceType":"oneoff","redirectUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/process\/?order_id=*******&payment_token=*******&utm_nooverride=1","webhookUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/webhook\/?isAjax=1","mandateId":null,"subscriptionId":null,"orderId":null,"settlementId":null,"locale":"nl_NL","metadata":{"order_id":"*******","store_id":"1","payment_token":"*******"},"details":{"consumerName":"*******","consumerAccount":"*******","consumerBic":"*******"},"restrictPaymentMethodsToCountry":null,"_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/payments\/*******","type":"application\/hal+json"},"dashboard":{"href":"https:\/\/my.mollie.com\/dashboard\/*******\/payments\/*******","type":"text\/html"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/payments-api\/get-payment","type":"text\/html"}},"_embedded":null,"isCancelable":null,"amountCaptured":null,"applicationFee":null,"routing":null,"authorizedAt":null,"expiredAt":null,"customerId":null,"countryCode":"NL"} [] []

Error error: Entiteit bestaat niet. [] []

Success success: {"resource":"payment","id":"*******","mode":"live","amount":{"value":"52.45","currency":"EUR"},"settlementAmount":{"value":"52.45","currency":"EUR"},"amountRefunded":{"value":"0.00","currency":"EUR"},"amountRemaining":{"value":"77.45","currency":"EUR"},"amountChargedBack":null,"description":"*******","method":"ideal","status":"paid","createdAt":"2023-01-02T15:44:58+00:00","paidAt":"2023-01-02T15:45:12+00:00","canceledAt":null,"expiresAt":null,"failedAt":null,"dueDate":null,"billingEmail":null,"profileId":"*******","sequenceType":"oneoff","redirectUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/process\/?order_id=*******&payment_token=*******&utm_nooverride=1","webhookUrl":"https:\/\/www.clienturl.nl\/mollie\/checkout\/webhook\/?isAjax=1","mandateId":null,"subscriptionId":null,"orderId":null,"settlementId":null,"locale":"nl_NL","metadata":{"order_id":"*******","store_id":"1","payment_token":"*******"},"details":{"consumerName":"*******","consumerAccount":"*******","consumerBic":"*******"},"restrictPaymentMethodsToCountry":null,"_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/payments\/*******","type":"application\/hal+json"},"dashboard":{"href":"https:\/\/my.mollie.com\/dashboard\/*******\/payments\/*******","type":"text\/html"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/payments-api\/get-payment","type":"text\/html"}},"_embedded":null,"isCancelable":null,"amountCaptured":null,"applicationFee":null,"routing":null,"authorizedAt":null,"expiredAt":null,"customerId":null,"countryCode":"NL"} [] []

Success success: {"success":true,"status":"paid","order_id":"*******","type":"success"} [] []

jesse-deboer commented 1 year ago

After a lot of research I found out the error is there because the order can't be found.

$this->orderRepository->save($order); in Model/Client/Payments.php gives back No such entity.

I have not found the solution yet and will try if it works again if I downgrade back to 2.17

jesse-deboer commented 1 year ago

Downgrading to 2.17 did not help, so it has to be something in the 2.4.5 and PHP 8.1 update.

It's giving me the same error on 2.17: error: Entiteit bestaat niet. [] [] / No such entity

jesse-deboer commented 1 year ago

We found something that might help. The error only happens when the order contains configurable products. When the order only contains simple products the status will change and everything goes how it should work.

jesse-deboer commented 1 year ago

Found it, it's a custom implementation that happens during the $this->orderRepository->save($order);, nothing to do with Mollie!

fjbender commented 1 year ago

Wow, what a ride! Thanks for sharing your thought process here though, it'll certainly be helpful for folks in similar situations.

Frank-Magmodules commented 1 year ago

It seems that you had indeed some adventure debugging this, thanks for sharing the outcome @jesse-deboer, glad it's solved now! ;-)