You are here

function paymentform_field_formatter_view in Payment 7

Implements hook_field_formatter_view().

File

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

Code

function paymentform_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  if ($display['type'] == 'paymentform') {
    list($entity_id) = entity_extract_ids($entity_type, $entity);
    $payment = new Payment(array(
      'context_data' => array(
        'entity_type' => $entity_type,
        'entity_id' => $entity_id,
      ),
      'currency_code' => $instance['settings']['currency_code'],
      'description' => $instance['label'],
      'finish_callback' => 'paymentform_payment_finish',
    ));
    foreach ($items as $line_item_data) {
      $payment
        ->setLineItem(new PaymentLineItem($line_item_data));
    }
    return drupal_get_form('payment_form_standalone', $payment);
  }
}