Paypal IPN自定义变量为空

时间:2013-12-27 07:36:15

标签: php paypal paypal-ipn

所以我正在尝试使用Paypal自适应支付发送自定义变量,当Paypal使用我在Paypal帐户的销售首选项中指定的文件进行IPN时,自定义变量为空。我的卷曲代码工作正常,响应包络返回成功。我在发送之前回复了帖子字段,这就是我得到的(敏感数据审查):

  

操作类型= PAY&安培; clientDetails.applicationId = [应用   ID]& clientDetails.ipAddress = [my ip]
  ¤cyCode= USD&安培; feesPayer = EACHRECEIVER&安培;备忘录= [我   备忘录]安培;定制= 1Ad2Ad8Ad9&安培; receiverList.receiver(0).amount = 1&安培; receiverList.receiver(0).email = [EMAIL1]&安培; receiverList.receiver(0)= .primary真安培; receiverList.receiver(1) .amount = 0.2&安培; receiverList.receiver(1).email = [EMAIL2]&安培; receiverList.receiver(1).primary =假安培; receiverList.receiver(2).amount = 0.19&安培; receiverList.receiver(2)。电子邮件= [EMAIL3]&安培; receiverList.receiver(2).primary =假安培; receiverList.receiver(3).amount = 0.16&安培; receiverList.receiver(3).email = [EMAIL4]&安培; receiverList.receiver(3) .primary =假安培; requestEnvelope.errorLanguage = EN_US&安培; RETURNURL = [返回   url]& cancelUrl = [取消网址]

自定义变量完全符合我的要求。另一方面,我注意到currencyCode字段以某种方式变为“¤cyCode”。我不知道为什么,但是当我把它改成数组并使用print_r时,它说的是currencyCode。

无论如何,当Paypal立即通知我的Confirm.php并运行以下代码时,我遇到的问题出现了:

// read the post from PayPal system and add 'cmd'  
$req = 'cmd=_notify-validate';  
foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));  
    $req .= "&$key=$value";  
}
// post back to PayPal system to validate  
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";  
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";  
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";  

$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);  
if (!$fp) {
    // HTTP ERROR  
} else {  
    fputs ($fp, $header . $req);  
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);  
    if (strcmp ($res, "VERIFIED") == 0) {  

        $strEmail = $_POST[ "payer_email" ];


        if( isset( $_POST[ "custom" ] ) == true )
        {
            $strQuery = "UPDATE TTest SET TestField = 'posted: " . $_POST[ "custom" ] . "' WHERE id = 1";
        }

        // Execute
        mysql_query( $strQuery );

    }
    else if (strcmp ($res, "INVALID") == 0) {  

    }
}
fclose ($fp);  
}

$ _POST [“custom”]变量似乎是空的,因为它每次只将TestField设置为“posted:”。

0 个答案:

没有答案