The client hosted their Magento 1.13 site themselves and their preference was to utilize an integrated Payment Gateway extension. However, the costs associated with PCI compliance encouraged them to look at a hosted Payment Gateway solution. The requirement for this project was to optimize customer experience in checking out with a hosted solution – to make checkout as seamless as possible and, specifically, to avoid losing cart items when back-paging to Magento from the hosted payment page or when returning to the Magento failure page when card details were not accepted.
Natively, the hosted payment gateway extension closed the cart (or ‘quote’ object) and created an order before moving to the external payment page. Hence the cart was emptied at this point. The solution posted the quote parameters rather than the order parameters to the Payment Gateway site. Hence, cart contents were still available. The cart was closed and the order was created only when returning to Magento after card details had been successfully processed by the gateway. The solution involved rewriting models and controllers in the payment gateway itself, as well as rewriting Magento’s one page controller and model, and making extensive changes to Magento’s sales service quote model to derive two methods, ‘submitQuoteOnly’ and ‘submitOrderAfter’, where only the ‘submitOrder’ method had existed natively.