You are here

function commerce_robokassa_build_redirect_form in Commerce robokassa 7

Payment method callback; generation callback for the payment redirect form.

Returns form elements that should be submitted to the redirected payment service; because of the array merge that happens upon return, the service’s URL that should receive the POST variables should be set in the #action property of the returned form array.

1 call to commerce_robokassa_build_redirect_form()
commerce_robokassa_redirect_form in ./commerce_robokassa.module
Payment method callback: redirect form.

File

./commerce_robokassa.module, line 95

Code

function commerce_robokassa_build_redirect_form($form, &$form_state, $order, $settings) {

  // Choose a server to redirect.
  $form['#action'] = commerce_robokassa_server_url($settings['server']);
  $wrapper = entity_metadata_wrapper('commerce_order', $order);
  $currency_code = $wrapper->commerce_order_total->currency_code
    ->value();
  $amount = $wrapper->commerce_order_total->amount
    ->value();

  // Get real price.
  $amount = commerce_currency_amount_to_decimal($amount, $currency_code);
  $form["MrchLogin"] = array(
    '#type' => 'hidden',
    '#value' => commerce_robokassa_get_settings('login'),
  );
  $form["OutSum"] = array(
    '#type' => 'hidden',
    '#value' => $amount,
  );
  $form["InvId"] = array(
    '#type' => 'hidden',
    '#value' => $order->order_id,
  );

  // Calculate signature.
  $form["SignatureValue"] = array(
    '#type' => 'hidden',
    '#value' => md5(commerce_robokassa_get_settings('login') . ':' . $amount . ':' . $order->order_id . ':' . commerce_robokassa_get_settings('pass1')),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Pay via robokassa'),
  );
  return $form;
}