function payment_commerce_payment_fill in Payment for Drupal Commerce 7.2
Fill a Payment with data from a Commerce order.
Parameters
Payment $payment: The payment to fill with order data.
$order: The order to base the payment on.
integer $pmid: The PMID of the payment method to use for the payment.
Return value
4 calls to payment_commerce_payment_fill()
- PaymentCommerceDeleteOrderWebTestCase::assertCreateAndDeleteOrderAndPayment in tests/
PaymentCommerceDeleteOrderWebTestCase.test - Creates an order, transaction and Payment, and then deletes them.
- payment_commerce_form_process_submit_form in ./
payment_commerce.module - Implements form process callback for payment_commerce_submit_form().
- payment_commerce_form_process_submit_form_submit in ./
payment_commerce.module - Implements CALLBACK_commerce_payment_method_submit_form_submit().
- payment_commerce_payment_method_validate in ./
payment_commerce.rules.inc - Implements Rules plugin callback.
File
- ./
payment_commerce.module, line 324 - Hook implementations and shared functions.
Code
function payment_commerce_payment_fill(Payment $payment, $order, $pmid) {
$balance = commerce_payment_order_balance($order);
$payment->context = 'payment_commerce';
$payment->context_data = array(
'balance_amount' => $balance['amount'],
'order_id' => $order->order_id,
);
$payment->description = t('Order !order_number', array(
'!order_number' => $order->order_number,
));
$payment->currency_code = $balance['currency_code'];
$payment->method = entity_load_single('payment_method', $pmid);
$payment->finish_callback = 'payment_commerce_payment_finish';
$payment
->setLineItem(new PaymentLineItem(array(
'amount' => $balance['amount'],
'description' => 'Order !order_number',
'description_arguments' => array(
'!order_number' => $order->order_number,
),
'name' => 'payment_commerce',
)));
return $payment;
}