Add payment method surcharge on single page checkout 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.
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:

Ingredients


Commerce Checkout Field Group
Field Group
Commerce Payment Methods Field - (I just created this module because it didn't exist, just gives you a field that is populated with payment methods available to that order).
Commerce Checkout Ajax


Directions

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.