2

I have a strange behaviour in magento 2. Sometimes an order paid via paypal express or paypal plus creates a duplicate invoice. There seems to be no error. Aside from the invoice id they are completely identical and are created in the same second.

I found this inside the PayPal.log file:

[20-03-2019 19:41:34] PayPal\Core\PayPalHttpConnection : INFO: GET https://api.paypal.com/v1/payments/payment/PAYID-MYSECRETPAYID
[20-03-2019 19:41:35] PayPal\Core\PayPalHttpConnection : INFO: Response Status  : 200
[20-03-2019 19:41:35] PayPal\Core\PayPalHttpConnection : INFO: PATCH https://api.paypal.com/v1/payments/payment/PAYID-MYSECRETPAYID
[20-03-2019 19:41:36] PayPal\Core\PayPalHttpConnection : INFO: Response Status  : 200
[20-03-2019 19:42:39] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.paypal.com/v1/oauth2/token
[20-03-2019 19:42:40] PayPal\Core\PayPalHttpConnection : INFO: Response Status  : 200
[20-03-2019 19:42:40] PayPal\Core\PayPalHttpConnection : INFO: GET https://api.paypal.com/v1/payments/payment/PAYID-MYSECRETPAYID
[20-03-2019 19:42:41] PayPal\Core\PayPalHttpConnection : INFO: Response Status  : 200
[20-03-2019 19:42:41] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.paypal.com/v1/payments/payment/PAYID-MYSECRETPAYID/execute

The ID in those requests refer to a transaction that created those duplicate invoices.

My assumption is that paypal returns some info back to the shop ("webhook"?). And somthing causes paypal to do it twice.

This is from the order comment history:

20.03.2019 20:43:46 Processing Kunde Nicht benachrichtigt
Benachrichtigung über erfassten Betrag von 1.054,00 € erhalten. Transaktions-ID: "MYSECRETTRANSACTIONID"
20.03.2019 20:43:46 Processing Kunde Nicht benachrichtigt
Benachrichtigung über erfassten Betrag von 1.054,00 € erhalten. Transaktions-ID: "MYSECRETTRANSACTIONID"
20.03.2019 20:42:57 Processing Kunde Nicht benachrichtigt
Benachrichtigung über erfassten Betrag von 1.054,00 € erhalten. Transaktions-ID: "MYSECRETTRANSACTIONID"
20.03.2019 20:42:57 Processing Kunde Nicht benachrichtigt
Benachrichtigung über erfassten Betrag von 1.054,00 € erhalten. Transaktions-ID: "MYSECRETTRANSACTIONID"
20.03.2019 20:42:44 Processing Kunde Nicht benachrichtigt
Autorisierter Betrag von 1.054,00 €. Transaktions-ID: "MYSECRETTRANSACTIONID"

I would like to somehow hook into the process to log if paypal actually DOES return anything multiple times.

Does anybody know where to look?

Thank you

0

I had the same mistake.

In my case it was due to the switch to PayPal Plus, which caused another webhook. And then two confirmations were sent by PayPal.

I simply deleted the second webhook and since then only one confirmation is sent and thus created only one invoice.

The webhooks can be found at http://developer.paypal.com/ on "MyApps & Credentials" under "REST API apps". There, select the appropriate app and switch to the top right on "Live". On this page I removed the second webhook.

In the left navigation you can also look under "Live" > "Webhook Events" to which webhooks PayPal has sent confirmations.

  • Thanks for the input. I actually did have 2 more webhooks but they had staging urls so I doubt the caused the issue. Also this would not explain why this only happened sometimes. – omsta Sep 3 at 14:36
  • In our shop that happened only sporadically too. I then found an article describing the bug in Magento 1 and that it was due to the webhooks. Since I deleted the second webhook, it did not occur anymore. – marowi Sep 3 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.