public function index() { //if ($id > 0) { /*$data = array('u_subdomain'=>'neo'); $this->common_model->setupApplication($data);*/ $post = $this->input->post(); if ($post) { $this->form_validation->set_rules('fname', 'First Name', 'trim|required'); $this->form_validation->set_rules('lname', 'Last Name', 'trim|required'); $this->form_validation->set_rules('email', 'Email', 'valid_email|trim|required|is_unique[users.u_email]'); $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[password2]'); $this->form_validation->set_rules('password2', 'Confirm password', 'trim|required'); $this->form_validation->set_rules('website', 'Website', 'trim|required|is_unique[user_plan.up_website]'); $this->form_validation->set_rules('subdomain', 'Subdomain', 'trim|required|is_unique[user_plan.up_subdomain]'); if ($this->form_validation->run()) { $packageId = $post['planSelect']; switch ($packageId) { case 1: $expDate = Date('Y-m-d', strtotime("+20 days")); break; case 2: $expDate = Date('Y-m-d', strtotime("+30 days")); break; case 3: $expDate = Date('Y-m-d', strtotime("+180 days")); break; case 4: $expDate = Date('Y-m-d', strtotime("+365 days")); break; } $insert_data = array('u_fname' => $post['fname'], 'u_lname' => $post['lname'], 'u_email' => $post['email'], 'u_password' => md5($post['password']), 'u_created_date' => date('Y-m-d H:i:s'), 'u_phone' => $post['phone'], 'u_active' => 1); $plan_data = array('up_package_id' => $packageId, 'up_website' => $post['website'], 'up_subdomain' => $post['subdomain'], 'up_created_date' => date('Y-m-d H:i:s'), 'up_package_expiry_date' => $expDate, 'up_status' => 'Active'); if ($packageId != 1) { /* Paypal payment code */ $this->load->helper('paypal'); $paypal = new wp_paypal_gateway(true); $pkgDetail = $this->common_model->selectData('packages', "*", array("package_id" => $packageId)); $package_name = $pkgDetail[0]->package_name; $package_price = $pkgDetail[0]->package_price; $package_desc = $package_name . " (" . $pkgDetail[0]->package_description . ") Subscription for " . $post['website']; // Required Parameter for the getExpresscheckout $param = array('amount' => $package_price, 'currency_code' => 'USD', 'payment_action' => 'Sale', 'package_desc' => $package_desc); $param["return_url"] = base_url() . PAYPAL_API_RETURN; $param["cancel_url"] = base_url() . PAYPAL_API_CANCEL; // Display the response if successful or the debug info if ($paypal->setExpressCheckout($param)) { $res = $paypal->getResponse(); $url = $paypal->getRedirectURL(); $payment["payment"] = $paypal->getResponse(); $payment["user_data"] = $insert_data; $payment["plan_data"] = $plan_data; $this->session->set_userdata('payment_session', $payment); echo $url; } else { print_r($paypal->debug_info); } exit; } else { $this->processUsersInformation($insert_data, $plan_data); } } else { $retFlg = -1; echo $retFlg; exit; } } // $data['view'] = "signup"; //} else { $data['packages'] = getPackages(); $data['view'] = "index"; //} $this->load->view('content', $data); }
public function plan_upgrade() { $post = $this->input->post(); $where = array('u_id' => $this->front_session['u_id']); $user = $this->common_model->selectData('users', '*', $where); $where = array('up_u_id' => $this->front_session['u_id']); $user_plan = $this->common_model->selectData('user_plan', '*', $where); if ($post && $post['planSelect'] != "1") { $domainId = $post['domainSelect']; $packageId = $post['planSelect']; $website = $this->common_model->selectData('user_plan', 'up_website', array("up_id" => $domainId)); /*store information in session */ $post['subdomain'] = $website[0]->up_subdomain; $this->session->set_userdata('tmpPostParam', $post); //temp store plan info in sessin var. /* Paypal payment code */ $this->load->helper('paypal'); $paypal = new wp_paypal_gateway(true); $pkgDetail = $this->common_model->selectData('packages', "*", array("package_id" => $packageId)); $package_name = $pkgDetail[0]->package_name; $package_price = $pkgDetail[0]->package_price; $package_desc = $package_name . " (" . $pkgDetail[0]->package_description . ") Subscription upgraded for " . $website[0]->up_website; // Required Parameter for the getExpresscheckout $param = array('amount' => $package_price, 'currency_code' => 'USD', 'payment_action' => 'Sale', 'package_desc' => $package_desc); $param["return_url"] = base_url() . "dashboard/planUpgradeSuccess"; $param["cancel_url"] = base_url() . PAYPAL_API_CANCEL; // Display the response if successful or the debug info if ($paypal->setExpressCheckout($param)) { $res = $paypal->getResponse(); $url = $paypal->getRedirectURL(); $payment["payment"] = $paypal->getResponse(); //$payment["plan_data"] = $plan_data; $this->session->set_userdata('ppayment_session', $payment); redirect($url); } else { print_r($paypal->debug_info); } exit; } $data['user'] = $user[0]; $data['packages'] = getPackages(); $data['user_plan'] = $user_plan; $data['view'] = "plan_upgrade"; $this->load->view('care/content', $data); }