伙计们,
我们有一个使用 PayPal Express Checkout for Digital Goods 进行软件销售的网站。它已经工作了5个月。上周我们开始收到错误“请求被中止:无法创建 SSL/TLS 安全通道。” 关闭实时站点。当我在开发服务器上运行该站点时,它运行良好,我们可以处理交易。所有这些都针对实时贝宝站点。在查看此论坛和其他论坛上的许多问题时,主要问题似乎是使用错误的端点。我正在使用.NET SDK和nvp方法。我检查了端点,它们是paypal为nvp交易提供的当前端点。甚至查看了dll以确保我们没有旧版本。我们在那里很好。
然后我认为托管服务器可能会建立一个到贝宝的安全链接,因此创建了一个测试页面,其中包含一个带有查询字符串的 URL 到端点,例如(https://api-3t.paypal.com/nvp?USER =XXXX_api1.XXX.com&PWD=XXX&SIGNATURE=XXXXXX&VERSION=60.0&PAYMENTACTION=Authorization&AMT=1.95&RETURNURL=https://www.paypal.com&CANCELURL=https://www.paypal.com&METHOD=SetExpressCheckout )。
这有效并返回了预期的交易令牌。所以我们可以从托管服务器连接。然后考虑我们的凭据或凭据检索代码可能是问题,我将凭据从我们的数据库中提取出来并按如下方式运行测试。
使用服务器数据代码测试查询字符串=======================================
这很有效,因此凭据和端点在托管服务器上很好。
( Dim sCEnvironment As String = System.Configuration.ConfigurationManager.AppSettings("Environment")
Dim dtsettings As DataTable
dtsettings = Dac.ExecuteDataTable("GetCredentials", Dac.Parameter("@Environment", sCEnvironment))
'// Set up your API credentials, PayPal end point, API operation and version.
Dim sAPIUsername As String = dtsettings.Rows(0).Item("UserName").ToString
Dim sAPISignature As String = dtsettings.Rows(0).Item("Signature").ToString
Dim sAPIPassword As String = dtsettings.Rows(0).Item("Password").ToString
Dim sEnvironment As String = dtsettings.Rows(0).Item("Environment").ToString
Dim QS As String = "https://api-3t.paypal.com/nvp?USER=" & sAPIUsername & "&PWD=" & sAPIPassword & "&SIGNATURE=" & sAPISignature & "&VERSION=60.0&PAYMENTACTION=Authorization&AMT=1.95&RETURNURL=https://www.paypal.com&CANCELURL=https://www.paypal.com&METHOD=SetExpressCheckout"
Response.Redirect(QS)
然后我继续使用 sdk dll (paypal_base.dll) 测试令牌生成。请参阅下面的代码。在生成每一行时,我向其中添加了一个写入测试页面的字符串,这样我就可以了解我们的托管服务器上发生了什么。我们对数字商品流程使用快速结账。我从https://cms.paypal.com/cms_content/FR/fr_FR/files/developer/nvp_DoAuthorization_cs.txt获得了基本代码,并根据在线文档添加了数字商品查询参数。这适用于我的开发服务器并返回令牌。它在托管网站上运行了大约四个月,直到 1 月 27 日到 1 月 30 日之间的某个时候,我收到了客户无法购买产品的第一个通知。
在我们的托管服务器上运行时,我们得到“请求被中止:无法创建 SSL/TLS 安全通道”。下面突出显示的代码行上的错误消息。查询字符串由编码器生成并保存在变量 pStrrequestforNvp 中,因此编码器可以工作。
我很茫然。托管服务器与我们的开发服务器有什么不同?dll中是否有一种方法可以用来写出对paypal服务器的实际调用?我将我们在开发中使用的相同 dll 文件放在托管站点上,但有些不同。
测试sdk生成的查询============================
Dim caller As NVPCallerServices = New NVPCallerServices
Dim profile As IAPIProfile = ProfileFactory.createSignatureAPIProfile
Dim sCEnvironment As String = System.Configuration.ConfigurationManager.AppSettings("Environment")
Dim dtsettings As DataTable
Dim sMsg As String
dtsettings = Dac.ExecuteDataTable("GetCredentials", Dac.Parameter("@Environment", sCEnvironment))
profile.APIUsername = dtsettings.Rows(0).Item("UserName").ToString
sMsg = "APIUserName = " & dtsettings.Rows(0).Item("UserName").ToString & "<br/>"
profile.APISignature = dtsettings.Rows(0).Item("Signature").ToString
sMsg = sMsg & "APISignature = " & dtsettings.Rows(0).Item("Signature").ToString & "<br/>"
profile.APIPassword = dtsettings.Rows(0).Item("Password").ToString
sMsg = sMsg & "APIPassword = " & dtsettings.Rows(0).Item("Password").ToString & "<br/>"
profile.Environment = dtsettings.Rows(0).Item("Environment").ToString
sMsg = sMsg & "Environment = " & dtsettings.Rows(0).Item("Environment").ToString & "<br/>"
caller.APIProfile = profile
Dim encoder As NVPCodec = New NVPCodec
encoder("VERSION") = "65.1"
encoder("METHOD") = "SetExpressCheckout"
encoder("RETURNURL") = "http://www.multiware.biz/return.aspx"
encoder("CANCELURL") = "http://www.multiware.biz/cancel.aspx"
encoder("PAYMENTREQUEST_0_CURRENCYCODE") = "USD"
encoder("PAYMENTREQUEST_0_PAYMENTACTION") = "Sale"
encoder("PAYMENTREQUEST_0_AMT") = "1.95"
encoder("PAYMENTREQUEST_0_ITEMAMT") = "1.95"
encoder("PAYMENTREQUEST_0_DESC") = "Software"
encoder("L_PAYMENTREQUEST_0_ITEMCATEGORY0") = "Digital"
encoder("L_PAYMENTREQUEST_0_NAME0") = "Test"
encoder("L_PAYMENTREQUEST_0_NUMBER0") = "123"
encoder("L_PAYMENTREQUEST_0_QTY0") = "1"
encoder("L_PAYMENTREQUEST_0_AMT0") = "1.95"
encoder("L_PAYMENTREQUEST_0_DESC0") = "Download"
encoder("REQCONFIRMSHIPPING") = "0"
encoder("NOSHIPPING") = "1"
encoder("SOLUTIONTYPE") = "Sole"
Try
Dim pStrrequestforNvp As String = encoder.Encode
sMsg = sMsg & "pStrrequestforNvp = " & pStrrequestforNvp & "<br/>"
Dim pStresponsenvp As String = caller.Call(pStrrequestforNvp) ***Error occurs here***
sMsg = sMsg & "pStresponsenvp = " & pStresponsenvp & "<br/>"
Dim decoder As NVPCodec = New NVPCodec
decoder.Decode(pStresponsenvp)
Dim Token As String = decoder("TOKEN")
sMsg = sMsg & "Token = " & Token & "<br/>"
Me.lblResponse.Text = sMsg.ToString
Catch ex As Exception
sMsg = sMsg & "<br/>" & ex.Message.ToString & "<br/>" _
& ex.StackTrace.ToString
Me.lblResponse.Text = sMsg.ToString
End Try