Paypal SandBox IPN始终返回INVALID [英] Paypal SandBox IPN always returns INVALID

查看:57
本文介绍了Paypal SandBox IPN始终返回INVALID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如以下答案中的评论之一所述,我尝试遵循

As mentioned in one of the comments in an answer below, I tried following this tutorial. So now I have the following:

ipn.php文件:

<?php

    $ipn_post_data = $_POST;

    $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

    // Set up request to PayPal
    $request = curl_init();
    curl_setopt_array($request, array
    (
        CURLOPT_URL => $url,
        CURLOPT_POST => TRUE,
        CURLOPT_POSTFIELDS => http_build_query(array('cmd' => '_notify-validate') + $ipn_post_data),
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_HEADER => FALSE,
        CURLOPT_SSL_VERIFYPEER => TRUE,
        CURLOPT_CAINFO => 'cacert.pem',
    ));

    // Execute request and get response and status code
    $response = curl_exec($request);
    $status   = curl_getinfo($request, CURLINFO_HTTP_CODE);

    // Close connection
    curl_close($request);

    if($status == 200 && $response == 'VERIFIED')
    {
        $subject = "valid";
        $message = "good";
    }
    else
    {
        $subject = "invalid";
        $message = "bad";
    }

    $to = "oshirowanen@mail.com";
    $from = "me@desktop.com";

    $header  = 'MIME-Version: 1.0' . "\r\n";
    $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $header .= 'To: Oshirowanen <oshirowanen@mail.com>' . "\r\n";
    $header .= 'From: Me <me@desktop.com>' . "\r\n";

    mail($to,$subject,$message,$header);

?>


收到的电子邮件:

Subject "invalid"
Message "bad"

推荐答案

  1. 使用基本示例代码 4b使其正常工作,

  1. Got it working using the basic sample code 4b,

从基本示例代码中清除了$ipnNotificationUrl = "";,因为我在其中添加了自己的值,

Cleared $ipnNotificationUrl = ""; from the basic sample code as I had a value in there which I added myself,

在沙箱中创建了卖方帐户,而不是商业专业帐户,

Created a seller account instead of a business pro account in sandbox,

设置卖方帐户以启用ipn网址,

Set the seller account to enable the ipn url,

使用了以下PHP 5.2 示例代码用于ipn侦听器

Used the following PHP 5.2 sample code for the ipn listener

将两行添加到侦听器中,如

Added the 2 lines into the listener, as described here, the 2 lines can be seen below:

此处cacert.pem证书下载到我的服务器并放入并将其与ipn侦听器放在同一目录中:

Downloaded the cacert.pem certificate to my server from here and put it in the same directory as the ipn listener:

第6点提到的2行:

CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_CAINFO => 'cacert.pem',

我不知道为什么沙盒商务专业版帐户不允许我设置ipn url,而卖家帐户允许设置.

I have no idea why the sandbox business pro account does not let me set an ipn url, but the seller account does.

这篇关于Paypal SandBox IPN始终返回INVALID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆