Open simonworkhouse opened 3 years ago
Hi Simon,
I can't able to replicate the issue. I am able to place the order .please see the below log file.
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Checkout Method:- guest [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Is Allowed Guest Checkout :- 1 [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Is Customer Logged In :- [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Shipping Required:- Yes [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Gift Card Amount:- 0 [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: 5--5-5-5 [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Checkout Request:- {"type":"standard","shopper":{"first_name":"zip","last_name":"test","phone":"400000","email":"mahbubur.rahman@zip.co","billing_address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"order":{"reference":"AU141020000000088","amount":5,"currency":"AUD","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"507","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}],"cart_reference":"183"},"metadata":{},"config":{"redirect_uri":"http:\/\/127.0.0.1\/magento240\/default\/zippayment\/complete\/"}} [] []
[2021-06-24 23:19:00] zipMoneyLog.DEBUG: Checkout Response:- {"id":"au-co_W84Xx2fj04zAwqB1VyeCj6","uri":"https:\/\/sandbox.zip.co\/customer\/account-selector?co=co_W84Xx2fj04zAwqB1VyeCj6&m=52ca96a6-3286-4e2e-a085-06918554fc4f","type":"standard","shopper":{"first_name":"zip","last_name":"test","phone":"400000","email":"mahbubur.rahman@zip.co","birth_date":"0001-01-01T00:00:00+00:00","gender":"Other","statistics":{"sales_total_count":0,"sales_total_amount":0,"sales_avg_amount":0,"sales_max_amount":0,"refunds_total_amount":0,"previous_chargeback":false,"currency":"AUD"},"billing_address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"order":{"reference":"AU141020000000088","amount":5,"currency":"AUD","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"507","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}],"cart_reference":"183"},"config":{"redirect_uri":"http:\/\/127.0.0.1\/magento240\/default\/zippayment\/complete\/"},"created":"2021-06-24T23:19:00+00:00","state":"created","metadata":{}} [] []
[2021-06-24 23:19:00] zipMoneyLog.INFO: Successful to get redirect url [ https://sandbox.zip.co/customer/account-selector?co=co_W84Xx2fj04zAwqB1VyeCj6&m=52ca96a6-3286-4e2e-a085-06918554fc4f ] [] []
[2021-06-24 23:19:37] zipMoneyLog.INFO: Starting Checkout [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Checkout Method:- guest [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Is Allowed Guest Checkout :- 1 [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Is Customer Logged In :- [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Shipping Required:- Yes [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Gift Card Amount:- 0 [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: 5--5-5-5 [] []
[2021-06-24 23:19:37] zipMoneyLog.DEBUG: Checkout Request:- {"type":"standard","shopper":{"first_name":"zip","last_name":"test","phone":"400000","email":"mahbubur.rahman@zip.co","billing_address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"order":{"reference":"AU141020000000088","amount":5,"currency":"AUD","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"507","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}],"cart_reference":"183"},"metadata":{},"config":{"redirect_uri":"http:\/\/127.0.0.1\/magento240\/default\/zippayment\/complete\/"}} [] []
[2021-06-24 23:19:38] zipMoneyLog.DEBUG: Checkout Response:- {"id":"au-co_E7Q0mwyWFo5A0JPcG6lF24","uri":"https:\/\/sandbox.zip.co\/customer\/account-selector?co=co_E7Q0mwyWFo5A0JPcG6lF24&m=52ca96a6-3286-4e2e-a085-06918554fc4f","type":"standard","shopper":{"first_name":"zip","last_name":"test","phone":"400000","email":"mahbubur.rahman@zip.co","birth_date":"0001-01-01T00:00:00+00:00","gender":"Other","statistics":{"sales_total_count":0,"sales_total_amount":0,"sales_avg_amount":0,"sales_max_amount":0,"refunds_total_amount":0,"previous_chargeback":false,"currency":"AUD"},"billing_address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"order":{"reference":"AU141020000000088","amount":5,"currency":"AUD","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"507","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}],"cart_reference":"183"},"config":{"redirect_uri":"http:\/\/127.0.0.1\/magento240\/default\/zippayment\/complete\/"},"created":"2021-06-24T23:19:38+00:00","state":"created","metadata":{}} [] []
[2021-06-24 23:19:38] zipMoneyLog.INFO: Successful to get redirect url [ https://sandbox.zip.co/customer/account-selector?co=co_E7Q0mwyWFo5A0JPcG6lF24&m=52ca96a6-3286-4e2e-a085-06918554fc4f ] [] []
[2021-06-24 23:19:48] zipMoneyLog.DEBUG: On Complete Controller [] []
[2021-06-24 23:19:48] zipMoneyLog.DEBUG: /magento240/default/zippayment/complete/?result=cancelled&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24 [] []
[2021-06-24 23:19:48] zipMoneyLog.DEBUG: Result:- %s [] []
[2021-06-24 23:19:48] zipMoneyLog.DEBUG: Current Customer Id:- %s Quote Customer Id:- %s Quote checkout method:- %s [] []
[2021-06-24 23:19:48] zipMoneyLog.DEBUG: Calling cancelledAction [] []
[2021-06-24 23:20:00] zipMoneyLog.DEBUG: On Complete Controller [] []
[2021-06-24 23:20:00] zipMoneyLog.DEBUG: /magento240/default/zippayment/complete/?result=approved&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24 [] []
[2021-06-24 23:20:00] zipMoneyLog.DEBUG: Result:- %s [] []
[2021-06-24 23:20:00] zipMoneyLog.DEBUG: Current Customer Id:- %s Quote Customer Id:- %s Quote checkout method:- %s [] []
[2021-06-24 23:20:01] zipMoneyLog.DEBUG: Quote Grand Total:- 5.0000 Quote Customer Id:- Checkout Method:- guest [] []
[2021-06-24 23:20:06] zipMoneyLog.INFO: Successfull to place the order [] []
[2021-06-24 23:20:06] zipMoneyLog.DEBUG: Shipping Required:- Yes [] []
[2021-06-24 23:20:06] zipMoneyLog.DEBUG: Gift Card Amount:- 0 [] []
[2021-06-24 23:20:06] zipMoneyLog.DEBUG: 5--5-5-5 [] []
[2021-06-24 23:20:06] zipMoneyLog.DEBUG: Charge Payload:- {"authority":{"type":"checkout_id","value":"au-co_E7Q0mwyWFo5A0JPcG6lF24"},"reference":"AU141020000000088","amount":5,"currency":"AUD","capture":true,"order":{"reference":"AU141020000000088","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"379","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}]},"metadata":{}} [] []
[2021-06-24 23:20:08] zipMoneyLog.DEBUG: Charge Response:- {"id":"au-ch_zfYW3cheLgVIVyyORD4322","reference":"AU141020000000088","amount":5,"currency":"AUD","state":"captured","captured_amount":5,"refunded_amount":0,"created_date":"2021-06-24T23:20:07+00:00","order":{"reference":"AU141020000000088","shipping":{"pickup":false,"address":{"line1":"10 spring st","city":"sydney","state":"NSW","postal_code":"2000","country":"AU","first_name":"zip","last_name":"test"}},"items":[{"name":"Argus All-Weather Tank","amount":5,"reference":"379","quantity":1,"type":"sku","image_uri":"http:\/\/127.0.0.1\/magento240\/pub\/static\/version1623885585\/frontend\/Magento\/luma\/en_AU\/Magento_Catalog\/images\/product\/placeholder\/.jpg","item_uri":"http:\/\/127.0.0.1\/magento240\/default\/argus-all-weather-tank.html","product_code":"MT07-M-Gray"},{"name":"Discount","amount":-5,"reference":"Discount","quantity":1,"type":"discount"},{"name":"Shipping","amount":5,"reference":"Shipping","quantity":1,"type":"shipping"}],"cart_reference":"183"},"metadata":[],"receipt_number":"1882879"} [] []
[2021-06-24 23:20:08] zipMoneyLog.DEBUG: Charge State:- captured [] []
[2021-06-24 23:20:08] zipMoneyLog.INFO: Payment Captured [] []
[2021-06-24 23:20:08] zipMoneyLog.DEBUG: Order captured setting order state: processing status: processing [] []
@mahbub-zip It seems that you processed a payment for the same checkout ID that you cancelled. You need to cancel the one checkout and process the other.
Your logs show these two requests with the same checkout ID
/magento240/default/zippayment/complete/?result=cancelled&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24
/magento240/default/zippayment/complete/?result=approved&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24 [] []
Whereas my logs showed the two different checkout IDs
/zippayment/complete/?result=cancelled&checkoutId=au-co_qQSg86sBKq291yxxxxxxxx [] []
/zippayment/complete/?result=approved&checkoutId=au-co_FZCvATHzEw9VPTxxxxxxxx [] []
@simonworkhouse yes i can see the same checkout id for cancelled and approved. But whatever steps you mentioned i have followed those steps. please have a look on the below video link
@mahbub-zip That's an incomplete video of the process, and your logs indicate that it's fetching the same checkout ID from the database as what's in the request parameters. In our logs we received Checkout Id does not match with the session quote.
.
Which branch are you running these tests on?
Using master branch. I followed same steps whatever you mentioned. I attached another video.
@mahbub-zip It would be helpful to have the logs tailed at the same time as that order was being placed, but probably not necessary as I think that I may be able to guess what the issue is based on the previous logs that you supplied.
As I highlighted previously, your logs indicate that the cancelled order checkout ID is what's provided in the redirect query parameters:
/magento240/default/zippayment/complete/?result=cancelled&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24
/magento240/default/zippayment/complete/?result=approved&checkoutId=au-co_E7Q0mwyWFo5A0JPcG6lF24 [] []
This leads to the question as to why you are being redirected back to Magento with a different checkout ID (co_E7Q0mwyWFo5A0JPcG6lF24
) than the one that was used in the hosted payment page URL (https://sandbox.zip.co/customer/account-selector?co=co_W84Xx2fj04zAwqB1VyeCj6&m=52ca96a6-3286-4e2e-a085-06918554fc4f
).
My guess is that it's due to the fact that you are already logged in to your Zip account, so retry all tests in an incognito/private session and only log in once you are about to process the payment.
This is just a guess, but if it's incorrect, then we would need to determine why the redirect back to Magento uses the incorrect checkout ID.
@simonworkhouse I have checked this in an incognito. I cannot replicate the issue. Before redirect to merchant from zip, zip can able to map with latest checkout id. When it is redirect to merchant that time URL has the latest checkout id. In this video i am not showing login process for security reason. I believe this video make you more clear.
@mahbub-zip What mechanism is Zip supposedly using to map the user to the latest checkout ID? Session based? Mapped by order reference? Linked to a Zip account? Or something else? You can clearly see from the logs that I have provided that we are not being redirected to the latest checkout ID. Is there a setting on a merchant account that prevents cancelled orders from being approved?
Regardless of this mechanism, the module requires a fix to address situations where multiple payments have been created for an order.
@simonworkhouse could you please apply this https://github.com/zipMoney/zip.magento2/pull/45/files change on top our latest plugin and let me know is this resolve the issue?
I am attempting to perform some tests, but it appears that your sandbox is experiencing intermittent outages.
I'll keep trying over the course of the day, but you'll have to forgive me if it takes me some time to complete testing.
@mahbub-zip Yes, that fix does appear to resolve the issue. However; it still doesn't necessarily handle multiple checkout IDs/payments in the ideal way.
@simonworkhouse and @mahbub-zip I am having an identical issue but something I noticed isn't being discussed is the failed requests to the Zip API right before the order is cancelled (your logs are the same as mine in this regard).
All our cases are identical with the logs looking like:
[2021-10-11 09:07:00] zipMoneyLog.DEBUG: ApiError:- [400] Error connecting to the API (https://global-api.prod.au.edge.zip.co/merchant/charges) ...
[2021-10-11 09:07:00] zipMoneyLog.DEBUG: Cancelling the order [] []
[2021-10-11 09:07:03] zipMoneyLog.DEBUG: Could not process the payment [] []
[2021-10-11 09:07:04] zipMoneyLog.INFO: In errorAction [] []
[2021-10-11 09:07:04] zipMoneyLog.INFO: An error occurred. [] []
[2021-10-12 05:33:41] zipMoneyLog.DEBUG: ApiError:- [400] Error connecting to the API (https://global-api.prod.au.edge.zip.co/merchant/charges) ...
[2021-10-12 05:33:41] zipMoneyLog.DEBUG: Cancelling the order [] []
[2021-10-12 05:33:42] zipMoneyLog.DEBUG: Could not process the payment [] []
[2021-10-12 05:33:44] zipMoneyLog.INFO: In errorAction [] []
[2021-10-12 05:33:44] zipMoneyLog.INFO: An error occurred. [] []
[2021-10-14 02:15:51] zipMoneyLog.DEBUG: ApiError:- [400] Error connecting to the API (https://global-api.prod.au.edge.zip.co/merchant/charges) ...
...
[2021-10-14 12:26:41] zipMoneyLog.DEBUG: Error:- [500] Error connecting to the API (https://global-api.prod.au.edge.zip.co/merchant/charges) ...
...
Does the extension need a way to handle these errors, possibly with some retry logic instead of simply canceling the order?
@mahbub-zip as per my comment above - this issue happened again today even after applying the suggested code change above. It happens rarely but it still happens.
Any idea? You never replied to my comment above.
Hey @Swiftless , Do you have staging site where same issue is happening? is it possible to send me the staging website url then i can have a look? Thanks
Approved payments erroneously cancelled
An approved payment will be erroneously cancelled if a user has two tabs open on the Zip pay hosted page and chooses to return to the store in one of those tabs and then completes the payment process in the other tab.
Steps to reproduce
This issue is easiest to replicate using two browser tabs and these steps assume that the user is at the payment step of the checkout.
/zippayment/complete/?result=cancelled...
).After completing the payment and returning to the store, logs will first show a call to
/zippayment/complete/?result=approved...
, then a charge request is attempted with loggedCharge Payload:- {"authority":{...
which will receive a 403 with the messageAuthority request - xxxxxxx is not approved.
Upon receiving the 403, the approved order is then erroneously cancelled and the user is shown a generic error page, which likely states something along the lines of "General Error An error occurred while processing your request.".
The cause
The charge request uses the incorrect Zip checkout ID due to
Zip\ZipPayment\Helper\Payload::getAuthority()
fetching this from theadditional_information
field in the quote payment object, which may have changed since the user initially proceeded to the Zip hosted payment page.This incorrect Zip checkout ID is used in the charge payload and results in an error after which the module cancels the order.
The fix
Either use the checkout ID returned by the Zip hosted payment page instead of fetching it from the quote payment, or alternatively, track multiple payments against a quote instead of assuming that there will be only one.
Example logs