On the checkout forms review pane when i select to pay with Paypal WPS and submit the form it get's redirected to an intermediary pane which is the payments pane. And only after 10 seconds it redirects to the PayPal site, there's a button as well..

Could this step be left out? If so, what is the right configuration.

So when selecting PayPal WPS payment and submitting the form it should automatically redirect to the PayPal site.

2 Answers 2


Commerce Paypal WS already redirects automatically by using the "offsite_autoredirect" flag in hook_commerce_payment_method_info:

  $payment_methods['paypal_wps'] = array(
    'base' => 'commerce_paypal_wps',
    'title' => t('PayPal WPS'),
    'short_title' => t('PayPal'),
    'display_title' => $display_title,
    'description' => t('PayPal Website Payments Standard'),
    'terminal' => FALSE,
    'offsite' => TRUE,
    'offsite_autoredirect' => TRUE,

The behaviour of this flag is to redirect automatically:

if (!empty($payment_method['offsite_autoredirect'])) {
  $form['#attached']['js'][] = drupal_get_path('module', 'commerce_payment') . '/commerce_payment.js';

And the js is the simplest it can be:

  Drupal.behaviors.commercePayment = {
    attach: function (context, settings) {
      $('div.payment-redirect-form form', context).submit();

So if you're experiencing a 10s delay on this operation, you need to debug what's happening in your payment page to cause this slowness. Check things like other panes you've put there (there should be just the payment one), cache, js compression and so on.

  • Yes i can see that, but this takes the user to the Payment redirect pane which i want to avoid. I tried removing the Off-site payment redirect form from the Payment pane on the checkout settings page, but with no luck. Is there something else i could try.
    – adevms
    Jun 27, 2014 at 7:25
  • If you remove the offsite_autoredirect option, you're then expecting that the user clicks the button themselves. Check the origin of this feature in drupal.org/node/1110334, from there " When they get to the Payment page, there a form is constructed that passes all the necessary information to the payment service when submitted. So the JS redirect would actually be a JS form submission resulting in the redirect." so if you need to modify this behavior, I'm afraid you'll need to go fully custom and evaluate if you can build the form earlier on
    – pcambra
    Jun 27, 2014 at 7:48

You can clean up the auto redirect experience for the user by hiding the page content of the redirect form. Something simple like this will work in commerce_payment.js to hide the form from the user and still allow the redirect code to run.

  Drupal.behaviors.commercePayment = {
     attach: function (context, settings) {
       $('div.payment-redirect-form form', context).submit();

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.