%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 defined('BASEPATH') OR exit('No direct script access allowed'); class Payment extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('payment_model', 'payment'); $this->load->model('medical_package_model', 'package','contact'); $this->load->library('email'); } public function index() { $data = array(); $success = ''; $error_msg = ''; $post=$this->input->post(); $order_id = $this->generate_order_id('HOS'.date('Ymd')); $data['page_title'] = 'Medical Package |Sharda Hospital'; $data['page_description'] = 'Medical Package |Sharda Hospital'; $data['page_keyword'] = 'Medical Package |Sharda Hospital'; if($post){ $this->form_validation->set_rules('item_name', 'Item Name', 'required|trim'); $this->form_validation->set_rules('item_id', 'Item ID', 'trim|required|numeric'); $this->form_validation->set_rules('amount', 'Price', 'required|trim|numeric'); $this->form_validation->set_rules('currency_code', 'Currency Code', 'required|trim|alpha'); if($this->form_validation->run() == FALSE) { $error = $this->form_validation->error_array(); $error_msg = implode('\n',$error); $_SESSION['submit_status_msg'] = 'Your Request could not be processed:\n'.$error_msg; echo '<script>console.log("Your Request could not be processed");</script>'; //redirect(site_url('MedicalPackage')); } else{ if($order_id&&($order_id!='')){ $data = array( 'OrderItemType' => 'Medical Package', 'OrderItemName' => $post['item_name'], 'OrderItemID' => $post['item_id'], 'OrderAmount' => $post['amount'], 'OrderCurrencyCode' => $post['currency_code'], 'OrderID' => $order_id ); $success = $this->payment->insert_order($data); $this->load->view('ccavenue_form',$data); //$_SESSION['submit_status_msg'] = "Your Appointment Request has been submitted successfully. We will contact you soon!"; //redirect(base_url()."success"); } else { echo '<script>console.log("Unable to process your request. Kindly try again later.");</script>'; redirect(site_url('MedicalPackage')); } } } } /* * Function : handle_request * Created On : 02 July 2020 * Desc : ICICI Payment Gateway Response */ public function handle_request(){ $data = array(); $success = ''; $error_msg = ''; $post=$this->input->post(); if($post){ if($post['alternate_phone']==''){ $this->form_validation->set_rules('billing_name', 'Patient Name', 'required|trim'); $this->form_validation->set_rules('billing_address', 'Patient Address', 'trim|required'); $this->form_validation->set_rules('billing_city', 'Patient City', 'required|trim'); $this->form_validation->set_rules('billing_state', 'Patient State', 'required|trim'); $this->form_validation->set_rules('billing_country', 'Patient Country', 'required|trim'); $this->form_validation->set_rules('billing_zip', 'Patient Zip', 'required|trim'); $this->form_validation->set_rules('billing_tel', 'Patient Mobile Number', 'required|trim'); $this->form_validation->set_rules('billing_email', 'Patient Email-ID', 'required|trim'); if($this->form_validation->run() == FALSE) { $error = $this->form_validation->error_array(); $error_msg = implode('\n',$error); $_SESSION['submit_status_msg'] = 'Your Request could not be processed:\n'.$error_msg; echo '<script>console.log("Your Request could not be processed");</script>'; redirect(site_url('MedicalPackage')); } else{ $insert_data = array( // 'OrderItemType' => $post['merchant_param4'], // 'OrderItemName' => $post['merchant_param2'], // 'OrderItemID' => $post['merchant_param3'], // 'OrderAmount' => $post['amount'], // 'OrderCurrencyCode' => $post['currency'], // 'OrderID' => $post['order_id'], 'OrderPatientName' => $post['billing_name'], 'OrderPatientAddress' => $post['billing_address'], 'OrderPatientCity' => $post['billing_city'], 'OrderPatientState' => $post['billing_state'], 'OrderPatientZip' => $post['billing_zip'], 'OrderPatientCountry' => $post['billing_country'], 'OrderPatientMobile' => $post['billing_tel'], 'OrderPatientEmail' => $post['billing_email'], 'OrderTID' => $post['tid'], ); //print_r($insert_data);die; $post['merchant_param4'] = $post['merchant_param4'].' - '.$post['merchant_param2']; $post['merchant_param2'] = $post['billing_tel']; $post['merchant_param3'] = $post['billing_email']; $post['merchant_param5'] = $post['order_id']; $success = $this->payment->update_order($post['order_id'],$insert_data); if(($success)&&($success!='')){ $data['post'] = $post; //$this->load->view('ccavenue/ccavRequestHandler',$data); $this->load->view('icici/icicimpRequestHandler',$data); //$_SESSION['submit_status_msg'] = "Your Appointment Request has been submitted successfully. We will contact you soon!"; // redirect(base_url()."success"); } else{ echo '<script>alert("Unable to submit your request. Kindly try again later.");</script>'; } } } } } /* * Function : handle_response * Created On : 02 July 2020 * Desc : ICICI Payment Gateway Response */ public function handle_response(){ date_default_timezone_set('Asia/Kolkata'); $currentTime = date( 'd-m-Y h:i:s A', time()); // Save Payment Transaction details $order_status=''; $bank_ref_num=''; $tracking_num=''; $order_id=''; $order_id = $_POST['oid']; $response = array(); $order_status = $_POST['status']; $data['order_status']=$order_status; $update_data = array(); $update_data = array( 'orderPaymentStatus'=> $order_status, 'BankRefNumber' => $_POST['endpointTransactionId'], 'PaymentTrackingNumber' => $_POST['ipgTransactionId'], 'PaymentFailureMsg' => $_POST['fail_reason'] ); $success = $this->payment->update_order($order_id,$update_data); $insertArray = array(); // Save Payment Transaction Details $insertArray = array( 'order_id'=>$order_id, 'txndate_processed'=>$_POST['txndate_processed'], 'timezone'=>$_POST['timezone'], 'ccbin'=>$_POST['ccbin'], 'response_key'=>$_POST['response_hash'], 'transaction_id'=>$_POST['ipgTransactionId'], 'bank_ref_no'=>$_POST['endpointTransactionId'], 'order_status'=>$_POST['status'], 'failure_message'=>$_POST['fail_reason'], 'payment_method'=>$_POST['paymentMethod'], 'card_name'=>$_POST['cardnumber'], 'transaction_status'=>$_POST['status'], 'status_message'=>$_POST['status_message'], 'currency'=>$_POST['currency'], 'hash_algorithm'=>$_POST['hash_algorithm'], 'expmonth'=>$_POST['expmonth'], 'processor_response_code'=>$_POST['processor_response_code'], 'transaction_amount'=>$_POST['chargetotal'], 'merchant_param1'=> $_POST['txndatetime'], 'txntype'=>$_POST['txntype'], 'ccbrand'=>$_POST['ccbrand'], 'bname'=>$_POST['bname'], 'installments_interest'=>$_POST['installments_interest'], 'response_code_3dsecure'=>$_POST['response_code_3dsecure'], 'approval_code'=>$_POST['approval_code'], 'terminal_id'=>$_POST['terminal_id'], 'expyear'=>$_POST['expyear'], 'transaction_date'=>$_POST['txndatetime'], 'scheme_transaction_id'=>$_POST['schemeTransactionId'], 'ip_address'=>$this->get_client_ip(), 'response_code'=>$_POST['fail_rc'], 'tdate'=>$_POST['tdate'], 'bin_country'=>$_POST['cccountry'] ); $response['TID'] = $this->payment->get_TID($order_id)['OrderTID']; $data['response'] = $response; //echo $this->payment->update_order($order_id,$insertArray); die; $query = $this->db->query("select * from `SH_PaymentOrders` where orderID='".$order_id."'")->row_array(); $r = $query['OrderID']; $A = $query['OrderAmount']; $data['response']['billing_name'] = $query['OrderPatientName']; $data['response']['billing_tel'] = $query['OrderPatientMobile']; $data['response']['billing_email'] = $query['OrderPatientEmail']; $data['response']['billing_address'] = $query['OrderPatientAddress']; $data['response']['billing_city'] = $query['OrderPatientCity']; $data['response']['billing_state'] = $query['OrderPatientState']; $data['response']['billing_zip'] = $query['OrderPatientZip']; $data['response']['billing_country'] = $query['OrderPatientCountry']; $data['response']['order_id'] = $order_id; $data['response']['merchant_param4'] = $query['OrderPaymentStatus']; $data['response']['bank_ref_no'] = $query['BankRefNumber']; $data['response']['currency'] = $query['OrderCurrencyCode']; $data['response']['amount'] = $query['OrderAmount']; $data['response']['trans_date'] = $query['OrderDate']; $data['response']['PaymentFailureMsg'] = $query['PaymentFailureMsg']; $results = array(); $results = $this->payment->getallrecords('*',array('order_id'=>$order_id),'sh_payment_transactions'); $data['results'] = $results; if(empty($results['order_id'])) { $success = $this->payment->inserttransactiodetails('sh_payment_transactions',$insertArray); $data['results'] = $insertArray; /***************/ if(($order_status=='APPROVED')) { // Success //$msg = $this->load->view("email_templates/payment", $data, TRUE); $msg = $this->load->view("email_templates/payment_reply", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); //$this->email->to('amit.verma@shardatech.org'); //$this->email->cc('praveenpnf@gmail.com'); $this->email->bcc('amit.verma@shardatech.org'); $this->email->subject('Payment Successfully with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } /******** new code****/ else if(($order_status=='DECLINED')) { $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); $this->email->bcc('amit.verma@shardatech.org'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payments declined with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } /**************** END *********/ else if(($response['order_status']=='Failure')){ $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); $this->email->bcc('amit.verma@shardatech.org'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payment Failed with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } else { $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); $this->email->bcc('amit.verma@shardatech.org'); $this->email->subject('Payment Failed with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } } $this->load->view('icici/icicimpResponseHandler',$data); } public function handle_response_ccanv(){ date_default_timezone_set('Asia/Kolkata'); $currentTime = date( 'd-m-Y h:i:s A', time()); $this->load->helper('ccavenue'); //$data['workingKey']='92337578B1BEB60D3308787C704E9519'; //Working Key should be provided here. $data['workingKey'] ='8A21A9EDB89C4C923AE55C2A55F3263D'; $data['encResponse']=$_POST["encResp"]; //This is the response sent by the CCAvenue Server $data['rcvdString']=decrypt($data['encResponse'],$data['workingKey']); //Crypto Decryption used as per the specified working key. $data['order_status']=""; $data['decryptValues']=explode('&', $data['rcvdString']); $data['dataSize']=sizeof($data['decryptValues']); if($_POST['']) $order_status=''; $bank_ref_num=''; $tracking_num=''; $order_id=''; $response = array(); for($i = 0; $i < $data['dataSize']; $i++) { $information=explode('=',$data['decryptValues'][$i]); if($information[1]==null){ $information[1]=''; } if($i==3) $order_status=$information[1]; if($information[0]=='bank_ref_no'){ $bank_ref_num = $information[1]; } else if($information[0]=='tracking_id'){ $tracking_num = $information[1]; } else if($information[0]=='order_id'){ $order_id = $information[1]; } else if($information[0]=='failure_message'){ $failure_msg = $information[1]; } } $data['order_status']=$order_status; for($i = 0; $i < $data['dataSize']; $i++) { $information=explode('=',$data['decryptValues'][$i]); if($information[1]==null){ $information[1]=''; } $response[$information[0]] = $information[1]; } /***** New code Activate ************/ /*if($order_status=="Success"){ $original_request = $this->payment->get_order($order_id); if(!$original_request){ $response['order_status'] = 'Hacked'; $response['failure_msg'] = "Information Mismatch - OrderId tampered"; } else { /*if(($original_request['OrderPatientName']==$response['billing_name'])||($original_request['OrderPatientAddress']==$response['billing_address'])||($original_request['OrderPatientCity']==$response['billing_city'])||($original_request['OrderPatientState']==$response['billing_state'])||($original_request['OrderPatientZip']==$response['billing_zip'])||($original_request['OrderPatientCountry']==$response['billing_country'])||($original_request['OrderPatientMobile']==$response['billing_tel'])||($original_request['OrderPatientEmail']==$response['billing_email'])||($original_request['OrderAmount']==$response['amount'])||($original_request['OrderCurrencyCode']==$response['currency']))*/ /*{ $response['order_status'] = 'Hacked'; $response['failure_msg'] = "Information Mismatch - One or more parameters have been tampered with"; } } } */ $update_data = array( 'orderPaymentStatus'=> $response['order_status'], 'BankRefNumber' => $bank_ref_num, 'PaymentTrackingNumber' => $tracking_num, 'PaymentFailureMsg' => $response['failure_msg'] ); $success = $this->payment->update_order($order_id,$update_data); $response['TID'] = $this->payment->get_TID($order_id)['OrderTID']; $data['response'] = $response; /***************/ //print_r($data); $query = $this->db->query("select `OrderID`,`OrderAmount` from `SH_PaymentOrders` where orderID='".$order_id."'")->row_array(); $r = $query['OrderID']; $A = $query['OrderAmount']; $response['order_status']; $amount_split = $data['decryptValues'][10]; $prntamnt = explode('amount=',$data['decryptValues'][10]); $prntamnt[1].'0'; //if(($order_status=='Success')&&($response['order_status']=='Hacked')){ if(($order_status=='Success')) { // Success //$msg = $this->load->view("email_templates/payment", $data, TRUE); $msg = $this->load->view("email_templates/payment_reply", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); //$this->email->cc('praveenpnf@gmail.com'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payment Successfully with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } /******** new code****/ else if(($response['order_status']=='Aborted')) { $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); $this->email->cc('praveenpnf@gmail.com'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payments declined with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } /**************** END *********/ else if(($response['order_status']=='Failure')){ $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); //$this->email->cc('praveenpnf@gmail.com'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payment Failed with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); //$msg = $this->load->view("email_templates/payment_reply", $data, TRUE); //send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg); } else { $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital'); $this->email->to($response['billing_email']); //$this->email->cc('praveenpnf@gmail.com'); $this->email->subject('Payment Failed with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); /* $msg = $this->load->view("email_templates/payment_reply", $data, TRUE); send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg);*/ } /*if(($response['order_status']=='Success') && ($order_id==$r) && ($prntamnt[1].'0'==$A)){ $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('praveen.kumar@shardatech.org', 'Sharda Hospital'); $this->email->to('praveenpnf@gmail.com'); $this->email->cc('praveenjaishwal@gmail.com'); $this->email->subject('Payment Successfully with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } */ /*if(($response['order_status']=='Success') && ($prntamnt[1].'0'!=$A)){ $msg = $this->load->view("email_templates/payment", $data, TRUE); $this->email->from('praveen.kumar@shardatech.org', 'Sharda Hospital'); $this->email->to('praveenpnf@gmail.com'); $this->email->cc('praveenjaishwal@gmail.com'); //$this->email->bcc('them@their-example.com'); $this->email->subject('Payment Successfully with sharda hospital'." | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); }*/ $this->load->view('ccavenue/ccavResponseHandler',$data); } public function generate_order_id($base=''){ $this->load->helper('string'); $unique = false; $order_id = ''; while(!$unique){ $order_id = $base.random_string('numeric',5); $unique = $this->payment->is_unique_id($order_id); } return $order_id; } /* * Function : vanbookingpayment */ public function vanbookingpayment(){ $data = array(); $success = ''; $error_msg = ''; $post=$this->input->post(); if($post) { $order_id = $post['order_id']; $getOrderDetails = $this->payment->getallrecords('*',array('id'=>$post['view_respcode'])); $params = array(); $params['alternate_phone'] = $getOrderDetails['alternate_phone']; $params['billing_name'] = $getOrderDetails['club_name']; $params['billing_address'] = $getOrderDetails['full_address']; $params['billing_city'] = $getOrderDetails['city']; $params['billing_state'] = $getOrderDetails['state']; $params['billing_zip'] = $getOrderDetails['pincode']; $params['billing_country'] = $getOrderDetails['country']; $params['billing_tel'] = $getOrderDetails['contact_no']; $params['billing_email'] = $getOrderDetails['email_id']; $params['merchant_param1'] = $post['merchant_param1']; $params['merchant_param4'] = $post['merchant_param4'].' - '.$post['merchant_param2']; $params['merchant_param2'] = $getOrderDetails['contact_no']; $params['merchant_param3'] = $getOrderDetails['email_id']; $params['merchant_param5'] = $order_id; $params['order_id'] = $order_id; $params['amount'] = $getOrderDetails['booking_amount']; $params['merchant_id'] = $post['merchant_id']; $params['redirect_url'] = $post['redirect_url']; $params['cancel_url'] = $post['cancel_url']; $params['language'] = $post['language']; $params['customer_identifier'] = $post['customer_identifier']; $params['tid'] = $post['tid']; $params['currency'] = 'INR'; $updateParams = array(); $updateParams = array( 'order_item_id' => $post['merchant_param3'], 'payment_status' => '2', 'modifiedon' => date('Y-m-d H:i:s') ); // Set Order Item ID $success = $this->payment->updatebookingorder($updateParams,$post['view_respcode']); if(($success)&&($success!='')) { $data['post'] = $params; $this->load->view('icici/iciciRequestHandler',$data); } else { echo '<script>alert("Unable to submit your request. Kindly try again later.");</script>'; } } } /* * Function : bookingresponse */ public function bookingresponse() { date_default_timezone_set('Asia/Kolkata'); $order_status=''; $bank_ref_num=''; $tracking_num=''; $order_id=''; $response = array(); /***** New code Activate ************/ $order_id = $_POST['oid']; $response['order_id'] = $order_id; $response['order_status'] = $_POST['status']; $currentTime = $_POST['txndatetime']; $update_data = array( 'payment_message'=> $_POST['status'], 'bankrefnumber' => $_POST['endpointTransactionId'], 'transaction_id' => $_POST['ipgTransactionId'], 'transaction_msg' => $_POST['fail_reason'] ); $resp = $this->payment->updatebookingorder($update_data,$order_id,'booking_id'); /****** data response *********/ //print_r($data); die; $query = $this->payment->getallrecords('*',array('booking_id'=>$order_id)); $r = $query['booking_id']; $A = $query['booking_amount']; $booking_date = $query['booking_date']; $email_id = $query['email_id']; $data['queryRecord'] = $query; // Save Payment Transaction details $insertArray = array(); $insertArray = array( 'order_id'=>$order_id, 'txndate_processed'=>$_POST['txndate_processed'], 'timezone'=>$_POST['timezone'], 'ccbin'=>$_POST['ccbin'], 'response_key'=>$_POST['response_hash'], 'transaction_id'=>$_POST['ipgTransactionId'], 'bank_ref_no'=>$_POST['endpointTransactionId'], 'order_status'=>$_POST['status'], 'failure_message'=>$_POST['fail_reason'], 'payment_method'=>$_POST['paymentMethod'], 'card_name'=>$_POST['cardnumber'], 'transaction_status'=>$_POST['status'], 'status_message'=>$_POST['status_message'], 'currency'=>$_POST['currency'], 'hash_algorithm'=>$_POST['hash_algorithm'], 'expmonth'=>$_POST['expmonth'], 'processor_response_code'=>$_POST['processor_response_code'], 'transaction_amount'=>$_POST['chargetotal'], 'merchant_param1'=> $_POST['txndatetime'], 'txntype'=>$_POST['txntype'], 'ccbrand'=>$_POST['ccbrand'], 'bname'=>$_POST['bname'], 'installments_interest'=>$_POST['installments_interest'], 'response_code_3dsecure'=>$_POST['response_code_3dsecure'], 'approval_code'=>$_POST['approval_code'], 'terminal_id'=>$_POST['terminal_id'], 'expyear'=>$_POST['expyear'], 'transaction_date'=>$_POST['txndatetime'], 'scheme_transaction_id'=>$_POST['schemeTransactionId'], 'ip_address'=>$this->get_client_ip(), 'response_code'=>$_POST['fail_rc'], 'bin_country'=>$_POST['cccountry'] ); $mob = $query['contact_no']; // Validate order exist or not $results = $this->payment->getallrecords('*',array('order_id'=>$response['order_id']),'sh_payment_transactions'); //$results = array(); if(empty($results['order_id'])) { $success = $this->payment->inserttransactiodetails('sh_payment_transactions',$insertArray); if(($response['order_status']=='APPROVED')){ // Success $msg = $this->load->view("email_templates/payment_booking_reply", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('amit.verma@shardatech.org'); $this->email->bcc('amkverma@gmail.com'); $message = 'Congratulations, You have successfully booked the Aarogya Mammography Van at Sharda Hospital. Your Booking Number is - '.$response['order_id']; $this->send_otp($mob, $message); $this->email->subject("Congratulations, You have successfully booked the Aarogya Mammography Van at Sharda Hospital"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } else if(($response['order_status']=='FAILED')){ $msg = $this->load->view("email_templates/bookingvanpayment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('praveenpnf@gmail.com'); $this->email->bcc('amkverma@gmail.com'); $message = 'Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed. Please Try Again'; $this->send_otp($mob, $message); $this->send_otp($mob, $message); $this->email->subject("Payment Failed with Sharda Hospital - Aarogya Mammography Van Booking"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); //$msg = $this->load->view("email_templates/payment_reply", $data, TRUE); //send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg); } else { $msg = $this->load->view("email_templates/bookingvanpayment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('praveenpnf@gmail.com'); $message = 'Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed. Please Try Again'; $this->send_otp($mob, $message); $this->email->bcc('amkverma@gmail.com'); $this->email->subject("Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); // Send SMS /* $msg = $this->load->view("email_templates/payment_reply", $data, TRUE); send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg);*/ } } // Validate order exist or not $data['query'] = $this->payment->getallrecords('*',array('order_id'=>$response['order_id']),'sh_payment_transactions'); $this->load->view('icici/iciciBookingResponseHandler',$data); } /* * Function : bookingresponse_ccanvue */ public function bookingresponse_ccanvue() { date_default_timezone_set('Asia/Kolkata'); $currentTime = date( 'd-m-Y h:i:s A', time()); $this->load->helper('ccavenue'); //$data['workingKey'] = '92337578B1BEB60D3308787C704E9519'; //Working Key should be provided here. $data['workingKey'] = '8A21A9EDB89C4C923AE55C2A55F3263D'; $data['encResponse'] = $_POST["encResp"]; //This is the response sent by the CCAvenue Server $data['rcvdString'] = decrypt($data['encResponse'],$data['workingKey']); //Crypto Decryption used as per the specified working key. $data['order_status']=""; $data['decryptValues']=explode('&', $data['rcvdString']); $data['dataSize']=sizeof($data['decryptValues']); if($_POST['']) $order_status=''; $bank_ref_num=''; $tracking_num=''; $order_id=''; $response = array(); for($i = 0; $i < $data['dataSize']; $i++) { $information=explode('=',$data['decryptValues'][$i]); if($information[1]==null){ $information[1]=''; } if($i==3) $order_status=$information[1]; if($information[0]=='bank_ref_no'){ $bank_ref_num = $information[1]; } else if($information[0]=='tracking_id'){ $tracking_num = $information[1]; } else if($information[0]=='order_id'){ $order_id = $information[1]; } else if($information[0]=='failure_message'){ $failure_msg = $information[1]; } } $data['order_status']=$order_status; for($i = 0; $i < $data['dataSize']; $i++) { $information=explode('=',$data['decryptValues'][$i]); if($information[1]==null){ $information[1]=''; } $response[$information[0]] = $information[1]; } /***** New code Activate ************/ $update_data = array( 'payment_message'=> $response['order_status'], 'bankrefnumber' => $bank_ref_num, 'transaction_id' => $tracking_num, 'transaction_msg' => $response['failure_msg'] ); $success = $this->payment->updatebookingorder($update_data,$order_id,'booking_id'); $response['TID'] = $this->payment->getallrecords('order_item_id',array('booking_id'=>$order_id)); $data['response'] = $response; /****** data response *********/ //print_r($data); die; $query = $this->payment->getallrecords('id,booking_id,order_item_id, booking_amount, booking_date,contact_no,email_id',array('booking_id'=>$order_id)); $r = $query['booking_id']; $A = $query['booking_amount']; $booking_date = $query['booking_date']; $email_id = $query['email_id']; $data['queryRecord'] = $query; $response['order_status']; $amount_split = $data['decryptValues'][10]; $prntamnt = explode('amount=',$data['decryptValues'][10]); $prntamnt[1]; // Save Payment Transaction details $insertArray = array(); $insertArray = array( 'order_id'=>$response['order_id'], 'response_key'=>$_POST['encResp'], 'transaction_id'=>$response['tracking_id'], 'bank_ref_no'=>$response['bank_ref_no'], 'order_status'=>$response['order_status'], 'failure_message'=>$response['failure_message'], 'payment_mode'=>$response['payment_mode'], 'card_name'=>$response['card_name'], 'transaction_status'=>$response['status_code'], 'status_message'=>$response['status_message'], 'currency'=>$response['currency'], 'transaction_amount'=>$response['amount'], 'merchant_param1'=> $response['merchant_param1'], 'merchant_param2'=>$response['merchant_param2'], 'merchant_param3'=>$response['merchant_param3'], 'merchant_param4'=>$response['merchant_param4'], 'merchant_param5'=>$response['merchant_param5'], 'vault'=>$response['vault'], 'offer_type'=>$response['offer_type'], 'offer_code'=>$response['offer_code'], 'discount_value'=>$response['discount_value'], 'mer_amount'=>$response['mer_amount'], 'eci_value'=>$response['eci_value'], 'retry'=>$response['retry'], 'ip_address'=>$this->get_client_ip(), 'response_code'=>$response['response_code'], 'billing_notes'=>$response['billing_notes'], 'transaction_date'=>$response['trans_date'], 'bin_country'=>$response['bin_country'], 'order_item_id'=>$response['TID']['order_item_id'] ); $mob = $query['contact_no']; // Validate order exist or not $results = $this->payment->getallrecords('*',array('order_id'=>$response['order_id']),'sh_payment_transactions'); //$results = array(); if(empty($results['order_id'])) { $success = $this->payment->inserttransactiodetails('sh_payment_transactions',$insertArray); if(($response['order_status']=='Success')){ // Success $msg = $this->load->view("email_templates/payment_booking_reply", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('amit.verma@shardatech.org'); $this->email->bcc('amkverma@gmail.com'); $message = 'Congratulations, You have successfully booked the Aarogya Mammography Van at Sharda Hospital. Your Booking Number is - '.$response['order_id']; $this->send_otp($mob, $message); $this->email->subject("Congratulations, You have successfully booked the Aarogya Mammography Van at Sharda Hospital"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } else if(($response['order_status']=='Aborted')) { $msg = $this->load->view("email_templates/bookingvanpayment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($response['billing_email']); $this->email->bcc('amkverma@gmail.com'); $message = 'Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed. Please Try Again'; $this->send_otp($mob, $message); $this->email->subject("Payments declined with sharda hospital - Aarogya Mammography Van Booking | ".$currentTime); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); } else if(($response['order_status']=='Failure')){ $msg = $this->load->view("email_templates/bookingvanpayment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('praveenpnf@gmail.com'); $this->email->bcc('amkverma@gmail.com'); $message = 'Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed. Please Try Again'; $this->send_otp($mob, $message); $this->send_otp($mob, $message); $this->email->subject("Payment Failed with Sharda Hospital - Aarogya Mammography Van Booking"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); //$msg = $this->load->view("email_templates/payment_reply", $data, TRUE); //send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg); } else { $msg = $this->load->view("email_templates/bookingvanpayment", $data, TRUE); $this->email->from('info@shardahospital.org', 'Sharda Hospital - Aarogya Mammography Van Booking'); $this->email->to($email_id); //$this->email->cc('praveenpnf@gmail.com'); $message = 'Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed. Please Try Again'; $this->send_otp($mob, $message); $this->email->bcc('amkverma@gmail.com'); $this->email->subject("Sorry, Your payment for Sharda Hospital Aarogya Mammography Van booking has failed"); $this->email->set_mailtype("html"); $this->email->message($msg); $this->email->send(); // Send SMS /* $msg = $this->load->view("email_templates/payment_reply", $data, TRUE); send_email($response['billing_email'], "", "info@shardahospital.org", "Receipt|".$response['merchant_param4']."|Date:".$response['trans_date'], $msg);*/ } } // Validate order exist or not $data['query'] = $this->payment->getallrecords('*',array('order_id'=>$response['order_id']),'sh_payment_transactions'); $this->load->view('ccavenue/ccavBookingResponseHandler',$data); } /* * Get Client IP Address */ function get_client_ip() { $ipaddress = ''; if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress = $_SERVER['HTTP_CLIENT_IP']; else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; else if(isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED']; else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; else if(isset($_SERVER['HTTP_FORWARDED'])) $ipaddress = $_SERVER['HTTP_FORWARDED']; else if(isset($_SERVER['REMOTE_ADDR'])) $ipaddress = $_SERVER['REMOTE_ADDR']; else $ipaddress = 'UNKNOWN'; return $ipaddress; } /* * Function : send Confiramtion SMS */ function send_otp($mob, $message){ $msg= $message.". Call us at +91120-2333999 for any queries."; $msg=urlencode($msg); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, "http://bulkpush.mytoday.com/BulkSms/SingleMsgApi"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "feedid=363901&username=9015129267&password=wgtpt&To=".$mob."&Text=".$msg."&time=&senderid=shardacom_trans"); $buffer = curl_exec($ch); curl_close($ch); } }