You are here

function payment_ubercart_payment_status_change in Payment for Ubercart 7.2

Same name and namespace in other branches
  1. 7 payment_ubercart.module \payment_ubercart_payment_status_change()

Implements hook_payment_status_change().

File

./payment_ubercart.module, line 155
Hook implementations and shared functions.

Code

function payment_ubercart_payment_status_change(Payment $payment, PaymentStatusItem $previous_status_item) {
  if ($payment->context == 'payment_ubercart') {
    if (payment_ubercart_order_id_load($payment)) {
      if (!payment_status_is_or_has_ancestor($previous_status_item->status, PAYMENT_STATUS_SUCCESS) && payment_status_is_or_has_ancestor($payment
        ->getStatus()->status, PAYMENT_STATUS_SUCCESS)) {
        $order = uc_order_load($payment->payment_ubercart_uc_order_id);
        uc_payment_enter($order->order_id, 'payment_ubercart_' . $payment->method->pmid, $payment
          ->totalAmount(TRUE), $payment->uid, NULL, '', $payment
          ->getStatus()->created);
        uc_cart_complete_sale($order, FALSE);
      }
    }
  }
}