You are here

function paymentform_payment_finish in Payment 7

Implements Payment::finish_callback.

1 string reference to 'paymentform_payment_finish'
paymentform_field_formatter_view in modules/paymentform/paymentform.module
Implements hook_field_formatter_view().

File

modules/paymentform/paymentform.module, line 212
Hook implementations and general functions.

Code

function paymentform_payment_finish(Payment $payment) {
  $view = '';
  if (payment_access('view', $payment)) {
    $view = ' ' . l(t('View payment'), 'payment/' . $payment->pid) . '.';
  }
  if (payment_status_is_or_has_ancestor($payment
    ->getStatus()->status, PAYMENT_STATUS_PENDING)) {
    drupal_set_message(t('Your payment is still being processed.') . $view);
  }
  elseif (payment_status_is_or_has_ancestor($payment
    ->getStatus()->status, PAYMENT_STATUS_SUCCESS)) {
    drupal_set_message(t('Your payment was successfully completed.') . $view);
  }
  elseif (payment_status_is_or_has_ancestor($payment
    ->getStatus()->status, PAYMENT_STATUS_FAILED)) {
    drupal_set_message(t('Your payment failed.') . $view);
  }
  $entity = entity_load_single($payment->context_data['entity_type'], $payment->context_data['entity_id']);
  if ($uri = entity_uri($payment->context_data['entity_type'], $entity)) {
    drupal_goto($uri['path'], $uri['options']);
  }
  drupal_goto('<front>');
}