使用PHP的PayPal IPN通过IPN Tester和Sandbox返回HTTP 400

时间:2015-08-14 20:13:04

标签: php paypal paypal-ipn

我正在尝试将PayPal IPN集成到我的应用中。我正处于测试的第一阶段。我已复制/粘贴此代码: https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php

然后,在这里使用IPN测试器: https://developer.paypal.com/developer/ipnSimulator

我发送了一个IPN。这将返回消息“我们很抱歉,但是出现HTTP错误。请再试一次。”如果我检查检查员,在网络下有400错误。

日志文件的输出如下:

[2015-08-14 14:21 America/Chicago] 1. HTTP request of validation request:POST /cgi-bin/webscr HTTP/1.1
Host: www.sandbox.paypal.com
Accept: */*
Connection: Close
Content-Length: 20
Content-Type: application/x-www-form-urlencoded

 for IPN payload: cmd=_notify-validate
[2015-08-14 14:21 America/Chicago] 2. HTTP response of validation request: HTTP/1.1 200 OK
Date: Fri, 14 Aug 2015 19:21:30 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=YSr2aJL5kxPX894uugNhw87ur4ChWoHJjtJLIZ9nqfiS9rOgWSW42T0tPoLj2JpHZ8vclaVwel-vg4GrLQOJbNTcQ42AuITkYbaKVfj_pmpwVXpIB73Wn2C3dLPNWkcXdYWZdmOycOF4sVLHNVsO_cd3XZD2i3hzpptLUBvIKIsJjjq3WggwFQYYZRn-i0RuQnEZtZ1JQph-nT90PrSeqr2l7XNeY0ozqr0bwaZDyAhEWp01pozPZTughjbHzwoDjTetpkBWZkscNLNSomTYRzVlzZNYmVYKF1nh7Hmfb6AM2D_bR3d5cK6DXQcraaj3ZtGNifboMPRVbvJycti1ZOW3RNqFrxZhXkCRPYty_DGfSwo4pHiWW33B0AVCAvHXM7yv2uGjUc1SQjfl3ZXpmVsnpwsEme2MS7DGiwPZEApXixhvFT-9PJCiKm4; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Mon, 11-Aug-2025 19:21:31 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Sun, 13-Aug-2017 19:21:31 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1439580090758032; path=/; expires=Sun, 06-Aug-45 19:21:30 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
Paypal-Debug-Id: bf09526fb4efd
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D3124743765; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: Apache=10.72.128.11.1439580090740911; path=/; expires=Sun, 06-Aug-45 19:21:30 GMT
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

INVALID
[2015-08-14 14:21 America/Chicago] 4. Invalid IPN: cmd=_notify-validate

我已检查过服务器上的错误,但没有。我也尝试修改代码以考虑以下注释:

// CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below. Ensure the file is readable by the webserver.
// This is mandatory for some environments.
//$cert = __DIR__ . "./cacert.pem";
//curl_setopt($ch, CURLOPT_CAINFO, $cert);

我不知道还能检查什么。

1 个答案:

答案 0 :(得分:0)

我按照链接建议中的表单构建,这导致了php代码工作正常的额外证据。经过几次跟踪过程并跟踪IPN模拟器网络请求后,我决定尝试通过http而不是https连接到我的网站。通过https连接是导致400错误的触发器。通过http连接并且不会产生错误。