paypal的notify_url页面程序不执行?

Donthan 2012-03-05 11:26:59
我做了两个相同的paypal表单,除了notify_url、return和cancel_return三个URL不一样,其他的几乎都一模一样。一个是A.html提交的,一个是B.html提交的。
现在A的正常,可以通过notify_url指向的程序页面改变数据库状态,但是B页面的就不行。
B页面代码:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="buyer@gmails.com"><!--商户邮箱-->
<input type="hidden" name="lc" value="US"><!--币种-->
<input type="hidden" name="item_name" value="<%=ProductName%>"><!--商品名称-->
<input type="hidden" name="amount" value="<%=CartAmount%>"><!--总价-->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="tax_rate" value="0.000"><!--税率-->
<input type="hidden" name="shipping" value="0.00"><!--运费-->
<input type="hidden" value="http://www.xxxxxxxx.net/mem...../xxx.asp?1" name="return"/>
<input type="hidden" value="http://www.xxxxxxxx.net/mem...../xxx.asp?2" name="cancel_return"/>
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest">
<input type="hidden" name="notify_url" value="http://www.xxxxxxxx.net/mem..../payment_complete.asp?oid=<%=OrderId%>">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/zh_XC/i/scr/pixel.gif" width="1" height="1">
</form>



在payment_complete.asp程序如下:


id=Trim(Request.QueryString("oid"))
'从PayPal 出读取POST 信息同时添加变量 "cmd‟
str = Request.Form & "&cmd=_notify-validate"
'response.Write str
'response.End()
'建议在此将接受到的信息记录到日志文件中以确认是否收到IPN 信息
'我在这里把str写入到log文件也没用,log里面没东西,权限该给的都给了。
'将信息POST 回给PayPal 进行验证
logFile = "paypal_ipn_log.txt"
path = Server.MapPath(".") & "\logs\" & logFile
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
'set obj Http = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
'set obj Http = Server.CreateObject("Microsoft.XMLHTTP")
'在Sandbox 情况下 ,设置:
objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
'将POST 变量分配给本地变量
Item_name = Request.Form("item_name")
Item_number = Request.Form("item_number")
Payment_status = Request.Form("payment_status")
Payment_amount = Request.Form("mc_gross")
Payment_currency = Request.Form("mc_currency")
Txn_id = Request.Form("txn_id")
Receiver_email = Request.Form("receiver_email")
Payer_email = Request.Form("payer_email")
'检查通知是否合法
if (objHttp.status <> 200 ) then
set fs = CreateObject("Scripting.FileSystemObject")
set Lfile = fs.OpenTextFile(path, 8, true)
Lfile.WriteLine("===========================================================")
Lfile.WriteLine("HTTP Error:" & objhttp.status & Now() & ".")
Lfile.WriteLine("Error Time:"& Now() & ".")
Lfile.WriteLine("==============")
Lfile.Close()
Set fs=Nothing
Response.End()
elseif (objHttp.responseText = "VERIFIED") then
'检查付款状态是否完成( "Completed")
'检查txn_id 是否已经处理过
'检查receiver_email 是否是您的PayPal 账户中的EMAIL 地址
'检查付款金额和货币单位是否正确
'处理这次付款 ,包括写数据库
'如果数据库执行出错,保留出错信息在日志文件
on error resume next
SQL="UPDATE [OrderTable] SET ispay='y',payinfor=1 WHERE Id IN('"&id&"')"
conn.execute(SQL)
if Err.number<>0 then
set fs = CreateObject("Scripting.FileSystemObject")
set Lfile = fs.OpenTextFile(path, 8, true)
Lfile.WriteLine("===========================================================")
Lfile.WriteLine("Database Error:" & Err.Description & ".")
Lfile.WriteLine("Error Time:"& Now() & ".")
Lfile.WriteLine("==============")
Lfile.Close()
Set fs=Nothing
Else
.........
End If
elseif (objHttp.responseText = "INVALID") then
'未通过认证 ,有可能是编码错误或非法的POST 信息
set fs = CreateObject("Scripting.FileSystemObject")
set Lfile = fs.OpenTextFile(path, 8, true)
Lfile.WriteLine("===========================================================")
Lfile.WriteLine("Error: INVALID Transaction or ERROR Code.")
Lfile.WriteLine("Error Time:"& Now() & ".")
Lfile.WriteLine("==============")
Lfile.Close()
Set fs=Nothing
Response.End()
else
'处理其他错误
set fs = CreateObject("Scripting.FileSystemObject")
set Lfile = fs.OpenTextFile(path, 8, true)
Lfile.WriteLine("===========================================================")
Lfile.WriteLine("Other Error.")
Lfile.WriteLine("Error Time:"& Now() & ".")
Lfile.WriteLine("==============")
Lfile.Close()
Set fs=Nothing
Response.End()
end if
set objHttp = nothing


沙箱测试中显示订单已经完成。该收钱的收到钱了,该付钱的付过钱了,就是notify_url指向的程序没动静。
...全文
366 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Donthan 2012-03-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 shenjuan54 的回复:]

和我一样。不知道为什么不去调用notify_url的指向.
[/Quote]

你的商品描述那个字段,用什么符号了没?
这问题纠结我好长时间,最后才发现是因为商品描述里面用了英文的括号导致的……(/锤地)
小申22 2012-03-12
  • 打赏
  • 举报
回复
和我一样。不知道为什么不去调用notify_url的指向.

1,170

社区成员

发帖
与我相关
我的任务
社区描述
移动支付相关内容讨论专区
社区管理员
  • 移动支付
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧