How to handle tokens in Rules field? I have duplicated Drupal Commerce module "Cash on delivery", from which I am trying to make custom module, where if customer choose as payment method my new payment, it will simply print out text with tokens inside.
(This is because client needs to be able to pair orders with payments sent by credit card directly to his account, he will pair them with commerce order number)

I have successfully made a textarea in rules UI even with token field under this area, now I have to print them.

Working code for making textarea:

function bankovy_prevod_settings_form($settings = NULL) {

  $settings = (array) $settings + array(
    'information' =&gt; '',
    'var_symbol' =&gt; ''
  );

  $form = array();

  $form['information'] = array(
    '#type' =&gt; 'textarea',
    '#title' =&gt; t('Information'),
    '#description' =&gt; t('Informácie, ktoré chcete zobraziť zákazníkom, keď si navolia túto možnosť platby.'),
    '#default_value' =&gt; $settings['information']
  );

  $form['var_symbol'] = array(
    '#type' =&gt; 'textarea',
    '#title' =&gt; t('Variabilný symbol'),
    '#description' =&gt; t('Sem vložte token, na základe ktorého sa bude generovať variabilný symbol.'),
    '#default_value' =&gt; $settings['var_symbol']
  );

    if (module_exists('token')) {
      $form['token_help'] = array(
        '#theme' =&gt; 'token_tree',
        '#token_types' =&gt; array('commerce-order'),
      );
    }

  return $form;
}


Code for displaying the output on commerce order:

function bankovy_prevod_submit_form($payment_method, $pane_values, $checkout_pane, $order) {
  $form = array();

  $var_symbol = "";
  if (!empty($payment_method['settings']['var_symbol'])) {
      $var_symbol = token_replace($payment_method['settings']['var_symbol'], array('node' =&gt; $form['commerce_checkout_form']));
  }

  if (!empty($payment_method['settings']['information'])) {
    $form['grafeon_bankovy_prevod_description'] = array(
      '#markup' =&gt; $payment_method['settings']['information'] . "&lt;br/&gt;" . $var_symbol
    );
  }


  // Need to create a dummy value to solve http://drupal.org/node/1230666
  // Probably an issue in the main commerce module
  $form['dummy'] = array(
    '#type' =&gt; 'hidden',
    '#value' =&gt; 'dummy'
  );


  return $form;
}


Now I have to somehow replace tokens, trying to use function token_replace, but it does not seem to work with "node" as checkout is not node, so I tried various different "commerce_checkout_form" strings but neither of them worked. Can anyone please help me out to solve this? 

Thats the part I have problem with:

$var_symbol = token_replace($payment_method['settings']['var_symbol'], array('node' =&gt; $form['commerce_checkout_form']));


Any advice would be greatly appreciated.
Just needed to replace this one field with this:

$var_symbol = token_replace($payment_method['settings']['var_symbol'], array('commerce-order' =&gt; $order));


Now it works perfectly.