function payment_ubercart_payment_create in Payment for Ubercart 7.2
Same name and namespace in other branches
- 7 payment_ubercart.module \payment_ubercart_payment_create()
Creates a payment for an order.
Parameters
object $order:
Return value
1 call to payment_ubercart_payment_create()
- payment_ubercart_callback in ./
payment_ubercart.module - Implements Ubercart payment method callback.
File
- ./
payment_ubercart.module, line 299 - Hook implementations and shared functions.
Code
function payment_ubercart_payment_create($order) {
// Check for an existing payment;
$pids = payment_ubercart_pids_load($order->order_id);
$payment = $pids ? entity_load_single('payment', end($pids)) : NULL;
$pid = $payment && payment_status_is_or_has_ancestor($payment
->getStatus()->status, PAYMENT_STATUS_NEW) ? $payment->pid : 0;
$pmid = (int) str_replace('payment_ubercart_', '', $order->payment_method);
$payment = new Payment(array(
'context' => 'payment_ubercart',
'currency_code' => $order->currency,
'description' => t('Order #!order_id', array(
'!order_id' => $order->order_id,
)),
'finish_callback' => 'payment_ubercart_finish',
'method' => entity_load_single('payment_method', $pmid),
'payment_ubercart_uc_order_id' => $order->order_id,
'pid' => $pid,
));
// Add orders, line items, and hook_uc_order() totals to the payment as line items.
$order->order_total = uc_order_get_total($order);
$balance = uc_payment_balance($order);
$payment
->setLineItem(new PaymentLineItem(array(
'amount' => $balance,
'description' => 'Order !order_id',
'description_arguments' => array(
'!order_id' => $order->order_id,
),
'quantity' => 1,
'name' => 'payment_ubercart_order_balance_',
$order->order_id,
)));
return $payment;
}