Payumoney Error while integrating codeigniter - codeigniter

I am working on codeigniter and integrating the payumoney payment gateway. Here I have a registration form and there are various fields in the form Now what I am doing I want to add payumoney payment gateway but the problem is this when I add write the fname or amount from myself the it works fine but while I use $this->input->post('first_name') It shows error like follows
click to view the image (Here is the error in the image)
Here is the data variables
the values for data array
My code is follows :
function checkout() {
$this->load->config('payu');
$MERCHANT_KEY = $this->config->item('MERCHANT_KEY');
$SALT = $this->config->item('SALT');
$PAYU_BASE_URL = $this->config->item('PAYU_BASE_URL');
$action = '';
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$udf1 = '';
$udf2 = '';
$udf3 = '';
$udf4 = '';
$udf5 = '';
$amount = $this->input->post('corporate_plan_rate');
$productinfo = 'test';
$fname = $this->input->post('user_name');
$email = $this->input->post('user_email');
$data = array(
'mkey' => $MERCHANT_KEY,
'tid' => $txnid,
'MERCHANT_KEY'=>$MERCHANT_KEY,
'txnid'=>$txnid,
'SALT'=>$SALT,
// 'hash' => $hash,
'amount' => $amount,
'pinfo' => $productinfo,
'name' => $fname,
'productinfo'=>$productinfo,
'mailid' => $email,
'phoneno' => '9646403748',
'udf1' => $udf1,
'udf2' => $udf2,
'udf3' => $udf3,
'udf4' => $udf4,
'udf5' => $udf5,
);
$this->load->view('payu/checkout.php', $data);
}
and here is my view page:
<html>
<head>
<!--<script src="//code.jquery.com/jquery.min.js"></script>-->
<script>
// $(function () {
// setTimeout(function () {
// $('form').submit();
// }, 2000)
// });
</script>
</head>
<body>
<?php
$hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|' . $name . '|' . $mailid . '|' . $udf1 . '|' . $udf2 . '|' . $udf3 . '|' . $udf4 . '|' . $udf5 . '||||||' . $SALT;
$hash = strtolower(hash('sha512', $hashstring));
?>
<h2>PayU Form</h2>
<br/>
<form method="post" name="payuForm" action="https://test.payu.in/_payment">
<input name="key" type="hidden" value="<?php echo $mkey ?>" />
<input name="txnid" type="hidden" value="<?php echo $tid ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input name="amount" type="hidden" value="<?php echo $amount; ?>" />
<input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>">
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input name="udf1" type="hidden" value="">
<input name="udf2" type="hidden" value="">
<input name="udf3" type="hidden" value="">
<input name="udf4" type="hidden" value="">
<input name="udf5" type="hidden" value="">
<input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/>
<input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'>
<input name="phone" type="hidden" value="<?php echo $phoneno; ?>">
<input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" />
<input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" />
<input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" />
<input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" >
</form>
</body>
</html>
Please help me find out the problem and resolve it out.. Thanx

Please completely replace your controller function with below codes
function checkout()
{
$MERCHANT_KEY = "enter your test merchant key here";
$SALT = "enter your test salt here";
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$udf1 = '';
$udf2 = '';
$udf3 = '';
$udf4 = '';
$udf5 = '';
$amount = $this->input->post('corporate_plan_rate');
$productinfo = 'test_payment';
$fname = $this->input->post('user_name');
$email = $this->input->post('user_email');
$hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|'. $fname . '|' . $email .'|'.$udf1.'|' .$udf2.'|' .$udf3.'|'.$udf4.'|'.$udf5.'||||||'. $SALT;
$hash = strtolower(hash('sha512', $hashstring));
$data = array(
'mkey' => $MERCHANT_KEY,
'tid' => $txnid,
'hash' => $hash,
'amount' => $amount,
'pinfo' => $productinfo,
'name' => $fname,
'productinfo'=>$productinfo,
'mailid' => $email,
'phoneno' => '9646403748',
);
$this->load->view('payu/checkout', $data);
}
Now completely replace your checkout view file with following codes
<html>
<head>
</head>
<body>
<h2>PayU Form</h2>
<br/>
<form method="post" name="payuForm" action="https://test.payu.in/_payment">
<input name="key" type="hidden" value="<?php echo $mkey ?>" />
<input name="txnid" type="hidden" value="<?php echo $tid ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input name="amount" type="hidden" value="<?php echo $amount; ?>" />
<input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>">
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input name="udf1" type="hidden" value="">
<input name="udf2" type="hidden" value="">
<input name="udf3" type="hidden" value="">
<input name="udf4" type="hidden" value="">
<input name="udf5" type="hidden" value="">
<input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/>
<input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'>
<input name="phone" type="hidden" value="<?php echo $phoneno; ?>">
<input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" />
<input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" />
<input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" />
<input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" >
</form>
</body>
</html>
Please try above code without adding any of your own codes for testing and if the same error occurs comment below.

Related

geting 419 page expire error in laravel when using payumoney payment status reponse back url

this is my payment gateway page
<?php
$MERCHANT_KEY = "WTLZQBOb"; // add your id
$SALT = "6MyvUWk9pP"; // add your id
//$PAYU_BASE_URL = "https://test.payu.in";
$PAYU_BASE_URL = "https://secure.payu.in";
$action = '';
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$posted = array();
$posted = array(
'key' => $MERCHANT_KEY,
'txnid' => $txnid,
'amount' => 1,
'firstname' => Auth::user()->name,
'email' => Auth::user()->email,
'productinfo' => 'PHP Project Subscribe',
'surl' => 'http://infohp.in/admin/callback-pay-u-money',
'furl' => 'http://infohp.in/admin/cancel-payment',
'service_provider' => 'payu_paisa',
);
if(empty($posted['txnid'])) {
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
}
else
{
$txnid = $posted['txnid'];
}
$hash = '';
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';
foreach($hashVarsSeq as $hash_var) {
$hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
$hash_string .= '|';
}
$hash_string .= $SALT;
$hash = strtolower(hash('sha512', $hash_string));
$action = $PAYU_BASE_URL . '/_payment';
}
elseif(!empty($posted['hash']))
{
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
<html>
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
if(hash == '') {
return;
}
var payuForm = document.forms.payuForm;
payuForm.submit();
}
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
</script>
</head>
<body onload="submitPayuForm()">
Processing.....
<form action="<?php echo $action; ?>" method="post" name="payuForm"><br />
<input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" /><br />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/><br />
<input type="hidden" name="txnid" value="<?php echo $txnid ?>" /><br />
<input type="hidden" name="amount" value="1" /><br />
<input type="hidden" name="firstname" id="firstname" value="<?=Auth::user()->name?>" /><br />
<input type="hidden" name="email" id="email" value="<?=Auth::user()->email?>" /><br />
<input type="hidden" name="productinfo" value="PHP Project Subscribe"><br />
<input type="hidden" name="surl" value="http://infohp.in/admin/callback-pay-u-money" /><br />
<input type="hidden" name="furl" value="http://infohp.in/admin/cancel-payment" /><br />
<input type="hidden" name="service_provider" value="payu_paisa" /><br />
<?php
if(!$hash) { ?>
<input type="submit" value="Submit" />
<?php } ?>
</form>
</body>
</html>
this is my URL link
<input type="hidden" name="surl" value="http://infohp.in/admin/callback-pay-u-money" /><br />
<input type="hidden" name="furl" value="http://infohp.in/admin/cancel-payment" /><br />
I am trying to use payUmoney in my laravel 7 project i am geting error
When I am trying to get payuMoney payment response status and redirect in my URL page in laravel 7, can you please help me how to resolve that problem. please help me as soon as possible .
except this route on app/Http/Middleware/VerifyCsrfToken.php (except array)
$except = ['*cancel-payment*'];

What is the cause of this wrong image upload error message in my Codeigniter 3 application?

I am working on a basic blog application with Codeigniter 3.1.8 and Bootstrap 4.
There is, among others an "Edit account information" form, which has an image upload field. In the controller, the update() method contains the logic for the image upload action:
public function update() {
// Only logged in users can edit user profiles
if (!$this->session->userdata('is_logged_in')) {
redirect('login');
}
$id = $this->input->post('id');
$data = $this->Static_model->get_static_data();
$data['pages'] = $this->Pages_model->get_pages();
$data['categories'] = $this->Categories_model->get_categories();
$data['author'] = $this->Usermodel->editAuthor($id);
$this->form_validation->set_rules('first_name', 'First name', 'required');
$this->form_validation->set_rules('last_name', 'Last name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
$this->form_validation->set_error_delimiters('<p class="error-message">', '</p>');
// Upload avatar
$config['upload_path'] = './assets/img/avatars';
$config['allowed_types'] = 'jpg|jpeg|png';
$config['max_size'] = '100';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
$uerrors = array('uerrors' => $this->upload->display_errors());
$data['uerrors'] = $uerrors;
}
if(!$this->form_validation->run() || !empty($uerrors))
{
print_r($data['uerrors']);
$this->load->view('partials/header', $data);
$this->load->view('dashboard/edit-author');
$this->load->view('partials/footer');
} else
{
$this->Usermodel->update_user($id);
$this->session->set_flashdata('user_updated', 'Your account details have been updated');
redirect(base_url('/dashboard/manage-authors'));
}
}
The (surprising) problem I have is that, even though I am uploading an image, print_r($data['uerrors']); returns You did not select a file to upload. in the browser.
In the view, the same error is returned:
<?php echo form_open(base_url('dashboard/users/update')); ?>
<input type="hidden" name="id" id="uid" value="<?php echo $author->id; ?>">
<div class="form-group <?php if(form_error('first_name')) echo 'has-error';?>">
<input type="text" name="first_name" id="first_name" class="form-control" value="<?php echo set_value('first_name', $author->first_name); ?>" placeholder="First name">
<?php if(form_error('first_name')) echo form_error('first_name'); ?>
</div>
<div class="form-group <?php if(form_error('last_name')) echo 'has-error';?>">
<input type="text" name="last_name" id="last_name" class="form-control" value="<?php echo set_value('last_name', $author->last_name); ?>" placeholder="Last name">
<?php if(form_error('last_name')) echo form_error('last_name'); ?>
</div>
<div class="form-group <?php if(form_error('email')) echo 'has-error';?>">
<input type="text" name="email" id="email" class="form-control" value="<?php echo set_value('email', $author->email); ?>" placeholder="Email">
<?php if(form_error('email')) echo form_error('email'); ?>
</div>
<div class="form-group <?php if(form_error('bio')) echo 'has-error';?>">
<textarea name="bio" id="bio" cols="30" rows="5" class="form-control" placeholder="Add a short bio"><?php echo set_value('bio', $author->bio); ?></textarea>
<?php if(form_error('bio')) echo form_error('bio'); ?>
</div>
<input type="hidden" name="avatar" id="avatar" value="<?php echo $author->avatar; ?>">
<label for="avatar">Upload avatar</label>
<div class="form-group">
<input type="file" name="userfile" id="uavatar" size="20">
<p><?php print_r($uerrors); ?></p>
</div>
<div class="form-group">
<div class="w-50 pull-left pr-1">
<input type="submit" value="Update" class="btn btn-block btn-md btn-success">
</div>
<div class="w-50 pull-right pl-1">
Cancel
</div>
</div>
<?php echo form_close(); ?>
The error message I was expecting, considering that the image I was trying to upload is larger then the specified limit (100KB) is: The file you are attempting to upload is larger than the permitted size.
What am I doing wrong?
Try this
<?php echo form_open_multipart(base_url('dashboard/users/update')); ?>
<div class="form-group">
<input type="file" name="userfile" id="userfile" size="20">
<p><?php print_r($uerrors); ?></p>
</div>
Try to change your form opening, from :
<?php echo form_open(base_url('dashboard/users/update')); ?>
to
<?php echo form_open_multipart(base_url('dashboard/users/update')); ?>
To change the form encoding type from text/plain to multipart/form-data to support image data upload. Here is the difference between each encoding type.

Images are not showing in the login view after logging out

This is the actual login page
The 2nd pic is when the user logs out or has validation errors
And this is my current code
<?php
echo form_open('login/validate_credentials');
echo '<img src="img/too.png" style="height: 30px">'.form_input( 'username', '');
echo '<img src="img/pwd.png" style="height: 30px">'.form_password('password', '');
echo '<br>';
echo form_submit('submit', 'Login');
echo form_close();
?>
You should use HTml Helper to display images
echo form_open('login/validate_credentials');
echo img(array('src' => 'img/too.png', 'height' => '30px')) . form_input( 'username', '');
echo img(array('src' => 'img/pwd.png', 'height' => '30px')) .form_password('password', '');
echo '<br>';
echo form_submit('submit', 'Login');
echo form_close();
try this...
<form method="post" action="<?php echo base_url();?>login/validate_credentials">
<img src="<?php echo base_url('imagepath');" style="height: 30px">
<input type="text" name="username" id="username" value="">
<img src="img/pwd.png" style="height: 30px">
<input type="password" name="password" id="password" value="">
<input type="submit" name="Login">

Validate with codeigniter

I dont know what am i doing wrong with the validation.
here is my Controller
function update_user() {
$this->load->library('form_validation');
$this->form_validation->set_rules('sirname', 'First Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
$this->form_validation->set_rules('name', 'Last Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
$this->form_validation->set_rules('email', 'Email ID', 'trim|required|valid_email');
if ($this->form_validation->run() == FALSE)
{
// fails
$this->load->view('update_view');
}
else
{
$data = array(
'surname' => $this->input->post('sirname'),
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
);
$this->Account_model->update_user(31,$data);
$this->show_user();
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">You are Successfully Updated!</div>');
redirect('home');
}
}
here is my view
<form method="post" action="<?php echo base_url() . "account/update_user"?>" >
<div class="form-group">
<label for="name">First Name</label>
<input class="form-control" name="sirname" placeholder="Your First Name" type="text" value="<?php echo $user->surname; ?>" />
<span class="text-danger"><?php echo form_error('sirname'); ?></span>
</div>
<div class="form-group">
<label for="name">Last Name</label>
<input class="form-control" name="name" placeholder="Last Name" type="text" value="<?php echo $user->name; ?>" />
<span class="text-danger"><?php echo form_error('name'); ?></span>
</div>
<div class="form-group">
<label for="email">Email ID</label>
<input class="form-control" name="email" placeholder="Email-ID" type="text" value="<?php echo $user->email; ?>" />
<span class="text-danger"><?php echo form_error('email'); ?></span>
</div>
<div class="form-group">
<button name="submit" type="submit" class="btn btn-default" onclick="account.php">Update</button>
<button name="cancel" type="reset" class="btn btn-default">Cancel</button>
</div>
<?php echo form_close(); ?>
<?php endforeach; ?>
<?php echo $this->session->flashdata('msg'); ?>
i need to display the value already in the database as im doing an update info for user.. so how do i implement the set_value('name') as well.
First preference is for form_error(),
so in value for each input fields,
value="<?php form_error("surname") ? echo set_value("surname") : echo $user->surname; ?> ?>"
Which means, if form error, then echo set_value() else echo database value.
in home controller where you redirect to success load :
$this->load->library('form_validation');
it will be ok!
You can use CI's built-in set_value function, which lets you set the values of a form field. It has a second (optional) parameter, to set the default value for the field.
<? echo form_label('Last Name', 'name'); ?>
<input class="form-control" name="name" id="name" type="text" value="<? echo set_value('name', $user->name) ?>">
<? echo form_error('name', '<span class="text-danger">','</span>');?>
In the code above, when loaded for the first time, the form will show the value from the database. But when returned after failing form validation, it will show the user input.

invalid token in joomla

I am using joomla for my website
I have a function in my controller like this
function genericLogis(){
$model = &$this->getModel( JRequest::getCmd( 'view' ) );
$view = &$this->getView( JRequest::getCmd( 'view' ), 'html' );
$view->setModel($model, true);
$view->setLayout('logistical');
$view->logistical();
}
and in my model I have this
function getBasicos(){
JRequest::checkToken() or jexit( 'Invalid Token' );
$plantilla=1;
$db=& JFactory::getDBO();
$query= "SELECT *
FROM ".$db->nameQuote('#__accedo_materiales')."
WHERE ".$db->nameQuote('plantilla')."=".$db->quote($plantilla).";";
$db->setQuery( $query );
$materialesBasicos=$db->loadObjectList();
return $materialesBasicos;
}
and my view is a form like this
<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php?option=<?php echo $option; ?>&view=<?php echo $view; ?>" method="post" name="adminForm">
.....
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="view" value="materiales" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
why when I click on the link to see this form I see Invalid Token!!

Resources