Closed joosev closed 4 years ago
How can a payment first fail and then be confirmed? AFAIK most payment gateways dispatch a success callback when the payment completes. Usually that happens instantly but if the user does something stupid like closes the browser after completing the bank payment, it takes N days for the gateway provider to register the payment and then dispatch the success callback. It takes a while, but Woocommerce doesn't care. It's up to the payment gateway integration to change order statuses.
If the payment fails (user clicks the cancel button mid gateway), then the gateway usually sends an error response, and the order is cancelled, which means it can't be completed anymore.
I'll gladly take a look if there's a way to reproduce this behaviour, but I can't. Even if it is reproducible, IMO the fault is in the payment gateway plugin, https://wordpress.org/plugins/op-payment-service-for-woocommerce/.
I think this is a case where we are saving the pickup point information to the order, but when order is not created, information is lost. And this is a case when payment fails and gw confirms it. It seems that payment gateways are creating orders themselves in these cases and there for can not know what information there is to save.
We have to investigate how to save data before the order and how to retrieve that order when it is created.
Idea: would it be possible to command woocommerce to create order way before the order is placed? => would most likely brake alot of things.
idea 2: would it be possible to save shipping and pickup point information to cart?
Idea 2 should be implementable, but it's a bit tricky as the pickup points are dynamic. I'll see what I can do.
Looks like you partially implemented this ages ago, not sure why you set the session data to null in pickup_point_field_html.
https://github.com/Seravo/woo-pakettikauppa/commit/85f55ec329c726b85e55646b99545f50672ab460
I'll fix it and finish it. There's some edge cases (like user changing address after selecting a pickup point) that have to be considered but it'll be done today.
Chosen pickup point is not saved when payment fails (and is later confimed). This happens atleast with Checkout Finland.
I have not yet tested this myself, but this is probably how to replicate it: