PayPal IPN 监听器——使用 CURL 发送响应

发布于 2024-10-05 03:51:40 字数 2861 浏览 3 评论 0原文

我正在尝试使用 CURL 设置我的 PayPal IPN Listener。我从 Paypal 收到的 POST 数据很好,但在发回回复时我遇到了困难。

这是我试图发送回 Paypal 的测试,寻找预期的“已验证”或“无效”响应。

    $string = 'cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=13%3A49%3A46+Dec+01%2C+2010+PST&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=9.34&txn_type=web_accept&txn_id=461212149&notify_version=2.1&custom=xyz123&charset=windows-1252&verify_sign=AHaXyf3zaDTb0y4MveMg3L5zjpqNAElZcXU6rvpq5jsGR30FGG6OehkN';

    $endpoint = 'https://www.sandbox.paypal.com/';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $endpoint);
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $result = curl_exec($ch);
    curl_close($ch);

    echo $result;

我正在使用沙盒 IPN 测试模拟器向我的听众发送 IPN 信号。我正在将回复发送至 https://www.sandbox.paypal.com/

无论我向 Paypal 发送什么数据,我都会收到这样的响应:

HTTP/1.1 301 Moved Permanently
Date: Wed, 01 Dec 2010 23:34:30 GMT
Server: Apache
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=%7cPwtfdnvWZ1WVsa34w2F4FnUT4lXZCFSynqbMXEb4n-DLVEWN-dbmDX86YMRj6lgQyDfDGW%7cgeDqSysrRWP1DZZKq9pFf2j5ZBlu0nORtDS4-uXC_YGN8BtbwSBf1d6vq-77_078ySZeRG%7c; domain=.paypal.com; path=/
Set-Cookie: -1ILhdyICORs4hS4xTUr41S8iP0=cH14qDWDhwMs_KbBH2sE-6AG-wKvoQqYPWtsICHmeL1gU49_4McpLl14aXD3KVyvQsmhfiPzKd-Ekiwm; expires=Tue, 26-Nov-2030 23:34:31 GMT; domain=.paypal.com; path=/
Set-Cookie: cookie_check=yes; expires=Sat, 28-Nov-2020 23:34:31 GMT; domain=.paypal.com; path=/
Set-Cookie: Apache=10.191.196.11.135781291246470532; path=/; expires=Tue, 18-Oct-04 17:06:14 GMT
Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home&country_lang.x=true
Cneonction: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=ISO-8859-1

这让我觉得我只是简单地发布到错误的网址,但这就是我应该使用的网址。

I'm trying to setup my PayPal IPN Listener with CURL. I'm receiving the POST data from Paypal just fine, but I'm stuck when sending my response back.

This is a test I'm trying to send back to Paypal, looking for the expected "VERIFIED" or "INVALID" response.

    $string = 'cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=13%3A49%3A46+Dec+01%2C+2010+PST&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=9.34&txn_type=web_accept&txn_id=461212149¬ify_version=2.1&custom=xyz123&charset=windows-1252&verify_sign=AHaXyf3zaDTb0y4MveMg3L5zjpqNAElZcXU6rvpq5jsGR30FGG6OehkN';

    $endpoint = 'https://www.sandbox.paypal.com/';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $endpoint);
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $result = curl_exec($ch);
    curl_close($ch);

    echo $result;

I'm using the Sandbox IPN Testing Simulator to send IPN signals to my listener. I'm sending my responses to https://www.sandbox.paypal.com/.

I get this response from Paypal no matter what data I send to it:

HTTP/1.1 301 Moved Permanently
Date: Wed, 01 Dec 2010 23:34:30 GMT
Server: Apache
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=%7cPwtfdnvWZ1WVsa34w2F4FnUT4lXZCFSynqbMXEb4n-DLVEWN-dbmDX86YMRj6lgQyDfDGW%7cgeDqSysrRWP1DZZKq9pFf2j5ZBlu0nORtDS4-uXC_YGN8BtbwSBf1d6vq-77_078ySZeRG%7c; domain=.paypal.com; path=/
Set-Cookie: -1ILhdyICORs4hS4xTUr41S8iP0=cH14qDWDhwMs_KbBH2sE-6AG-wKvoQqYPWtsICHmeL1gU49_4McpLl14aXD3KVyvQsmhfiPzKd-Ekiwm; expires=Tue, 26-Nov-2030 23:34:31 GMT; domain=.paypal.com; path=/
Set-Cookie: cookie_check=yes; expires=Sat, 28-Nov-2020 23:34:31 GMT; domain=.paypal.com; path=/
Set-Cookie: Apache=10.191.196.11.135781291246470532; path=/; expires=Tue, 18-Oct-04 17:06:14 GMT
Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home&country_lang.x=true
Cneonction: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=ISO-8859-1

It makes me think I'm just plain posting to the wrong url, but that's the url I'm supposed to use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟花肆意 2024-10-12 03:51:40

Paypal 的沙盒 URL 是:

https://www.sandbox.paypal.com/cgi-bin/webscr

Sandbox URL for Paypal is:

https://www.sandbox.paypal.com/cgi-bin/webscr
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文