public function actionIndex() { $settings = app()->settings; $config = array(); $paymentClasses = new PaymentGatewayHelper(); $allPaymentClassesArray = $paymentClasses->getSubClasses(); foreach ($allPaymentClassesArray as $key => $value) { $paymentClass = new $key(); $config['elements'][$paymentClass->getPaymentName()] = $paymentClass->settingsArray; } if (isset($_POST['SettingsForm'])) { //print_r($_POST['SettingsForm']); $settings->deleteCache(); foreach ($_POST['SettingsForm'] as $category => $values) { $settings->set($category, $values); } user()->setFlash('success', 'Site settings were updated.'); $this->refresh(); } foreach ($config['elements'] as $category => &$attributes) { foreach ($attributes['elements'] as &$attribute) { $attribute['value'] = $settings->get($category, $attribute['name']); } } $this->render('index', array('config' => $config)); }
public function actionView() { //if(!empty($_GET['txnref']) || !empty($_GET['payRef']) || !empty($_GET['retRef'])){ //exit($_GET['payment']); $json = array(); $ref = isset($_POST['txnref']) ? $_POST['txnref'] : null; $returnPayment = $_GET['payment']; $subClasses = new PaymentGatewayHelper(); $subClassesArray = $subClasses->getSubClasses(); foreach ($subClassesArray as $class => $payOption) { ${$class} = new $class(); ${$class}->getPaymentName() == $returnPayment; } Yii::app()->user->setState('user_cart', NULL); $this->render('view', array('response' => $json, 'ref' => $ref)); //exit($_GET['payment']); /*if(!empty($_POST['txnref']) || !empty($_POST['payRef']) || !empty($_POST['retRef'])){ $json = array(); $ref = $_POST['txnref']; $order = UtilityHelper::callInterswitch($ref,$json); $message = "Error call"; //UtilityHelper::sendToLog($ref); Yii::app()->user->setState('user_cart', NULL); $this->render('view',array('response'=>$json, 'ref'=>$ref)); }else throw new CHttpException(400, Yii::t('info', 'Your request is invalid.')); */ }
public function __construct() { $paymentClasses = new PaymentGatewayHelper(); $allPaymentClassesArray = $paymentClasses->getSubClasses(); //$this->allPaymentClassesArray= $paymentClasses->getSubClasses(); foreach ($allPaymentClassesArray as $key => $value) { //echo $key . ' ' . $value . '<br/>'; $paymentClass = new $key(); array_push($this->allPaymentClassesArray, $paymentClass->settingsArray); //print_r($paymentClass->settingsArray); echo '<br/><br/>'; } print_r($this->allPaymentClassesArray); //exit('End'); }
<div class="checkout_head_general"> <div class="clearfix"></div> </div> <div class="section_body_general"> <div class="checkout_wrapper"> <?php //exit(print_r($_POST)); $returnPayment = $_GET['payment']; $subClasses = new PaymentGatewayHelper(); $subClassesArray = $subClasses->getSubClasses(); foreach ($subClassesArray as $class => $payOption) { ${$class} = new $class(); ${$class}->getPaymentName() == $returnPayment; ${$class}->checkResponse($_POST, $ref); } ?> </div> </div>
public function actionPayment($id) { $cart = $this->getCart(); $add = CheckoutAddress::model()->findByPk($id); $link; $onlinePaymentMethodName; $extrapObj = array(); $orderArray = array(); $classArray = array(); if (!empty($add) && !empty($cart['items'])) { if (isset($_POST['Payment']['payment_method'])) { $pay_method = $_POST['Payment']['payment_method']; $cart['payment'] = $pay_method == 4 ? 2 : $pay_method; $paymentType = is_numeric($pay_method) ? 'others' : 'online'; $order = new Order(); $order->order_status_id = 1; $order->total = $this->getCartTotal(); $order->ip = Yii::app()->request->userHostAddress; $order->user_agent = Yii::app()->request->userAgent; $order->firstname = $add->firstname; $order->lastname = $add->lastname; $order->email = $add->email; $order->telephone = $add->telephone; $order->payment_firstname = $add->firstname; $order->payment_lastname = $add->lastname; $order->payment_company = ''; $order->payment_tax_id = 0; $order->payment_address_1 = $add->address_1; $order->payment_address_2 = $add->address_2; $order->payment_city = $add->city; $order->payment_postcode = $add->postal_code; $order->payment_country_id = $add->country_id; $order->payment_zone_id = $add->zone_id; $order->payment_method = $cart['payment']; $order->payment_code = uniqid() . rand(1, 9); $order->shipping_firstname = $add->firstname; $order->shipping_lastname = $add->lastname; $order->shipping_company = ''; $order->shipping_address_1 = $add->address_1; $order->shipping_address_2 = $add->address_2; $order->shipping_city = $add->city; $order->shipping_postcode = $add->postal_code; $order->shipping_country_id = $add->country_id; $order->shipping_zone_id = $add->zone_id; $order->shipping_method = 2; if ($add->zone_id == 2412) { $order->shipping_method = 1; } $storeid = UtilityHelper::yiiparam('storeID'); $store = Store::model()->findByPk($storeid); $order->store_id = $storeid; $order->store_name = $store->name; $order->store_url = $store->url; $order->payment_country = Country::model()->findByPk($order->payment_country_id)->name; $order->payment_zone = Zone::model()->findByPk($order->payment_zone_id)->name; $order->shipping_country = $order->payment_country; $order->shipping_zone = $order->payment_zone; if ($order->save()) { foreach ($cart['items'] as $product) { $orderproduct = new OrderProduct(); $orderproduct->order_id = $order->id; $orderproduct->product_id = $product['product_id']; $orderproduct->name = $product['name']; $orderproduct->model = $product['model']; $orderproduct->quantity = $product['quantity']; $orderproduct->price = $product['price']; $orderproduct->total = $product['total']; $orderproduct->tax = 0; if ($orderproduct->save()) { if (!empty($product['option'])) { foreach ($product['option'] as $orderoption) { $orderoption->order_id = $order->id; $orderoption->order_product_id = $orderproduct->id; $orderoption->save(); } } } else { Yii::log("CartPaymentOrderProductErrors: " . CVarDumper::dumpAsString($orderproduct->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment"); } } //Yii::app()->user->setState('user_cart', NULL); $extrap = array(); // switch ($paymentType) { case 'others': // Will need to loop through the ids for non online payment to do this properly if ($pay_method == 1) { $link = '_cash'; $extrap = array('orderID' => $order->id, 'total' => $order->total); UtilityHelper::changeOrderStatus($order->id); } else { if ($pay_method == 3) { $link = '_bank'; $extrap = array('orderID' => $order->id, 'total' => $order->total); } } break; case 'online': $subClasses = new PaymentGatewayHelper(); $subClassesArray = $subClasses->getSubClasses(); foreach ($subClassesArray as $class => $payOption) { ${$class} = new $class(); $onlinePaymentMethodName = ${$class}->getPaymentName(); if ($pay_method == $onlinePaymentMethodName) { $link = ${$class}->getViewLink(); ${$class}->setOrderObj($order); $extrapObj = ${$class}->getOrderObj(); foreach ($extrapObj as $field => $value) { $orderArray[$field] = $value; } $link = ${$class}->getViewLink(); $extrap = array('orderID' => $orderArray['id'], 'total' => $orderArray['total']); ${$class}->regPaymentTransaction($order); $classArray['pay_method'] = $pay_method; } else { continue; } } break; default: break; } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray), false, true); Yii::app()->end(); } $this->render($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray)); Yii::app()->end(); } else { Yii::log("CartPaymentErrors: " . CVarDumper::dumpAsString($order->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment"); } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_payment', array('app' => $add), false, true); Yii::app()->end(); } $this->render('payment', array('app' => $add)); Yii::app()->end(); } $this->redirect(array('cart')); }