antonioperic Posted January 15, 2017 Share Posted January 15, 2017 Hi, I am working on one custom payment module and module is implementing 3rd party api. So I redirect user to payment gateway page, then when he is return I process his order. There is situation when user cancel his order, or got some erorr and then complete order with other payment method. In this situation I will love to mark this payment as error or failed but when I do validateOrder() then my cart is removed. How can I keep cart when order is created and failed?Thank you Link to comment Share on other sites More sharing options...
bellini13 Posted January 15, 2017 Share Posted January 15, 2017 Don't create an order, don't call validateOrder if the payment gateway returned a failure. Instead return the customer to the checkout process and display a message that the payment was cancelled or failed. They can pick another payment method, or try again. Link to comment Share on other sites More sharing options...
antonioperic Posted January 15, 2017 Author Share Posted January 15, 2017 That is easy. But I want administrator to see what happen to that order. It is failed because of some reason and clients will call and ask and in this way he wont see anything as order doesn't exist. Link to comment Share on other sites More sharing options...
antonioperic Posted January 15, 2017 Author Share Posted January 15, 2017 As I get from code it is impossible in that way, only way is to clone Cart and assign new cart to user if Order is failed, then new cart will create new order. $newCart = $cart->duplicateObject();$products = $cart->getProducts();foreach($products as $product) {$newCart->updateQty($product['cart_quantity'], $product['id_product']);}$newCart->save();Hook::exec('actionCartSave');$this->context->cookie->id_cart = $newCart->id; Link to comment Share on other sites More sharing options...
bellini13 Posted January 15, 2017 Share Posted January 15, 2017 then record the failure in a database table, and provide a mechanism in the back office to view the failures Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now