I have a payment module for Magento that redirects to an external site to collect the payment info, then upon success it redirects back to the Magento one page checkout page.

Right now when it redirects back to the page it is using some javascript to insert the html input for the payment method and calling payment.save() to get to the review step.

What I want to know is there a better way to reload the one page checkout page and have it go directly to a specific step, in this case the review step?

The way it is now seems like its hacked together and there must be a better way.


1 Answer 1


The first way that comes to mind is:

To create a new first step in the checkout process that would be called each time. When you are returned from the 3rd party page this would have a URL param set so we know to do something. This requires:

Updating: public/app/code/core/Mage/Checkout/Block/Onepage/Abstract.php

protected function _getStepCodes()
    return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');

This block gets the available checkout steps. We would include a new one at the beginning for API or whatever make sense to what you are doing.

Then in OnePageController.php ( All should be changed in your own module ) we would need a new step:

public function saveAPIAction()
  if ($this->getRequest()->getParam('returned')) {
     $result['goto_section'] = 'review';          
  } else {
     $result['goto_section'] = 'login';

Next up would be to change the JS OpCheckout.js this file will need:

this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'];

Updating to reflect the new step. As well as a full new class adding for API

var Billing = Class.create();
Billing.prototype = {
initialize: function(form, addressUrl, saveUrl){
    this.form = form;
    if ($(this.form)) {
        $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
    this.saveUrl = saveUrl;
    this.onSave = this.nextStep.bindAsEventListener(this);
    this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
    // would need to add forcing payment save or success redirect 

Complexity when it comes to all of the above is ensuring that all the options throughout your checkout journey are set. If when the current implementation returns to the current checkout it just calls payment.save then it should be ok as adding to what I have provided will get you going with a new checkout step that does implement almost the same as the current but in a more modular means. You could add more functionality if required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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