codeigniter voguepay付款后付款未能返回商家网站

时间:2017-06-09 10:13:14

标签: php codeigniter-3

我正在尝试在codeigniter项目上集成voguepay支付网关,但在成功付款后,它无法返回商家网站进行通知回复。

这是我的控制器文件

<?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()
{


}


}   

?>

这是我的查看档案

<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>

3 个答案:

答案 0 :(得分:1)

我更新了vgniter library。查看config file,您需要提供一个success_url $config['success_url'] = '';,告知图书馆重定向的网址,以便成功完成交易。

答案 1 :(得分:0)

根据使用voguepay的经验,您的成功网址,失败和通知网址必须是现有的功能页面。直接访问这些链接显示它们不可用,所有返回404页面未找到错误。

解决此问题,您的代码将正常运作。

答案 2 :(得分:0)

就像@ user297056所说,直接访问您的成功,失败和通知网址都会返回404错误。你需要解决这个问题。

其次,确保您的浏览器启用了javascript,以便自动重定向工作。