我正在研究经典的asp创建捐赠网站,支付网关是paypal。 我已经实现了IPN,paypal正在通过表单传递notify_url的通知。 付款也正常工作,即我可以在我的沙盒paypal帐户中获得付款历史记录和IPN历史记录。
现在问题出现在IPN处理程序文件中,当我使用sandbox.paypal url发回PayPal时,它会给出500错误。同样的事情不适用于直播贝宝网址。 下面是更好解释的代码。
测试表格
<form action="zPaypalTest.asp" method="POST">
<input name="mc_gross" type="hidden" value="500.00" />
<input name="custom" type="hidden" value="some custom data" />
<input name="address_status" type="hidden" value="confirmed" />
<input name="item_number1" type="hidden" value="6" />
<input name="item_number2" type="hidden" value="4" />
<input name="payer_id" type="hidden" value="FW5W7ZUC3T4KL" />
<input name="tax" type="hidden" value="0.00" />
<input name="address_street" type="hidden" value="1234 Rock Road" />
<input name="payment_date" type="hidden" value="14:55 15 Jan 07 2005 PST" />
<input name="payment_status" type="hidden" value="Completed" />
<input name="address_zip" type="hidden" value="12345" />
<input name="mc_shipping" type="hidden" value="0.00" />
<input name="mc_handling" type="hidden" value="0.00" />
<input name="first_name" type="hidden" value="Jason" />
<input name="last_name" type="hidden" value="Anderson" />
<input name="mc_fee" type="hidden" value="0.02" />
<input name="address_name" type="hidden" value="Jason Anderson" />
<input name="notify_version" type="hidden" value="1.6" />
<input name="payer_status" type="hidden" value="verified" />
<input name="business" type="hidden" value="paypal@emailaddress.com" />
<input name="address_country" type="hidden" value="United States" />
<input name="num_cart_items" type="hidden" value="2" />
<input name="mc_handling1" type="hidden" value="0.00" />
<input name="mc_handling2" type="hidden" value="0.00" />
<input name="address_city" type="hidden" value="Los Angeles" />
<input name="verify_sign" type="hidden" value="AlUbUcinRR5pIo2KwP4xjo9OxxHMAi6.s6AES.4Z6C65yv1Ob2eNqrHm" />
<input name="mc_shipping1" type="hidden" value="0.00" />
<input name="mc_shipping2" type="hidden" value="0.00" />
<input name="tax1" type="hidden" value="0.00" />
<input name="tax2" type="hidden" value="0.00" />
<input name="txn_id" type="hidden" value="TESTER" />
<input name="payment_type" type="hidden" value="instant" />
<input name="last_name=Borduin" type="hidden" />
<input name="payer_email" type="hidden" value="test@domain.com" />
<input name="item_name1" type="hidden" value="Rubber+clog" />
<input name="address_state" type="hidden" value="CA" />
<input name="payment_fee" type="hidden" value="0.02" />
<input name="item_name2" type="hidden" value="Roman sandal" />
<input name="invoice" type="hidden" value="123456" />
<input name="quantity" type="hidden" value="1" />
<input name="quantity1" type="hidden" value="1" />
<input name="receiver_id" type="hidden" value="5HRS8SCK9NSJ2" />
<input name="quantity2" type="hidden" value="1" />
<input name="txn_type" type="hidden" value="web_accept" />
<input name="mc_gross_1" type="hidden" value="0.01" />
<input name="mc_currency" type="hidden" value="USD" />
<input name="mc_gross_2" type="hidden" value="0.01" />
<input name="payment_gross" type="hidden" value="0.02" />
<input name="subscr_id" type="hidden" value="PP-1234" />
<input name="test" type="submit" value="test" />
</form>
我的IPN处理程序文件 zPaypalTest.asp
<%@ language="VBScript" %>
<%
Dim Item_name, Item_number, Payment_status, Payment_amount
Dim Txn_id, Receiver_email, Payer_email
Dim objHttp, str
DIM ApplicationRootPath
ApplicationRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
' read post from PayPal system and add 'cmd'
str = Request.Form& "&cmd=_notify-validate"
' post back to PayPal system to validate
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
'Set objHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
'set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
'objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
'objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
'Send response message back to paypal'
'objHttp.open "POST", "https://ipnpb.paypal.com/cgi-bin/webscr", false
'objHttp.open "POST", "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", false
Response.write "IPN-Sand"
Response.write "<br/>"
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
Response.write objHttp.status
if (objHttp.status <> 200 ) then
' HTTP error handling
elseif (objHttp.responseText = "VERIFIED") then
Response.write "VERIFIED"
elseif (objHttp.responseText = "INVALID") then
Response.write "INVALID"
else
Response.write "ERROR"
end if
set objHttp = nothing
%>
以上是示例文件。 这是我使用的代码示例。 https://github.com/paypal/ipn-code-samples
我在localhost IIS上测试它,它也可以正常工作。 因此,只有问题是我使用时,
objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
OR
objHttp.open "POST", "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", false
我收到500服务器错误,这500服务器只在我的服务器上运行,无论是在http或https上运行,但在localhost IIS中它可以工作。 也 如果我将该网址更改为直播网址
objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
OR
objHttp.open "POST", "https://ipnpb.paypal.com/cgi-bin/webscr", false
有效。
如果我只是在我的服务器浏览器中浏览该页面,即https://myserver.com/zPaypalTest.asp,则仅在使用沙盒网址时会出错。
我无法想到这里的错误是什么。为什么会出现500错误。
如果有人能给我任何线索有什么不妥,我将非常感激。