%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php class Pay extends MY_Controller { function __construct() { parent::__construct(); $this->load->model('pay_model', 'pay'); $this->load->model('user_model', 'user'); $this->load->helper('paytm'); } function load_paytm_form($appId=0, $coupanId=0, $state=0, $adm_user_id=0){ $appDtl=$this->user->applicationDtl($appId); $fee=$appDtl['fee']; if($state=='pre-registration' && $appDtl['instant_fee']){ $fee=$appDtl['instant_fee']; } if(!$appDtl){ $this->json_data(array('success'=>'F', 'msg'=>'Invalid Data')); } if($appDtl['payment_status']){ die("Payment has been already made!"); } $coupanDtl=[]; if($coupanId){ if($coupanId==="PER12TH85"){ $coupanDtl=['title'=>$coupanId, 'amt'=>round($fee/2)]; //$coupanDtl=['title'=>$coupanId, 'amt'=>$fee-500]; }else{ $coupanDtl=$this->db->select("title, amt")->get_where("master_coupans", array('id'=>$coupanId))->row_array(); } } $usrDtl=$this->user->detail(); $amt=$fee; if($coupanDtl){ $amt=$amt-$coupanDtl['amt']; } $orderId=$appId.'_'.time(); $custId='CUST'.$appId.'_'.time(); $trans=array( 'applicant_id'=>$appDtl['applicant_id'], 'application_id'=>$appDtl['id'], 'pay_order_id'=>$orderId, 'pay_cust_id'=>$custId, 'txn_amt'=>$amt, 'created'=>currentDT(), 'updated'=>currentDT(), ); $trans_id=$this->dba->insert("pay_trans", $trans); $d=array( 'pay_trans_id'=>$trans_id, 'fee'=>$fee, 'coupan_used'=>$coupanDtl?$coupanDtl['title']:'', 'coupan_amt'=>$coupanDtl?$coupanDtl['amt']:0, 'adm_paid_by'=>$adm_user_id, 'updated'=>currentDT() ); $this->db->where('id', $appId)->update("applications", $d); $inf=array( 'ORDER_ID'=>$orderId, 'CUST_ID'=>$custId, 'MOBILE_NO'=>$usrDtl['mob'], 'EMAIL'=>$usrDtl['email'], 'TXN_AMOUNT'=>$amt, 'trans_id'=>$trans_id, 'state'=>$state, 'adm_user_id'=>$adm_user_id ); $this->load->view("pages/paytm_form", $inf); } function paytm_response($trans_id, $state=0){ $res=$_POST; $transdtl=$this->pay->trans_dtl($trans_id); $paytmChecksum=isset($res["CHECKSUMHASH"]) ? $res["CHECKSUMHASH"] : ""; $isValidChecksum=verifychecksum_e($res, PAYTM_MERCHANT_KEY, $paytmChecksum); $err=FALSE; $pay_success=FALSE; if($isValidChecksum == "TRUE"){ if($res["STATUS"] == "TXN_SUCCESS") { $pay_success=TRUE; } }else{ $err=TRUE; } if(!$err){ $inf=replace_null(array( 'payment_status'=>$pay_success?'SUCCESS':'FAIL', 'txn_id'=>$res['TXNID'], 'bank_txn_id'=>$res['BANKTXNID'], 'txn_amt'=>$res['TXNAMOUNT'], 'txn_date'=>$res['TXNDATE'], 'txn_status'=>$res["STATUS"], 'respcode'=>$res["RESPCODE"], 'respmsg'=>$res["RESPMSG"], 'bank_name'=>$res["BANKNAME"], 'payment_mode'=>$res["PAYMENTMODE"], 'updated'=>currentDT(), 'full_resp'=>serialize($res), )); $this->db->update("pay_trans", $inf, array('id'=>$trans_id)); if($this->db->affected_rows()){ if($pay_success){ $appdtl=$this->db->get_where("applications", ["id"=>$transdtl['application_id']])->row_array(); $up_data=array('payment_status'=>1, 'payment_mode'=>'ONLINE', 'payment_date'=>currentDT(), 'updated'=>currentDT()); if($appdtl['step_completed']==2){ $up_data['step_completed']=3; $up_data['step3date']=currentDT(); } $this->db->where("id", $transdtl['application_id'])->update("applications", $up_data); $cond=["applicant_id"=>$transdtl['applicant_id']]; $this->db->where($cond)->update("applicants_visit_history", ['is_paid'=>0]); $lastv=$this->db->select("id,lpage")->order_by("id", "DESC")->limit(1)->get_where("applicants_visit_history", $cond)->row_array(); $last_v_id=$lastv['id']; $lpage=str_replace(["https://", "http://", "www."], ["", "", ""], rtrim(trim($lastv['lpage']), '/')); $lpagedtl=$this->db->select("for_mob_app, step1pay")->from("landing_pages")->like("trimed_title", $lpage)->get()->row_array(); if($lpagedtl['for_mob_app']){ $this->db->where("id", $trans_id)->update("pay_trans", ['from_mob_app'=>1, 'updated'=>currentDT()]); } if($lpagedtl['step1pay'] && $appdtl['step_completed']==1){ $this->db->where("id", $transdtl['application_id'])->update("applications", ['step1_paid'=>1]); } $this->db->where("id", $last_v_id)->update("applicants_visit_history", ['is_paid'=>1]); if($this->common->isPhd($transdtl['applicant_id'])){ $this->db->where("app_id", $appdtl['id'])->update("phd_app_form", ['step_completed'=>5, 'step5date'=>currentDT(), 'updated'=>currentDT()]); } if($appdtl['step_completed']==2){ $this->pay->addLeadToPS($transdtl['application_id']); $this->common->sendPaymentConfirmMsg($transdtl['application_id']); }else{ $this->common->sendPaymentConfirmMsgStep1($transdtl['application_id']); } } $this->common->sendPaymentAlertToAdmin($transdtl['application_id']); }else{ $err=TRUE; } } if($err){ die("Error!"); } $lpage=$this->db->select('lpage')->order_by("id", "DESC")->limit(1)->get_where("applicants_visit_history", array('applicant_id'=>$transdtl['applicant_id']))->row()->lpage; if(!$lpage){ $lpage_id=$this->db->select('lpage_id')->get_where("applicants", array('id'=>$transdtl['applicant_id']))->row()->lpage_id; $lpage=rtrim($this->db->get_where("landing_pages", array('id'=>$lpage_id))->row()->title, "/"); } if($pay_success){ if($state=='pre-registration'){ redirect($lpage.'/dashboard/pre-payment-success/'.encode($trans_id)); }else{ redirect($lpage.'/dashboard/payment-success/'.encode($trans_id)); } }else{ redirect($lpage.'/dashboard/payment-fail/'.encode($trans_id)); } } } //EOF