How to fix payu biz integration error in codeigniter - codeigniter

How to fix the payu payment gateway integration hashing errors.
This is my controller codes.
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$data['tid'] = $txnid;
$SALT = 'eCwWELxi';
$udf1 = '';
$udf2 = '';
$udf3 = '';
$udf4 = '';
$udf5 = '';
$hashstring = 'gtKFFx' . '|' . $txnid . '|' . '2000' . '|' . 'sdfsdgfsgsfgdfgfsgfdgsd' . '|' . 'suman' . '|' . 'suman#weborbit.in' . '|' . $udf1 . '|' . $udf2 . '|' . $udf3 . '|' . $udf4 . '|' . $udf5 . '||||||||' . $SALT;
$hash = strtolower(hash('sha512', $hashstring));
$data['hash'] = $hash;
$this->load->view('booking_form_view', $data);
And this is my form.
<form method="POST" name="payuForm" action="https://test.payu.in/_payment">
<input type="hidden" name="key" value="gtKFFx" />
<input type="text" name="hash" value="<?= #$hash; ?>"/>
<input type="text" name="txnid" value="<?php echo $tid; ?>" />
<input type="hidden" name="service_provider" value="" size="64" />
<tr>
<td>Amount <span class="mand">*</span>: </td>
<td><input name="amount" type="number" value="2000" /></td>
<td>First Name <span class="mand">*</span>: </td>
<td><input type="text" name="firstname" id="firstname" value="suman" /></td>
</tr>
<tr>
<td>Email <span class="mand">*</span>: </td>
<td><input type="email" name="email" id="email" value="suman#gmail.com" /></td>
<td>Phone <span class="mand">*</span>: </td>
<td><input type="text" name="phone" value="7047752176" /></td>
</tr>
<tr>
<td>Product Info <span class="mand">*</span>: </td>
<td colspan="3"><textarea name="productinfo">sdfsdgfsgsfgdfgfsgfdgsd</textarea></td>
</tr>
<tr>
<td>Success URL <span class="mand">*</span>: </td>
<td colspan="3"><input type="text" name="surl" value="<?= site_url('test/success'); ?>" size="64" /></td>
</tr>
<tr>
<td>Failure URL <span class="mand">*</span>: </td>
<td colspan="3"><input type="text" name="furl" value="<?= site_url('test/fail'); ?>" size="64" /></td>
</tr>
<button type="submit" id="test"></button>
</form>
When i submit the form for testing payment that giving me some hashing errors and hash not array.

Before $SALT, you are using eight '|' which is not correct.
User six '|' and also amount should be float(atleast two decimals
) value eg: 2000.00
I hope this will work.

Use below code for hash parameter :
$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|||||||||||".$salt);
$hash = strtolower(hash("sha512", $hashdata));

Related

Google recaptcha V2 Error: We detected that your site isn't verifying reCAPTCHA solutions. This is required for the proper use of reCAPTCHA on your

I need to your help to solve my problem. I'm using Google recaptcha V2 from last 4-5 years and it was working fine but all of sudden its showing following error:-
We detected that your site isn't verifying reCAPTCHA solutions. This is required for the proper use of reCAPTCHA on your site. Please see our developer site for more information.
My Code:-
<?php
if(isset($_POST['submit'])):
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
//your site secret key
$secret = 'keykeykeykeykeykeykeykeykeykeykey';
//get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
$name = !empty($_POST['name'])?$_POST['name']:'';
$email = !empty($_POST['email'])?$_POST['email']:'';
$phone = !empty($_POST['phone'])?$_POST['phone']:'';
$message = !empty($_POST['message'])?$_POST['message']:'';
if($responseData->success):
//contact form submission code
$to = 'info#greve.com';
$subject = 'Query Received from '.$name;
$htmlContent = "
<p><b>Name: </b>".$name."</p>
<p><b>Email: </b>".$email."</p>
<p><b>Contact No.: </b>".$phone."</p>
<p><b>Message: </b>".$message."</p>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: GREVE Main <info#greve.com>' . "\r\n";
//send email
#mail($to,$subject,$htmlContent,$headers);
$succMsg = 'Your contact request have submitted successfully.';
$name = '';
$email = '';
$phone = '';
$message = '';
else:
$errMsg = 'Robot verification failed, please try again.';
endif;
else:
$errMsg = 'Please click on the reCAPTCHA box.';
endif;
else:
$errMsg = '';
$succMsg = '';
$name = '';
$email = '';
$phone = '';
$message = '';
endif;
?>
Form Code:-
<div>
<?php if(!empty($errMsg)): ?><div class="errMsg"><?php echo $errMsg; ?></div><?php endif; ?>
<?php if(!empty($succMsg)): ?><div class="succMsg"><?php echo $succMsg; ?></div><?php endif; ?>
</div>
<form class="row call_back_form" action="" method="post">
<table class="tab-font" width="80%" border="0" cellspacing="3" cellpadding="0" style="margin-left:15px;">
<tr>
<td align="left" valign="top">Your Name: <span class="red">*</span></td>
</tr>
<tr>
<td align="left" valign="top"><input type="text" class="form-control" value="<?php echo !empty($name)?$name:''; ?>" name="name" ></td>
</tr>
<tr>
<td align="left" valign="top">Your Email: <span class="red">*</span></td>
</tr>
<tr>
<td align="left" valign="top"><input type="text" class="form-control" value="<?php echo !empty($email)?$email:''; ?>" name="email" ></td>
</tr>
<tr>
<td align="left" valign="top">Contact No.: <span class="red">*</span></td>
</tr>
<tr>
<td align="left" valign="top"><input type="text" class="form-control" value="<?php echo !empty($phone)?$phone:''; ?>" name="phone" ></td>
</tr>
<tr>
<td align="left" valign="top">Your Message: <span class="red">*</span></td>
</tr>
<tr>
<td align="left" valign="top"><textarea class="form-control" type="text" required name="message"><?php echo !empty($message)?$message:''; ?></textarea></td>
</tr>
<tr>
<td align="left" valign="top"><div class="g-recaptcha" data-sitekey="6LdBzRMUAAAAALB3B_Jq11dcHeEf2d5jwxw2IBLm"></div></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#F00;">*</span>Read our updated Terms of Use and Privacy Policy before submitting your query.</td>
</tr>
<tr>
<td align="left" valign="top"><input type="submit" style="padding-bottom: 20px; padding-top: 10px; height: 65px;" class="btn submit_btn form-control" name="submit" value="SEND MESSAGE"></td>
</tr>
</table>
</form>

Uploading image can't saved at directory and having error "htmlspecialchars() expects parameter 1 to be string, array given "

i have a view input like that :
<form class="form-group" action="/user6" method="post" enctype="multipart/form-data">
<table class="table table-striped">
<tbody><tr>
<th style="width: 10px">#</th>
<th>Pertanyaan</th>
<th style="width: 60px">Tidak Baik</th>
<th style="width: 60px">Baik</th>
</tr>
<div class="form-group">
<tr>
<td>1.</td>
<td><input class="form-control" style="border:none" type="text" name="question1" value="Kondisi, kebersihan, pelumasan bearing" readonly></td>
{{-- <td><input class="form-control" type="text" placeholder=".input-lg"></td> --}}
<td>
<label><input type="radio" name="answer1" value="tidak baik" checked></label>
</td>
<td>
<label><input type="radio" name="answer1" value="baik"></label>
</td>
</tr>
<tr>
<td></td>
<td> <input class="form-control" style="border:none" type="file" name="image" value="" readonly> </td>
</tr>
</div>
<tr>
<td></td>
<td> <div class="form-group">
<label>Catatan</label>
<textarea class="form-control" name="catatan" rows="3" placeholder="Enter ..." required></textarea>
</div>
</tr>
<input type="hidden" name="alat_id" value="7">
<input type="hidden" name="status" value="3 Bulanan">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</tbody>
</table>
<div class="box-footer">
<button type="submit" class="btn btn-primary" name="name" value="post">Submit</button>
</div>
</form>
and to save this i have controller :
public function store6(Request $request)
{
if($request->hasfile('image'))
{
foreach($request->file('image') as $file)
{
$name=$file->getClientOriginalName();
$file->move(public_path().'/images/', $name);
$data[] = $name;
}
}
$user = new pemeliharaan;
$id = Auth::user()->id;
$user->user_id = $id;
$user->alat_id = $request->alat_id;
$user->pertanyaan =json_encode($request->except
(['_token','name','alat_id','status','catatan']));
$user->catatan = $request->catatan;
$user->status = $request->status;
$user->save();
//dd($user);
return redirect('user/show6')->with('success', 'Data Telah Terinput');
}
before i add "enctype="multipart/form-data" , my view dont have error BUT cant display and saved image at directory . i want saved image to directory but cant saved .
i create a folder named 'images' at public . after i add enctype="multipart/form-data" . this view having error "htmlspecialchars() expects parameter 1 to be string, array given "
its my view after input :
<table class="table table-condensed">
<tbody><tr>
<th style="width: 10px">#</th>
<th>Pertanyaan</th>
<th>Hasil</th>
{{-- <th style="width: 40px">Label</th> --}}
</tr>
<tr>
<td>1.</td>
<td>{{ $pemeliharaan->pertanyaan['question1'] }}</td>
<td>
{{ $pemeliharaan->pertanyaan['answer1'] }}
</td>
</tr>
<tr>
<td>2.</td>
<td>{{ $pemeliharaan->pertanyaan['image'] }}</td>
<td>
{{ $pemeliharaan->pertanyaan['image'] }}
</td>
</tr>
<td><img src="{{ url('images/'.$pemeliharaan->pertanyaan['image'])}}"></td>
</tbody></table>
Something in your table is array, it's not a string so when you put it inside {{}}, it will show error.
You should check
$pemeliharaan->pertanyaan['question1']
$pemeliharaan->pertanyaan['answer1']
$pemeliharaan->pertanyaan['image']
by using dd() function.
Deal with one problem at a time. At present you are storing the image but not saving the path to the file, which you saved in $data. You are not using $data anywhere.
Then you have a problem rendering the new model in the view. This is a totally different issue and is caused by having non-string data passed to the htmlspecialchars function which is what {{ }} does.

Fckeditor to ckeditor4

Issue:
Starting off my issue is that my content does not appear for me to edit.
I can see it on my front end, but not the backend.
Likely due to the old fckedit program.
Im trying to figure out the next step to replace the old FCKeditor within my page with ckeditor4.
My site was custom built from scratch (I didn't build it). I have the ckeditor4 loaded in my include folder and I was able to test it using my URL.
However, I can't get it to work on the page or show my content that is not reachable on the backend.
Here is my page coding:
{include file='siteadmin/header.tpl'}
{include file='siteadmin/left.tpl'}
<h1>{if $action eq 'add'}Add{else}Edit{/if} Page</h1>
<form method="post" action="{$_conf_vars.ADMIN_URL}index.php?opt={$opt}&a={$action}{$qstr}" name="frm" id="frm" enctype="multipart/form-data">
{if $show_msg ne ''}
{$show_msg}
{/if}
<input type="hidden" name="page_id" id="page_id" value="{$page_id}" />
<input type="hidden" name="alias_id" id="alias_id" value="{$alias_id}" />
<input type="hidden" name="page_title" id="page_title" value="{$page_title|#StripSlash}" />
<input type="hidden" name="adapters" id="adapters" value="1" />
<input type="hidden" name="btn" value="{$action}" />
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="listdata">
<tr>
<td><div align="right">Page Title:<span class="star">*</span></div></td>
<td><input type="text" id="page_title" name="page_title" value="{$page_title|#StripSlash}" maxlength="300" style="width:532px;"/></td>
</tr>
<tr>
<td><div align="right">Page Alias:<span class="star">*</span></div></td>
<td><input type="text" name="page_alias" maxlength="100" id="page_alias" value="{$page_alias|#StripSlash}" size="60" />
<em>(a-z, 0-9, hyphen (-) only)</em></td>
</tr>
<tr>
<td valign="top"><div align="right">Description:<span class="star">*</span></div></td>
<td>
{php}
$sBasePath = $_conf_vars['ROOT_URL'].'include/fckeditor/';
$oFCKeditor = new FCKeditor('page_body') ;
$oFCKeditor->BasePath = $sBasePath ;
$oFCKeditor->ToolbarSet ="Default";
$oFCKeditor->Value = StripSlash($this->get_template_vars('page_body')) ;
$oFCKeditor->Height = 500;
$oFCKeditor->Width = 700;
$oFCKeditor->Create() ;
{/php}
</tr>
<tr>
<td width="31%"><div align="right">Meta Title:</div></td>
<td width="69%"><textarea name="meta_title" id="meta_title" rows="4" cols="100">{$meta_title|#StripSlash}</textarea></td>
</tr>
<tr>
<td><div align="right">Meta Keywords:</div></td>
<td><textarea name="meta_keywords" id="meta_keywords" rows="4" cols="100">{$meta_keywords|#StripSlash}</textarea>
<br/><small> <small>Separated by commas</small></small></td>
</tr>
<tr>
<td><div align="right">Meta Description:</div></td>
<td><textarea name="meta_desc" id="meta_desc" rows="4" cols="100">{$meta_desc|#StripSlash}</textarea></td>
</tr>
<tr>
<td width="270"> </td>
<td width="689" align="right"> {if $action eq "add" or $action eq "more"}
<button type="submit" onclick="document.frm.btn.value = 'success';">Add and Go To Listing</button>
<button type="submit" onclick="document.frm.btn.value = 'more';">Add More</button>
{else}
<button type="submit" onclick="document.frm.btn.value = 'update';">Update and Go To Listing</button>
{/if}
<button type="button" onclick="window.location.href='index.php?opt={$opt}{$qstr}'">Cancel</button></td>
</tr>
</table>
</form>
{include file='siteadmin/footer.tpl'}
Thank you,
leon

Edit Pages - Invalid argument supplied for foreach()

I wonder why I still having this error message appearing.
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/editpages.php
Line Number: 48
Backtrace:
File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\admin\views\editpages.php
Line: 48
Function: _error_handler
controllers/Cpages.php
public function editpagesupdate() {
$data['pagessuccess'] = '';
$pages_id = $this->uri->segment(3);
$data['pages'] = $this->Mpages->update_pages($pages_id);
$this->load->view('editpages', $data);
}
models/Mpages.php
public function update_pages($pages_id)
{
$data = array(
'pages_name' => $this->input->post('pages_name'),
'create_date' => $this->input->post('create_date'),
'pages_order' => $this->input->post('pages_order'),
'pages_content' => $this->input->post('pages_content')
);
$this->db->where('pages_id', $pages_id);
$query = $this->db->update('pages', $data);
//return $query->result_array();
return $query;
}
views/editpages.php
<div class="widget-box">
<div class="widget-title"><h5>Pages</h5></div>
<div class="widget-content">
<?php echo form_open('cpages/editpagesupdate'); ?>
<table border="0" style="width: 100%; height: 90px;">
<tr>
<td>Pages Name</td>
<td><input type="text" name="pages_name" value="<?php echo $pages_item['pages_name']; ?>"></td>
</tr>
<tr>
<td>Create Date</td>
<td><input type="text" name="create_date" value="<?php echo $pages_item['create_date']; ?>"></td>
</tr>
<tr>
<td>Order</td>
<td><input type="text" name="pages_order" value="<?php echo $pages_item['pages_order']; ?>"></td>
</tr>
<tr>
<td>View Content</td>
<td><textarea rows="3" cols="20" name="pages_content"><?php echo $pages_item['pages_content']; ?></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="edit" name="submit" value="SUBMIT"></td>
</tr>
</table>
</div>
</div>
<?php endforeach; ?>
controllers/Cpages.php
public function editpagesupdate() {
$data['pagessuccess'] = '';
$pages_id = $this->uri->segment(3);
$update = $this->Mpages->update_pages($pages_id);
$data = array();
/* get updated pages here */
if($update){
$data['pages'] = $this->Mpages->get_pages();
}
$this->load->view('editpages', $data);
}
models/Mpages.php
public function get_pages()
{
$query = $this->db->get('pages');
return $query->result_array();
}
views/editpages.php
<div class="widget-box">
<div class="widget-title"><h5>Pages</h5></div>
<div class="widget-content">
<?php echo form_open('cpages/editpagesupdate'); ?>
<table border="0" style="width: 100%; height: 90px;">
<?php foreach($pages as $pages_item) : ?>
<tr>
<td>Pages Name</td>
<td><input type="text" name="pages_name" value="<?php echo $pages_item['pages_name']; ?>"></td>
</tr>
<tr>
<td>Create Date</td>
<td><input type="text" name="create_date" value="<?php echo $pages_item['create_date']; ?>"></td>
</tr>
<tr>
<td>Order</td>
<td><input type="text" name="pages_order" value="<?php echo $pages_item['pages_order']; ?>"></td>
</tr>
<tr>
<td>View Content</td>
<td><textarea rows="3" cols="20" name="pages_content"><?php echo $pages_item['pages_content']; ?></textarea></td>
</tr>
<?php endforeach; ?>
<tr>
<td></td>
<td><input type="submit" class="edit" name="submit" value="SUBMIT"></td>
</tr>
</table>
</div>
</div>

set_value in codeigniter not responding

I am new to the codeigniter and i am trying its tutorials from the user guide. But i just got stuck in one place. In the code of the form validations. I am trying its example for the set_value property but my user text box is not returning anything.
In my view i added the following code:
<?php echo validation_errors();?>
<?php echo form_open('form');?>
<table border="0">
<tr>
<td><h5>Username</h5></td>
<td><input type="text" name="username" value="" size="50" value="<?php echo set_value('username'); ?>" /></td>
</tr>
<tr>
<td><h5>Password</h5></td>
<td><input type="password" name="password" value="" size="50" accept=" <?php echo set_value('password'); ?>" /></td>
</tr>
<tr>
<td><h5>password Confirm</h5></td>
<td><input type="password" name="passconf" value="" size="50" /></td>
</tr>
<tr>
<td><h5>Email Addres</h5></td>
<td> <input type="text" name="email" value="" size="50" accept="<?php echo set_value('email'); ?>" /></td>
</tr>
<tr>
<td> </td>
<td><div><input type="submit" value="Submit" /></div></td>
</tr>
</table>
</form>
and in my controller i added the following code:
function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username','username','required|min_length[5]|max-length[10]|xss_clean');
$this->form_validation->set_rules('password','password','required');
$this->form_validation->set_rules('passconf','password confirmation','required');
$this->form_validation->set_rules('email','email','required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsucces');
}
}
Thank You in advance.
There are two value attributes in your input type..
Try this...
<td><input type="text" name="username" size="50" value="<?php echo set_value('username'); ?>" /></td>
There are some problems with CI and form validation...
You need own helper where grabs a value from the POST array for the specified field so you can re-populate an input field or textarea. If form validation is active it retrieves the info from the validation class
if (!function_exists('set_value')) {
function set_value($field = '', $default = '') {
$OBJ = & _get_validation_object();
if ($OBJ === TRUE && isset($OBJ->_field_data[$field])) {
return form_prep($OBJ->set_value($field, $default));
} else {
if (!isset($_POST[$field])) {
return $default;
}
return form_prep($_POST[$field]);
}
}
}
This solution is working, best answer. By the way, what is the difference between
<?php echo set_value('field_name'); ?>
and
<?php echo #$_POST['field_name']; ?>

Resources