You are here

function payment_form_standalone_submit in Payment 7

Implements form submit callback for payment_form().

1 string reference to 'payment_form_standalone_submit'
payment_form_standalone in ./payment.ui.inc
Implements form build callback: the payment add/edit form.

File

./payment.ui.inc, line 186
The Payment user interface.

Code

function payment_form_standalone_submit(array $form, array &$form_state) {

  /** @var Payment $payment */
  $payment = $form_state['payment'];

  // Save the payment.
  entity_save('payment', $payment);

  // Execute the payment.
  if ($payment
    ->getStatus()->status == PAYMENT_STATUS_NEW) {
    $payment
      ->execute();
  }
  if (payment_status_is_or_has_ancestor($payment
    ->getStatus()->status, PAYMENT_STATUS_FAILED)) {
    $form_state['rebuild'] = TRUE;
  }

  // Redirect the user.
  if (payment_access('view', $payment)) {
    $form_state['redirect'] = 'payment/' . $payment->pid;
  }
}