You are here

function basic_cart_payment_node_submit in Basic cart 7.3

Implements hook_node_submit().

File

basic_cart_payment/basic_cart_payment.module, line 85

Code

function basic_cart_payment_node_submit($node, $form, &$form_state) {
  if ($node->type == 'order') {

    // Executing the payment.
    $payment = $form_state['payment'];
    entity_save('payment', $payment);

    // Setting the pid for this payment so that it can be registered when hook_node_insert is called.
    basic_cart_payment_pid($payment->pid);

    // Every payment method redirects the user to the payment site, except for the dummy test one.
    if ($payment->method->name != 'basic_payment_method') {

      // Saving the node. Since we are about to redirect to the payment site, the
      // order node hasn't been saved yet.
      node_save($node);
    }
    $payment
      ->execute();
  }
}