我需要一些关于Paypal集成的清晰度。 首先,我在三年前做了一个成功的经典ASP Paypal集成,工作得很好。 我已将其与当前的Paypal文档结合使用,为客户端生成新系统。我无法让它发挥作用。
这是我正在做的事情:
第1步:我有一篮子物品(在这种情况下,显示门票)。
第2步:我以自己的形式捕获用户地址和联系方式。
第3步:我调用从Paypal Developer API下载的'expresscheckout.asp'表单
以下是该表单上的第一段代码:
<%
v_title = Request.Form("title")
v_firstname = Request.Form("firstname")
v_lastname = Request.Form("lastname")
v_addrline1 = Request.Form("addrline1")
v_addrline2 = Request.Form("addrline2")
v_addrline3 = Request.Form("addrline3")
v_addrline4 = Request.Form("addrline4")
v_addrcity = Request.Form("addrcity")
v_addrcounty = Request.Form("addrcounty")
v_addrpostcode = Request.Form("addrpostcode")
v_countryid = Request.Form("countryid")
v_currencyid = Request.Form("currencyid")
v_phoneprimary = Request.Form("phoneprimary")
v_email = Request.Form("email")
SQLStmt = "UPDATE [OrderHeader] SET [Title] = '" & v_title & "',[FirstName] = '" & v_firstname & "',[LastName] = '" & v_lastname & "',[AddrLine1] = '" & v_addrline1 & "',[AddrLine2] = '" & v_addrline2 & "',[AddrLine3] = '" & v_addrline3 & "',[AddrLine4] = '" & v_addrline4 & "',[AddrCity] = '" & v_addrcity & "',[AddrCounty] = '" & v_addrcounty & "',AddrPostcode='" & v_addrpostcode & "',CountryId=" & v_countryid & ",CurrencyId=" & v_currencyid & ",PhonePrimary='" & v_phoneprimary & "',Email='" & v_email & "', Status='New' WHERE [OrderReference] = '" & session("orderreference") & "';"
Set RS_OrderHeader01 = Connection01.Execute(SQLStmt)
On Error Resume Next
paymentAmount = Session("Payment_Amount")
currencyCodeType = "GBP"
paymentType = "Sale"
returnURL = "http://www.myurl.co.uk/transactioncomplete.asp"
cancelURL = "http://www.myurl.co.uk/shop.asp"
%>
正如您所看到的,我正在捕获用户输入详细信息并更新我的OrderHeader,然后设置Paypal变量。我可以确认'paymentAmount'设置正确。
同一表格的下一部分代码是:
<%
Set resArray = CallShortcutExpressCheckout (paymentAmount, currencyCodeType, paymentType, returnURL, cancelURL)
ack = UCase(resArray("ACK"))
If ack="SUCCESS" Then
' Redirect to paypal.com
SQLStmt = "UPDATE [OrderHeader] SET [Token] = '" & resArray("TOKEN") & "' WHERE [OrderReference] = '" & session("orderreference") & "';"
Set RS_OrderHeader01 = Connection01.Execute(SQLStmt)
ReDirectURL(resArray("TOKEN") )
Else
'Display a user friendly Error on the page using any of the following error information returned by PayPal
ErrorCode = URLDecode( resArray("L_ERRORCODE0"))
ErrorShortMsg = URLDecode( resArray("L_SHORTMESSAGE0"))
ErrorLongMsg = URLDecode( resArray("L_LONGMESSAGE0"))
ErrorSeverityCode = URLDecode( resArray("L_SEVERITYCODE0"))
%>
<div class="content full left">
<h1>Payment Not Succesful</h1>
<p>Your order number is <span class="bold"><%=session("orderreference")%></span>. Please use this number if you need to contact us about this order.
</div>
<div class="content full left">
<h2>There was a problem with your payment.</h2>
<p>Please contact us with your order reference and following details so that we can help you complete the transaction.</p>
<p>Paypal error code: <%=ErrorCode%></p>
<p>Error description: <%=ErrorLongMsg%></p>
<p>Severity: <%=ErrorSeverityCode%></p>
</div>
<%
End If
%>
正如您所看到的,我正在调用'CallShortcutExpressCheckout'。我可以确认TOKEN是否正确返回,并用它更新我的Orderheader。
到目前为止,非常好。
但是此时我被重定向到一个包含空白订单摘要的Payal页面。 一旦我输入我的沙盒买家帐户详细信息,我就会收到我的ReturnURL。
我的返回网址上的代码位于:
<%
Session("orderreference") = ""
On Error Resume Next
finalPaymentAmount = Session("Payment_Amount")
set resArray = GetShippingDetails( Request.QueryString("token"))
set resArray = ConfirmPayment( finalPaymentAmount )
ack = UCase(resArray("ACK"))
If ack <> "SUCCESS" Then
'Display a user friendly Error on the page using any of the following error information returned by PayPal
ErrorCode = URLDecode( resArray("L_ERRORCODE0"))
ErrorShortMsg = URLDecode( resArray("L_SHORTMESSAGE0"))
ErrorLongMsg = URLDecode( resArray("L_LONGMESSAGE0"))
ErrorSeverityCode = URLDecode( resArray("L_SEVERITYCODE0"))
response.Write("ack = " & ack)
response.Write("ErrorCode = " & ErrorCode)
Else
token = resArray("TOKEN")
transactionId = resArray("PAYMENTINFO_0_TRANSACTIONID")
transactionType = resArray("PAYMENTINFO_0_TRANSACTIONTYPE")
paymentType = resArray("PAYMENTINFO_0_PAYMENTTYPE")
orderTime = resArray("PAYMENTINFO_0_ORDERTIME")
amt = resArray("PAYMENTINFO_0_AMT")
currencyCode = resArray("PAYMENTINFO_0_CURRENCYCODE")
taxAmt = resArray("PAYMENTINFO_0_TAXAMT")
paymentStatus = resArray("PAYMENTINFO_0_PAYMENTSTATUS")
pendingReason = resArray("PAYMENTINFO_0_PENDINGREASON")
reasonCode = resArray("PAYMENTINFO_0_REASONCODE")
SQLStmt = "UPDATE [OrderHeader] SET [Status]='Success' WHERE [Token] = '" & token & "';"
Set RS_OrderHeader01 = Connection01.Execute(SQLStmt)
SQLStmt = "SELECT * FROM [OrderHeader] WHERE [Token] = '" & token & "';"
Set RS_OrderHeader02 = Connection01.Execute(SQLStmt)
End If
%>
Paypal完全没有回复。 ACK似乎为空或NULL。
有人能说清楚这里发生了什么吗?我错过了一个关键步骤吗?有任何已知问题吗?它可能是沙盒问题吗?
亲切的问候,