After banging my head against a wall for days, I finally monkey-patched this fix which allows my users to securely checkout.

My securepages pages is just "checkout*" and my secure basedomain is https://secure.example.com/

Without the patch, clicking the "Checkout" button on the /cart page will redirect you to https://www.example.com/ (which doesn't load as I don't have an SSL certificate for that domain).

I don't know why this particular redirect fails - you can see the redirect being added to the cart here (with my monkey patch):

/**
 * Implements hook_form_alter().
 */
function commerce_checkout_form_alter(&$form, &$form_values, $form_id) {
  if (strpos($form_id, 'views_form_commerce_cart_form_') === 0) {
    $form['actions']['checkout'] = array(
      '#type' => 'submit',
      '#value' => t('Checkout'),
      '#weight' => 5,
      '#access' => user_access('access checkout'),
      '#submit' => array_merge($form['#submit'], array('commerce_checkout_line_item_views_form_submit')),
    );
  }
}

/**
 * Submit handler used to redirect to the checkout page.
 */
function commerce_checkout_line_item_views_form_submit($form, &$form_state) {
  // Set the order status to the first checkout page.
  $order = commerce_order_load($form_state['order']->order_id);
  $form_state['order'] = commerce_order_status_update($order, 'checkout_checkout', TRUE);

  // Skip saving in the status update and manually save here to force a save
  // even when the status doesn't actually change.
  $form_state['order']->revision = TRUE;
  $form_state['order']->log = t('Customer proceeded to checkout using a submit button.');

  commerce_order_save($form_state['order']);

  // Redirect to the checkout page if specified.
  if ($form_state['triggering_element']['#value'] == $form['actions']['checkout']['#value']) {
    // The simple checkout redirect here fails ... not sure why
    // Perhaps it's not registered in time? Because no #https is added to the form because the form action URL does not work?
    if (module_exists('securepages')) {
      $form_state['redirect'] = variable_get('securepages_basepath_ssl', '') . '/checkout';
    } else {
      $form_state['redirect'] = 'checkout';
    }
  }
}

Any ideas on how we can fix this properly?

CommentFileSizeAuthor
securepages.diff0 bytesaidanlis

Comments

likewhoa’s picture

Status: Active » Postponed

reattach difference, thanks.

astonvictor’s picture

Status: Postponed » Closed (outdated)

I'm closing it because the issue was created a long time ago without any further steps.

if you still need it then raise a new one.
thanks