Commerce Order email with an "Unknown" payment method (Drupal 7) I placed the order programatically.  Everything seems to work fine, even the "payment method" on the order page is show up correctly.  However the order email I received, the payment method is unknown.  It suppose to show "Add to account"

I don't know why, I thought that could be the email rules is executed before the token is available with the payment method name to use. On Drupal commerce email configuration, it's set to use the token [commerce-order:payment-method-short-title]

$payment_method = commerce_payment_method_instance_load('bank_transfer|commerce_payment_bank_transfer');

 $charge = $order-&gt;commerce_order_total['und'][0];


$transaction = commerce_payment_transaction_new('bank_transfer', $order-&gt;order_id);
$transaction-&gt;instance_id = $payment_method['instance_id'];
$transaction-&gt;amount = $charge['amount'];
$transaction-&gt;currency_code = $charge['currency_code'];
$transaction-&gt;status = COMMERCE_PAYMENT_STATUS_SUCCESS;
$transaction-&gt;message = 'Name: @name';
$transaction-&gt;message_variables = array('@name' =&gt; 'Add to Account');

commerce_payment_transaction_save($transaction);
commerce_payment_commerce_payment_transaction_insert($transaction);
commerce_checkout_complete($order);
commerce_order_save($order);
I now found the solution, I need to add the payment method to the order object, so the token system can pick it up and use in the order email.

Before save the order, we need to add the payment method.

$order-&gt;data['payment_method'] = 'bank_transfer|commerce_payment_bank_transfer';
commerce_order_save($order);


It can be placed before the transaction section.