/** * Update cart payment with returned results and complete sale or return an error * * @param $arrPaymentResult * @return bool */ protected function finalizeOrder($arrPaymentResult) { $objCart = Yii::app()->shoppingcart; $objPayment = $objCart->payment; $objPayment->payment_data = $arrPaymentResult['result']; $objPayment->payment_amount = $arrPaymentResult['amount_paid']; $objPayment->datetime_posted = isset($retVal['payment_date']) ? date("Y-m-d H:i:s", strtotime($retVal['payment_date'])) : new CDbExpression('NOW()'); $objPayment->save(); if (isset($arrPaymentResult['success']) && $arrPaymentResult['success']) { Yii::log("Payment Success! Wrapping up processing", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); // We have successful payment, so close out the order and show the receipt. $objCart->printed_notes .= $this->checkoutForm->orderNotes; $objCart->completeUpdatePromoCode(); Checkout::emailReceipts($objCart); Checkout::finalizeCheckout($objCart, true, true); return true; } else { $error = isset($arrPaymentResult['result']) ? $arrPaymentResult['result'] : "UNKNOWN ERROR"; $this->checkoutForm->addErrors(array('payment' => $error)); Yii::log("Error executing payment:\n" . $error, 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__); return false; } }