You are here

function uc_payment_enter in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 payment/uc_payment/uc_payment.module \uc_payment_enter()
  2. 5 payment/uc_payment/uc_payment.module \uc_payment_enter()
  3. 7.3 payment/uc_payment/uc_payment.module \uc_payment_enter()

Enters a payment for an order.

Parameters

$order_id: The order ID to apply the payment to.

$method: The payment method ID.

$amount: The amount of the payment.

$uid: (optional) The user ID of the person logging the payment, or 0 if the payment was processed automatically.

$data: (optional) Any data that should be serialized and stored with the payment.

$comment: (optional) The comment to enter in the payment log.

$received: (optional) The timestamp at which the payment was received.

Return value

A unique ID identifying the payment.

9 calls to uc_payment_enter()
UbercartCartCheckoutTestCase::testCheckoutComplete in uc_cart/uc_cart.test
UbercartCartCheckoutTestCase::testCheckoutRoleAssignment in uc_cart/uc_cart.test
UbercartRolesTestCase::testRolePurchaseCheckout in uc_roles/uc_roles.test
uc_2checkout_complete in payment/uc_2checkout/uc_2checkout.pages.inc
@file 2checkout menu items.
uc_cybersource_hop_post in payment/uc_cybersource/uc_cybersource.module

... See full list

File

payment/uc_payment/uc_payment.module, line 641

Code

function uc_payment_enter($order_id, $method, $amount, $uid = 0, $data = NULL, $comment = '', $received = NULL) {
  if ($received == NULL) {
    $received = time();
  }
  $method_name = _payment_method_data($method, 'review');
  if (empty($method_name)) {
    $method_name = _payment_method_data($method, 'name');
  }
  if (is_null($method_name)) {
    $method_name = t('Other');
  }
  if (is_array($data)) {
    $data = serialize($data);
  }
  if (variable_get('uc_payment_logging', TRUE)) {
    global $user;
    $context = array(
      'revision' => 'formatted',
      'type' => 'amount',
    );
    $log_message = t('@method payment for @amount entered by @user.', array(
      '@method' => $method_name,
      '@amount' => uc_price($amount, $context),
      '@user' => uc_get_initials($user->uid),
    ));
    uc_order_log_changes($order_id, array(
      $log_message,
    ));
  }
  db_query("INSERT INTO {uc_payment_receipts} (order_id, method, amount, uid, data, comment, received) VALUES (%d, '%s', %f, %d, '%s', '%s', %d)", $order_id, $method_name, $amount, $uid, $data, $comment, $received);
  $receipt_id = db_last_insert_id('uc_payment_receipts', 'receipt_id');
  $order = uc_order_load($order_id);
  $account = user_load($uid);

  // Ensure user has an account before payment is made.
  uc_cart_complete_sale($order);
  module_invoke_all('uc_payment_entered', $order, $method, $amount, $account, $data, $comment);
  ca_pull_trigger('uc_payment_entered', $order, $account);
  return $receipt_id;
}