I am trying to integrate voguepay payment gateway on codeigniter project, but after successful payment, it failed to return to merchant website for notification response.
This is my Controller file
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Vgniter extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('Vgniter_lib');
}
function index()
{
$this->template->loadData("activeLink",
array("vgniter" => array("general" => 1)));
if(!$this->settings->info->payment_enabled) {
$this->template->error(lang("error_60"));
}
$this->template->loadContent("vgniter/index.php", array(
));
}
function notify()
{
if(isset($_POST['transaction_id'])){
//get the full transaction details as an json from voguepay
$json = file_get_contents('https://voguepay.com/?
v_transaction_id=11111&type=json&demo=true');
//create new array to store our transaction detail
$transaction = json_decode($json, true);
/*
Now we have the following keys in our $transaction array
$transaction['merchant_id'],
$transaction['transaction_id'],
$transaction['email'],
$transaction['total'],
$transaction['merchant_ref'],
$transaction['memo'],
$transaction['status'],
$transaction['date'],
$transaction['referrer'],
$transaction['method']
*/
if($transaction['total'] == 0)die('Invalid total');
if($transaction['status'] != 'Approved'){
redirect(base_url('vgniter/failed'));
}
/*You can do anything you want now with the transaction details or the
merchant reference.
You should query your database with the merchant reference and fetch the
records you saved for this transaction.
Then you should compare the $transaction['total'] with the total from your
database.*/
}
}
function failed()
{
}
}
?>
This is my View File
<div width="120px">
<form method="post" action="https://voguepay.com/pay/">
<p>Enter Amount</p>
<br />
<input type="text" name="total" style="width:120px" /><br />
<input type="hidden" name="v_merchant_id" value="demo" />
<input type="hidden" name="notify_url"
value="http://hotjobs.byethost12.com/member/notify" />
<input type="hidden" name="success_url"
value="http://hotjobs.byethost12.com/member/success" />
<input type="hidden" name="failure_url"
value="http://hotjobs.byethost12.com/member/fail" />
<input type="hidden" name="memo" value="Donation to" />
<input type="image"
src="http://voguepay.com/images/buttons/donate_blue.png" alt="PAY" />
</form>
</div>
From experience of using voguepay, your success url, failure and notification urls have to be existing functional pages. Accessing those links directly shows they are not available, all returned a 404 page not found error.
Resolve this and your code will work.
Like @user297056 said, accessing your success,failure and notification urls directly all returned 404 errors. You need to fix that.
Secondly, Make sure javascript is enabled on your browser for the automatic redirection to work.
I have updated the vgniter library. Check the config file, you're required to provide a success_url
$config['success_url'] = '';
which tells the library the url to redirect to for a successful transaction.