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->commerce_order_total['und'][0];
$transaction = commerce_payment_transaction_new('bank_transfer', $order->order_id);
$transaction->instance_id = $payment_method['instance_id'];
$transaction->amount = $charge['amount'];
$transaction->currency_code = $charge['currency_code'];
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
$transaction->message = 'Name: @name';
$transaction->message_variables = array('@name' => 'Add to Account');
commerce_payment_transaction_save($transaction);
commerce_payment_commerce_payment_transaction_insert($transaction);
commerce_checkout_complete($order);
commerce_order_save($order);