Paypal SandBox IPN 总是返回 INVALID [英] Paypal SandBox IPN always returns INVALID

查看:21
本文介绍了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' . "
";
    $header .= 'Content-type: text/html; charset=iso-8859-1' . "
";
    $header .= 'To: Oshirowanen <oshirowanen@mail.com>' . "
";
    $header .= 'From: Me <me@desktop.com>' . "
";

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

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

将 2 行添加到监听器中,如这里,可以看到下面的两行:

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

The 2 lines mentioned in point 6:

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

我不知道为什么 Sandbox business pro 帐户不让我设置 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天全站免登陆