将CodeIgniter PayPal IPN处理程序迁移到Payza IPN处理程序

时间:2012-09-14 16:02:02

标签: codeigniter paypal

对这样的新手请求表示歉意,但非常感谢指导。我需要将Payza(以前的AlertPay)IPN处理程序集成到以前与PayPal一起使用的类/函数结构中。

我的PayPal IPN处理程序具有以下结构:

class PayPalIPN {

public $paypal_url;
public $socket_url;
public $ipn_response;
public $ipn_data;



function __construct() {
    $this->paypal_url       = 'https://www.paypal.com/cgi-bin/webscr';
    $this->socket_url       = 'www.paypal.com';
    $this->ipn_response     = '';
}



function validate_ipn($logId = null) {

Do stuff
}

Payza(以前称为AlertPay)IPN处理程序示例代码如下所示:

define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
define("TOKEN_IDENTIFIER", "token=");

// get the token from Payza
$token = urlencode($_POST['token']);

//preappend the identifier string "token=" 
$token = TOKEN_IDENTIFIER.$token;

/**
 * 
 * Sends the URL encoded TOKEN string to the Payza's IPN handler
 * using cURL and retrieves the response.
 * 
 * variable $response holds the response string from the Payza's IPN V2.
 */

$response = '';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, IPN_V2_HANDLER);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);

curl_close($ch);

我从这开始:

class PayzaIPN {

public $IPN_V2_HANDLER;
public $TOKEN_IDENTIFIER;
public $response;
public $ipn_data;
public $token;  


//define("TOKEN_IDENTIFIER", "token=");

//define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
//define("IPN_V2_HANDLER", "https://sandbox.Payza.com/sandbox/IPN2.ashx");

function validate_ipn($logId = null)  { 
$this->IPN_V2_HANDLER = 'https://sandbox.Payza.com/sandbox/IPN2.ashx';
$this->token = TOKEN_IDENTIFIER.$token;

我无法在正确的结构中正确声明变量 - 获取T_function预期错误和未定义的常量错误。

2 个答案:

答案 0 :(得分:0)

查看开发中心https://dev.payza.com/

中的信息

您可以在那里找到大量信息,帮助您理清任何与IPN相关的信息。

以下是我认为您正在寻找的代码的直接链接:

https://dev.payza.com/sdks-and-sample-codes/php/ipn/sample-ipn-v2-handler-item.txt

一切顺利!

答案 1 :(得分:0)

我无法在评论中发布代码 - 这是我到目前为止实现的代码:

class PayzaIPN {  
function validate_ipn($payzaIPN ='',$logId = null)  {

define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
define("TOKEN_IDENTIFIER", "token=");
$_POST['token'] = ''; 

$token = urlencode($_POST['token']);

$token = TOKEN_IDENTIFIER.$payzaIPN;



$response = '';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, IPN_V2_HANDLER);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);

curl_close($ch);

if(strlen($response) > 0)

当我直接从浏览器运行代码来测试令牌处理时,它会显示在日志中,我得到了正确的响应: 标记= 47TXhMVgdPrmV3n5aauIZ5CC0MrytYXWjID81pjVnQsEhkSUklPXT3clXZ4SFUFOL5WqepRUpBz5SKomoyPuDw ==&安培; INVALID TOKEN

但是,当我从Payza生成一个事务或重新发送IPN时,它没有显示在日志中,而且我收到500内部服务器错误。托尼,听起来和佩扎一样 - 很高兴见到你:)