public function pay() { $this->layout = "default"; if ($this->Auth->user()) { $user = $this->Auth->user(); $PaymentRequest = new PaymentRequest(); if ($this->request->is("post")) { $data = $this->request->data; $this->Session->write("courses", $data['course_id']); $data['regno'] = $user['Student']['reg_no']; $result = $PaymentRequest->sendRequest($data); $this->set("json", json_encode($result)); } } else { $this->set("json", json_encode("login")); } }
public function save($id) { $this->layout = "ahaguru"; if ($this->request->is("post")) { $data = $this->request->data; $user = $this->Student->findById($id); unset($data['email']); if (!$data['cancel']) { $this->Student->save($data); } $paymentinfo = $this->Session->read('paymentdata'); $paymentinfo['regno'] = $user['Student']['reg_no']; $this->layout = "default"; $PaymentRequest = new PaymentRequest(); $this->Session->write("purchasemode", "online login"); $results = $PaymentRequest->sendRequest($paymentinfo); $message = array("result" => "encrypt", "msg" => $results); // $this->redirect("/payment/response"); echo json_encode($message); } }
public function hloginsuccess($id) { if ($this->request->is("post")) { $data = $this->request->data; error_log("aa" . print_r($data, true)); $this->layout = "default"; $level = $data['Student']['level']; $user = $this->Student->findByUserId($data['Student']['user_id']); unset($data['Student']['email']); $this->Student->save($data); if ($level == 1) { $course_id[0] = 42; $course_id[1] = 41; $courses = implode(',', $course_id); foreach ($course_id as $key => $value) { $cour = $this->Course->findById($value); if ($cour['Course']['discount'] == 0) { $fees += $cour['Course']['fee']; } else { $fees += $cour['Course']['discount']; } } $fees = $this->Session->read("studentfees"); $ch1 = $this->StudentCourseMap->find("first", array('conditions' => array('StudentCourseMap.student_id' => $user['Student']['id'], 'StudentCourseMap.challenge_type' => "PC1", 'StudentCourseMap.deleted' => 0))); $sesscoupon = $this->Session->read('coupon_code'); if (stripos($sesscoupon, "APC2S") === FALSE) { $sesscoupon = substr($sesscoupon, 0, 4); } else { if (stripos($sesscoupon, "APC2S") !== FALSE) { $sesscoupon = substr($sesscoupon, 0, 5); } } if (strcasecmp($sesscoupon, "APC2") == 0) { $fees = 799; } else { if (strcasecmp($sesscoupon, "APC2S") == 0) { $fees = 899; } else { if (!empty($ch1)) { $fees = 899; } } } $paymentdata['fee'] = $fees; $paymentdata['courses'] = $courses; $paymentdata['regno'] = $user['Student']['reg_no']; error_log("feeslogin" . print_r($paymentdata, true)); $this->Session->write($paymentdata); $this->Session->write("courses", $course_id); } else { if ($level == 2) { $course_id[0] = 39; $course_id[1] = 40; $courses = implode(',', $course_id); foreach ($course_id as $key => $value) { $cour = $this->Course->findById($value); if ($cour['Course']['discount'] == 0) { $fees += $cour['Course']['fee']; } else { $fees += $cour['Course']['discount']; } } $fees = $this->Session->read("studentfees"); $ch1 = $this->StudentCourseMap->find("first", array('conditions' => array('StudentCourseMap.student_id' => $user['Student']['id'], 'StudentCourseMap.challenge_type' => "PC1", 'StudentCourseMap.deleted' => 0))); $sesscoupon = $this->Session->read('coupon_code'); if (stripos($sesscoupon, "APC2S") === FALSE) { $sesscoupon = substr($sesscoupon, 0, 4); } else { if (stripos($sesscoupon, "APC2S") !== FALSE) { $sesscoupon = substr($sesscoupon, 0, 5); } } if (strcasecmp($sesscoupon, "APC2") == 0) { $fees = 799; } else { if (strcasecmp($sesscoupon, "APC2S") == 0) { $fees = 899; } else { if (!empty($ch1)) { $fees = 899; } } } $paymentdata['fee'] = $fees; $paymentdata['courses'] = $courses; $paymentdata['regno'] = $user['Student']['reg_no']; $this->Session->write($paymentdata); $this->Session->write("courses", $course_id); } } $this->Session->write("purchasemode", "hindu login purchase"); $this->Session->write('course_mapped_type', 2); $PaymentRequest = new PaymentRequest(); $results = $PaymentRequest->sendRequest($paymentdata); $message = array("result" => "encrypt", "msg" => $results, "student_id" => $user['Student']['id']); $this->set("json", json_encode($message)); // if($data['Student']['level'] == 1){ // $course_id[0] = 2; // $course_id[1] = 14; // } // else if($data['Student']['level'] == 2){ // $course_id[0] = 5; // $course_id[1] = 35; // } // foreach ($course_id as $value) { // $mapdata['course_id'] = $value; // $mapdata['student_id'] = $data['Student']['id']; // $mapdata['payment'] = 2; // $mapdata['status'] = 1; // $mapdata['course_mapped_type'] = 2; // $mapdata['deleted'] = 0; // $mapdata['comments'] = "Hindu Existing Student login"; // $con = array( // 'StudentCourseMap.course_id' => $value, // 'StudentCourseMap.student_id' => $data['Student']['id'], // 'StudentCourseMap.deleted' => 0 // ); // $mapping = $this->StudentCourseMap->find("first",array('conditions' => $con )); // if(empty($mapping)){ // $this->StudentCourseMap->saveAll($mapdata); // } // else{ // $mapdata['id'] = $mapping['StudentCourseMap']['id']; // $comments = $mapping['StudentCourseMap']['comments']; // if(strpos($comments,$mapdata['comments']) === FALSE){ // $comments .= ",".$mapdata['comments']; // $mapdata['comments'] = $comments; // $this->StudentCourseMap->saveAll($mapdata); // } // else{ // unset($mapdata['comments']); // $this->StudentCourseMap->saveAll($mapdata); // } // } // } // // $this->Session->write("purchasemode","hindu login"); // $this->redirect("/student/course/1"); } }