Using Drupal 7, Drupal Commerce module.

I have a single page checkout on which the user enters Billing Info, selects one of two payment methods and enters their credit card or E-Check information (using the Commerce NMI payment gateway which utilizes a direct-post method), and ultimately submits the payment. The Review pane is empty and therefore skipped, so the checkout proceeds directly to the Third-party Payment Redirect pane.

My issue: I use a Rule to apply a fee (using Commerce Fees) depending on payment method, but it seems like the payment method isn't being set before the information is sent to the payment gatway--the payment method comparison always evaluates to false.

The rule is recognized after the fact, however, as the fee gets added after the payment has been submitted, resulting in an unpaid balance on the order.

The client is set on a single page checkout process, and so what I need is this:

How can I grab and alter the order information after submitting the checkout form but before the third party redirect fires? This would be very helpful as I would also like to add a custom code to the order ID this way.

1 Answer 1


You need to be careful here. Obviously you want to share with your customer that their order total will change, even slightly, before they pay. Often, most payment gateways strongly discourage passing on their fee to the customer, or flat out do not allow it.

But let's assume you want to charge more for "Cash on Delivery."

According to the commerce_fee documentation, you have to use two pages.

Notice: if using fees based on payment type, be sure to move the payment type pane to a screen before the review pane on admin/commerce/config/checkout so that customers can see the fee before accepting.

This requirement would prevent nearly all normal payment gateways that require an off-site-payment-redirect step after putting payment details into a form from functioning correctly, if at all.

One way to create a single page, with ajax is the following recipe:



Add a payment method field to your order. Use field group and checkout field group to add this field to a checkout page. Use Rules to make only a pre-selected payment method available based on the field on orders (might require a custom rule condition?). Use Rules to calculate your fee based on that field selection and not on the actual payment gateway selected. Use Commerce Checkout Ajax to re-load panes as needed.

  • the question: How can I grab and alter the order information after submitting the checkout form but before the third party redirect fires? can be answered by using rules and the event "on order update." Just beware that the event fires on every order update, including adding products to cart, etc. So make sure your conditions are rock solid.
    – joshmiller
    Feb 15, 2016 at 23:32

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.