You are here

function paymentreference_page_finish in Payment 7

Menu page callback to call after a payment reference payment has finished.

Return value

integer|array

1 string reference to 'paymentreference_page_finish'
paymentreference_menu in modules/paymentreference/paymentreference.module
Implements hook_menu().

File

modules/paymentreference/paymentreference.module, line 481
Hook implementations and general functions.

Code

function paymentreference_page_finish() {
  if (isset($_SESSION['paymentreference_pid'])) {

    // Assign the PID to the local scope and remove it from the session.
    $pid = $_SESSION['paymentreference_pid'];
    unset($_SESSION['paymentreference_pid']);

    // Load the payment and the instance it's for, and build the page.
    if ($payment = entity_load_single('payment', $pid)) {
      $instance_info = paymentreference_load_instance($pid, $payment->uid);
      $instance = field_info_instance($instance_info['entity_type'], $instance_info['field_name'], $instance_info['bundle']);
      drupal_set_title($instance['label']);
      return array(
        '#type' => 'markup',
        '#markup' => t('Your payment is %status. You can now <span class="paymentreference-window-close">close this window</span>.', array(
          '%status' => payment_status_info($payment
            ->getStatus()->status, TRUE)->title,
        )),
        '#attached' => array(
          'js' => array(
            drupal_get_path('module', 'paymentreference') . '/js/paymentreference.js',
          ),
        ),
      );
    }
  }
  return MENU_ACCESS_DENIED;
}