/** * Our SIM Payment handling function * * @return void * @throws CHttpException */ public function runPaymentSim() { Yii::log('Attempting to complete SIM payment... ', 'info', 'application.' . __CLASS__ . '.' . __FUNCTION__); $objCart = Yii::app()->shoppingcart; $objPayment = $objCart->payment; if (!$objPayment instanceof CartPayment) { throw new CHttpException(500, 'Cart Payment missing'); } Yii::log("Running payment on " . $objCart->id_str, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $paymentSubFormModel = $this->checkoutForm->getPaymentSubFormModel(); //See if we have a subform for our payment module (ex. purchase order), set that as part of running payment module if (isset($paymentSubFormModel)) { $paymentSubFormModel->attributes = $this->checkoutForm->subFormModel; $arrPaymentResult = Yii::app()->getComponent($objPayment->payment_module)->setCheckoutForm($this->checkoutForm)->setSubForm($paymentSubFormModel)->run(); } else { $arrPaymentResult = Yii::app()->getComponent($objPayment->payment_module)->setCheckoutForm($this->checkoutForm)->run(); } Yii::log(print_r($arrPaymentResult, true), 'info', 'application.' . __CLASS__ . '.' . __FUNCTION__); // SIM Credit Card method with form? Then render it if (isset($arrPaymentResult['jump_form'])) { Yii::log("Using jump FORM: {$objPayment->payment_module}", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $objCart->printed_notes .= $this->checkoutForm->orderNotes; $objCart->cart_type = CartType::awaitpayment; $objCart->status = OrderStatus::AwaitingPayment; $objCart->completeUpdatePromoCode(); $this->layout = '/layouts/checkout-column2'; Yii::app()->clientScript->registerScript('submit', '$(document).ready(function(){ $("form:first").submit(); });'); $this->render('jumper', array('form' => $arrPaymentResult['jump_form'])); } elseif (isset($arrPaymentResult['jump_url']) && $arrPaymentResult['jump_url']) { Yii::log("Using jump URL: {$objPayment->payment_module}", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $objCart->printed_notes .= $this->checkoutForm->orderNotes; $objCart->cart_type = CartType::awaitpayment; $objCart->save(); $objCart->completeUpdatePromoCode(); $this->redirect($arrPaymentResult['jump_url']); } elseif (isset($arrPaymentResult['errorMessage'])) { Yii::app()->user->setFlash('error', $arrPaymentResult['errorMessage']); $this->redirect($this->createAbsoluteUrl('/checkout/confirmation/')); } else { // If we are this far then we have a no cc SIM method (COD, Phone Order, Check, etc.) $linkid = $objCart->linkid; $this->finalizeOrder($arrPaymentResult); $this->redirect($this->createAbsoluteUrl('/checkout/thankyou/' . $linkid)); } }