public function indexAction() { try { $user_transaction_form = new Application_Form_UserTransactionsForm(); $this->view->form = $user_transaction_form; $userTransactionsMapper = new Application_Model_UserTransactionsMapper(); $userTransaction = new Application_Model_UserTransactions(); $request = $this->getRequest(); if ($request->isPost()) { $request_type = $request->getParam("request_type", false); if ($request_type) { if ($request_type == "add") { $params = $request->getParams(); if ($user_transaction_form->isValid($params)) { foreach ($params as $param => $value) { $userTransaction->__set($param, $value); } if ($userTransactionsMapper->addNewUserTransaction($userTransaction)) { $this->view->message = "Transaction added successfully"; $this->view->hasMessage = true; $this->view->messageType = "success"; } else { $this->view->message = "Error occured while adding. Please try again"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } else { $this->view->message = "Error occured while Adding. Please fill form correctly"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } elseif ($request_type == "delete") { $id = $request->getParam("id"); if ($userTransactionsMapper->deleteUserTransactionById($id)) { $this->view->hasMessage = true; $this->view->messageType = "success"; $this->view->message = "Transaction deleted successfully."; } else { $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = "Error occured while deleting. Please try again."; } } } } $transactions = $userTransactionsMapper->getAllUserTransactions(); $this->view->transactions = $transactions; $this->authorised = true; $usersMapper = new Application_Model_UsersMapper(); $this->view->usersMapper = $usersMapper; } catch (Exception $ex) { $this->authorised = false; $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = $ex->getMessage(); } }
public function updateUserTransaction(Application_Model_UserTransactions $user_transaction) { $data = array('trnx_order_id' => $user_transaction->__get("trnx_order_id"), 'trnx_user_id' => $user_transaction->__get("trnx_user_id"), 'other_details' => $user_transaction->__get("other_details"), 'gateway_transaction_id' => $user_transaction->__get("gateway_transaction_id"), 'trnx_amount' => $user_transaction->__get("trnx_amount"), 'trnx_method' => $user_transaction->__get("trnx_method"), 'trnx_status' => $user_transaction->__get("trnx_status"), 'added_timestamp' => $user_transaction->__get("added_timestamp")); $where = "trnx_id = " . $user_transaction->__get("trnx_id"); $result = $this->_db_table->update($data, $where); if (count($result) == 0) { return false; } else { return true; } }
public static function getInstance() { if (!is_object(self::$_instance)) { //or if( is_null(self::$_instance) ) or if( self::$_instance == null ) self::$_instance = new Application_Model_UserTransactions(); } return self::$_instance; }
public function successAction() { try { // $userWalletMapper = new Application_Model_UserWalletMapper(); // $userWallet = new Application_Model_UserWallet(); // $userPackagesMapper = new Application_Model_UserPackagesMapper(); // $userPackages = new Application_Model_UserPackages(); $userTrackMapper = new Application_Model_UserTrackMapper(); $userTrack = new Application_Model_UserTrack(); $ordersMapper = new Application_Model_OrdersMapper(); // $packagesMapper = new Application_Model_PackagesMapper(); $userTransactionsMapper = new Application_Model_UserTransactionsMapper(); $userTransactions = new Application_Model_UserTransactions(); $request = $this->getRequest(); $status = $request->getParam("status"); $fname = $request->getParam("firstname"); $amount = $request->getParam("amount"); $txnid = $request->getParam("txnid"); $posted_hash = $request->getParam("hash"); $product_info = $request->getParam("productinfo"); $key = $request->getParam("key"); $email = $request->getParam("email"); $code = $request->getParam("bankcode"); $salt = "dwf1Ltip"; //test salt $salt = "GQs7yium"; $retHashSeq = $salt . '|' . $status . '|||||||||||' . $email . '|' . $fname . '|' . $product_info . '|' . $amount . '|' . $txnid . '|' . $key; $hash = hash("sha512", $retHashSeq); $infos = explode("|", $product_info); $transaction_type = explode(":", $infos[0]); $transaction_type = $transaction_type[1]; //echo $transaction_type;exit; $user_id = explode(":", $infos[1]); $user_id = $user_id[1]; $id = explode(":", $infos[2]); $id = $id[1]; $package_id = explode(":", $infos[3]); $package_id = $package_id[1]; if ($user_id != 0) { $userTransactions->__set("trnx_user_id", $user_id); $userTransactions->__set("other_details", $transaction_type); $userTransactions->__set("gateway_transaction_id", $txnid); $userTransactions->__set("trnx_amount", $amount); $userTransactions->__set("trnx_method", $code); $userTransactions->__set("trnx_status", $status); $userTransactions->__set("trnx_order_id", $id); $userTransactionsMapper->addNewUserTransaction($userTransactions); } if ($hash != $posted_hash) { throw new Exception("Invalid Transaction"); } else { $flag = TRUE; $this->view->flag = $flag; if ($transaction_type == "Package") { //echo "in"; $package = $packagesMapper->getPackageById($package_id); $number_clothes = $package->__get("no_of_clothes"); $number_pickups = $package->__get("no_of_pickups"); //echo $number_pickups;exit; $validity = $package->__get("validity"); //echo $validity;exit; $zend_date = new Zend_Date(); $date = $zend_date->addMonth($validity); $new_date = $date->toString("dd-MM-yyyy"); $userTrack->__set("usertrack_user_id", $user_id); $userTrack->__set("track_type", 'package'); $userTrack->__set("usertrack_package_id", $package_id); $userTrack->__set("clothes_left", $number_clothes); $userTrack->__set("clothes_availed", $number_clothes); $userTrack->__set("pickups_left", $number_pickups); $userTrack->__set("pickups_availed", $number_pickups); $userTrack->__set("usertrack_start_date", date('Y-m-d')); $userTrack->__set("usertrack_expiry_date", $new_date); if ($userTrackMapper->addNewTrack(addNewTrack)) { $this->view->hasMessage = true; $this->view->messageType = "success"; $this->view->message = "Profile Updated successfully"; } else { $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = "Error while updating"; } } elseif ($transaction_type == "Online") { $order = $ordersMapper->getOrderById($id); $order->__set("order_payment_status", "Paid"); $ordersMapper->updateOrder($order); } $this->_redirect('index/orderlist'); } } catch (Exception $e) { $e->getMessage(); } }
public function transactionProcessAction() { $usertransactionModal = Application_Model_UserTransactions::getInstance(); $cartiddetailsModel = Application_Model_Addtocart::getInstance(); $userdeliveryaddrmodal = Application_Model_UserDeliveryAddress::getInstance(); $orderaddressmodal = Application_Model_OrderAddress::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); $objCore = Engine_Core_Core::getInstance(); $this->_appSetting = $objCore->getAppSetting(); if ($method) { switch ($method) { case 'inserttransaction': if ($this->getRequest()->isPost()) { $tranType = $this->getRequest()->getPost('transactiontype'); if ($tranType == 1) { $orderid = $this->getRequest()->getPost('order_id'); $userid = $this->getRequest()->getPost('userid'); $tranAmount = $this->getRequest()->getPost('amount'); $tranDate = $this->getRequest()->getPost('date'); $tranStatus = $this->getRequest()->getPost('status'); $cod_code = mt_rand(100000, 999999); $result = array_merge(['order_id' => $orderid], ['user_id' => $userid], ['tx_amount' => $tranAmount], ['tx_date' => $tranDate], ['tx_status' => $tranStatus], ['tx_type' => $tranType], ['COD_Code' => $cod_code]); $transactionId = $usertransactionModal->insertUseTransactions($result); if ($transactionId) { $account_sid = $this->_appSetting->AccountSID; $auth_token = $this->_appSetting->AuthToken; $client = new Services_Twilio($account_sid, $auth_token); $smsResponse = $client->account->messages->create(array('To' => "+919713902664", 'From' => "+17474002298", 'Body' => $cod_code)); if ($smsResponse) { $response->message = 'successfully Inserted,SMS Sent to your corresponding Mobile number.'; $response->code = 200; $response->data['transaction_id'] = $transactionId; } else { $response->message = 'Fail to send Message'; $response->code = 197; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; } } else { if ($tranType == 2) { $orderid = $this->getRequest()->getPost('order_id'); $userid = $this->getRequest()->getPost('userid'); $tranAmount = $this->getRequest()->getPost('amount'); $tranDate = $this->getRequest()->getPost('date'); $tranStatus = $this->getRequest()->getPost('status'); $trancode = $this->getRequest()->getPost('transactioncode'); $cartid = $this->getRequest()->getPost('cartID'); $cartid = json_decode($cartid); $data1 = array_merge(['order_id' => $orderid], ['user_id' => $userid], ['tx_amount' => $tranAmount], ['tx_date' => $tranDate], ['tx_status' => $tranStatus], ['tx_type' => $tranType], ['tx_code' => $trancode]); $transactionId1 = $usertransactionModal->insertUseTransactions($data1); if ($transactionId1) { $fetchorderid = $usertransactionModal->fetchorderdetails($transactionId1); if ($fetchorderid['tx_status'] == 1) { $deletecartiddetails = $cartiddetailsModel->deletecartiddetails($cartid); if ($deletecartiddetails) { $response->message = 'successfully Inserted Transaction Details,Cleared From Cart.'; $response->code = 200; $response->data['transaction_id'] = $transactionId1; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; } // } } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; } } else { $response->code = 198; $response->message = "Required parameter not passed"; } } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } echo json_encode($response, true); die; break; case 'updatetransaction': if ($this->getRequest()->isPost()) { $txstatus = $this->getRequest()->getPost('status'); if (!empty($txstatus)) { $data['tx_status'] = $txstatus; } $orderid = $this->getRequest()->getPost('order_id'); $userid = $this->getRequest()->getPost('userid'); if ($userid && $orderid) { $update = $usertransactionModal->updateTransaction($userid, $orderid, $data); if ($update) { $response->message = 'successfull'; $response->code = 200; $response->data = $update; } else { $response->message = 'Could Not Serve The Request'; $response->code = 197; $response->data = $update; } } else { $response->message = 'Could Not Serve The Request'; $response->code = 401; $response->data = NULL; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; } echo json_encode($response, true); die; break; // case 'insertCod_code': // // if ($this->getRequest()->isPost()) { // // $postData = $this->getRequest()->getParams(); // // $orderid = ''; // if (isset($postData['order_id'])) { // $orderid = $postData['order_id']; // } // // if ($orderid != '') { // // $cod_code = mt_rand(100000, 999999); // // $exists = $usertransactionModal->checkOrderid($orderid, $cod_code); // // if (isset($exists)) { // //// $account_sid = 'AC91e39267660f124881c6eb071867b1fc'; //// $auth_token = 'cd5d73f4fef7d4fcb63a57e0558ca8d7'; // $account_sid = $this->_appSetting->AccountSID; // // $auth_token = $this->_appSetting->AuthToken; // // $client = new Services_Twilio($account_sid, $auth_token); // // $smsResponse = $client->account->messages->create(array( //// 'To' => "+919850014148", // 'To' => "+919713902664", // 'From' => "+17474002298", // 'Body' => $cod_code, // )); // // $response->code = 200; // $response->message = "SMS Sent to your corresponding Mobile number."; // $response->data = 1; // } else { // $response->code = 100; // $response->message = "OrderId is not correct."; // $response->data = null; // } // } else { // $response->code = 100; // $response->message = "Orderid Should not be null"; // $response->data = null; // } // } else { // $response->code = 401; // $response->message = "Invalid request"; // $response->data = null; // } // echo json_encode($response, true); // break; // case 'insertCod_code': // // if ($this->getRequest()->isPost()) { // // $postData = $this->getRequest()->getParams(); // // $orderid = ''; // if (isset($postData['order_id'])) { // $orderid = $postData['order_id']; // } // // if ($orderid != '') { // // $cod_code = mt_rand(100000, 999999); // // $exists = $usertransactionModal->checkOrderid($orderid, $cod_code); // // if (isset($exists)) { // //// $account_sid = 'AC91e39267660f124881c6eb071867b1fc'; //// $auth_token = 'cd5d73f4fef7d4fcb63a57e0558ca8d7'; // $account_sid = $this->_appSetting->AccountSID; // // $auth_token = $this->_appSetting->AuthToken; // // $client = new Services_Twilio($account_sid, $auth_token); // // $smsResponse = $client->account->messages->create(array( //// 'To' => "+919850014148", // 'To' => "+919713902664", // 'From' => "+17474002298", // 'Body' => $cod_code, // )); // // $response->code = 200; // $response->message = "SMS Sent to your corresponding Mobile number."; // $response->data = 1; // } else { // $response->code = 100; // $response->message = "OrderId is not correct."; // $response->data = null; // } // } else { // $response->code = 100; // $response->message = "Orderid Should not be null"; // $response->data = null; // } // } else { // $response->code = 401; // $response->message = "Invalid request"; // $response->data = null; // } // echo json_encode($response, true); // break; case 'varifyCod_code': if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $orderid = ''; if (isset($postData['order_id'])) { $orderid = $postData['order_id']; } $codcode = ''; if (isset($postData['COD_Code'])) { $codcode = $postData['COD_Code']; } $cartid = $this->getRequest()->getPost('cartID'); $cartid = json_decode($cartid); if ($orderid != '' && $codcode != '' && $cartid != '') { $exists = $usertransactionModal->verifycodCode($orderid, $codcode); if ($exists) { $fetchorderid = $usertransactionModal->fetchorderdetails($orderid); if ($fetchorderid['tx_status'] == 1) { $deletecartiddetails = $cartiddetailsModel->deletecartiddetails($cartid); $response->code = 200; $response->message = "Code Verify Successfully"; $response->data = $exists; } else { $response->code = 100; $response->message = "You missed something"; $response->data = null; } } else { $response->code = 100; $response->message = "Code Didnt Matched, Enter Correct Code."; $response->data = null; } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); break; case 'verifyPhoneNumber': if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $addressid = ''; if (isset($postData['addressid'])) { $addressid = $postData['addressid']; } $oldphonenumber = ''; if (isset($postData['oldContactNo'])) { $oldphonenumber = $postData['oldContactNo']; } $newphonenumber = ''; if (isset($postData['newContactNo'])) { $newphonenumber = $postData['newContactNo']; } $fetchdetailsfromBoth = $userdeliveryaddrmodal->fetchDetails($addressid); $orderaddressid = $fetchdetailsfromBoth['order_address_id']; if ($addressid != '') { $fetchaddressdetails = $userdeliveryaddrmodal->fetchUserDeliveryAddressByAddressID($addressid, $oldphonenumber); if ($fetchaddressdetails) { if ($oldphonenumber != '' && $newphonenumber != '') { $updateData['user_contact_number'] = $newphonenumber; $whereForUpdate = 'user_delivery_address_id=' . $addressid; $updateUserDeliveryAddress = $userdeliveryaddrmodal->updateUserDeliveryAddressWhere($updateData, $whereForUpdate); if (isset($updateUserDeliveryAddress)) { $updateData['user_contact_number'] = $newphonenumber; $whereForUpdate = 'order_address_id=' . $orderaddressid; $updateorderaddress = $orderaddressmodal->updateorderaddressWhere($updateData, $whereForUpdate); if (isset($updateorderaddress)) { $response->code = 200; $response->message = "Your Phone Number Updated Successfully"; $response->data = 1; } else { $response->code = 100; $response->message = "Something Went wrong"; $response->data = null; } } else { $response->code = 100; $response->message = "Something Went wrong."; $response->data = null; } } else { $response->code = 100; $response->message = "Missing Parameter"; $response->data = null; } } else { $response->code = 401; $response->message = "Incorrect Old Phone Number"; $response->data = null; } } else { $response->code = 100; $response->message = "AddressID Should not be null"; $response->data = null; } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); break; } } else { $response->message = 'Invalid Request'; $response->code = 401; $response->data = Null; echo json_encode($response); die; } }