我在Paypal沙箱上创建了买家和卖家测试帐户。我还创建了一个Paypal按钮。
Paypal按钮:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6M75NVDV8ZHR8">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
我启用了IPN并在那里设置了通知网址 在创建Paypal按钮时,我为成功的交易插入了我的网站URL 成功的交易和IPN通知共享相同的网址。
以下是引用网址的PHP脚本:
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
print_r($_POST);
foreach ($_POST as $key => $value) {
echo "loop";
echo $value = urlencode(stripslashes($value));
echo $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.sandbox.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) {
echo " PAYMENT VALIDATED & VERIFIED! ";
}
else if (strcmp ($res, "INVALID") == 0) {
echo " PAYMENT INVALID & INVESTIGATE MANUALY! ";
}
}
fclose ($fp);
}
?>
print_r
函数仅打印Array()
,在foreach循环中不显示任何内容。
页面上只显示PAYMENT INVALID & INVESTIGATE MANUALLY!
。
这里有什么问题?
因为我想在成功的交易中插入一些数据。
这是我的帖子数组:
Array
(
)
DoDirectPayment failed: Array
(
[TIMESTAMP] => 2012%2d05%2d03T12%3a54%3a08Z
[CORRELATIONID] => 51176eef6a5
[ACK] => Failure
[VERSION] => 51%2e0
[BUILD] => 2860716
[L_ERRORCODE0] => 10527
[L_ERRORCODE1] => 10563
[L_ERRORCODE2] => 10562
[L_ERRORCODE3] => 81234
[L_SHORTMESSAGE0] => Invalid%20Data
[L_SHORTMESSAGE1] => Invalid%20Data
[L_SHORTMESSAGE2] => Invalid%20Data
[L_SHORTMESSAGE3] => Invalid%20Parameter
[L_LONGMESSAGE0] => This%20transaction%20cannot%20be%20processed%2e%20Please%20enter%20a%20valid%20credit%20card%20number%20and%20type%2e
[L_LONGMESSAGE1] => This%20transaction%20cannot%20be%20processed%2e%20Please%20enter%20a%20valid%20credit%20card%20expiration%20month%2e
[L_LONGMESSAGE2] => This%20transaction%20cannot%20be%20processed%2e%20Please%20enter%20a%20valid%20credit%20card%20expiration%20year%2e
[L_LONGMESSAGE3] => ExpDate%20%3a%20Invalid%20Parameter
[L_SEVERITYCODE0] => Error
[L_SEVERITYCODE1] => Error
[L_SEVERITYCODE2] => Error
[L_SEVERITYCODE3] => Error
)
我更改了ipn.php代码,现在我收到此错误:“信用卡号无效”。
我已使用预配置创建了买方帐户,并随机生成信用卡号。
现在,当我去添加/编辑信用卡时,我无法仅在地址和有效期内编辑卡号。
并且也无法添加新的信用卡,而是将此信用卡的错误分配给另一个Paypal帐户消息。
答案 0 :(得分:0)
print_r将其输出回显给paypal的脚本。您可能希望将其记录到文件中,以便稍后查看