I am trying to create a membership site using Drupal commerce. I have created a custom form that collects all the billing details of the user and the membership type and then on submit creates and saves a Drupal commerce order (products have already been created).

Now I want to activate the payment system for the order as soon the order is saved but I have not been able to do so. All of this should be happening in the backend and I do not want to redirect the user to a payment page. How do we do that?

  • What do you mean by "activate the payment system"? Do you mean you want to enable a payment rule programmatically? Or do you mean you want to programmatically add a payment record to an order? – Clive Oct 31 '13 at 12:29
  • Clive, I am not familiar with the terminology of these commerce systems as I am new to them. Usually in a normal shopping cart, once the product has been added to their cart a user moves to the 'pay' button and then goes on to submit their credit card information. My form has all the required fields, and what I want is when the customer clicks on the submit button, an order is created and immediately proceeds to payment using the credit card info they entered earlier. I have enabled the payment method, tried activating the payment system when the order has been created but it is not working. – Binny Oct 31 '13 at 13:02
  • What payment processor are you using? On or off-site version? – Clive Oct 31 '13 at 13:41
  • I am using authorize.net. I am guessing it is an offsite version – Binny Nov 1 '13 at 4:59
  • If it's an offsite payment method you won't be able to do that. You'll need to change to use an insure method if you want to process card details on your own site – Clive Nov 1 '13 at 12:02

To get it to go onto the review page you can do.

$order = commerce_order_new($uid, 'checkout_review');

When creating your order that sets the status to checkout_review.

Then you can use the following to driect yourself to the page

drupal_goto('checkout/' . $order->order_id. '/review');

As the status has been set you go to the review page. I did something similar recently and it is working well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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