简体   繁体   English

CURL 来自 ASP.Net (VB.Net) PayPal

[英]CURL from ASP.Net (VB.Net) PayPal

https://developer.paypal.com/docs/archive/express-checkout/ht-ec-parallelPayments/ https://developer.paypal.com/docs/archive/express-checkout/ht-ec-parallelPayments/

Been trying to implement this on ISS with ASP.Net & VB.Net and I am not sure how to properly build the request token so that this can work and be utilized.一直在尝试使用 ASP.Net 和 VB.Net 在 ISS 上实现这个,我不确定如何正确构建请求令牌,以便它可以工作和使用。

This is what I have come up with, but the API request will not process getting this:这是我想出的,但是 API 请求不会处理得到这个:

The request was aborted: Could not create SSL/TLS secure channel.请求已中止:无法创建 SSL/TLS 安全通道。


still not working还是行不通

Private Sub btnSUBMIT_Click(sender As Object, e As EventArgs) Handles btnSUBMIT.Click

    Dim NVP As New Dictionary(Of String, String)  ''Api Name-Value-Pair parameters

    ''define paypal SANDBOX server
    Dim paypalApiServerUrl As String = "https://api-3t.sandbox.paypal.com/nvp"


    NVP.Add("USER", "fixed")   '                                                   = Caller_ID '## the PayPal User ID Of the caller account
    NVP.Add("PWD", "12345678")  '                                               PWD = Caller_Pswd '## the caller account Password
    NVP.Add("SIGNATURE", "solved")  '                                    Signature = Caller_Sig '## the caller account Signature
    NVP.Add("METHOD", METHOD)  '                                        METHOD = SetExpressCheckout '## API operation
    NVP.Add("RETURNURL", RETURNURL)  '                                     RETURNURL = https : //example.com/success.html '## URL displayed to buyer after authorizing transaction
    NVP.Add("CANCELURL", CANCELURL)  '                                    CANCELURL = https : //example.com/canceled.html '## URL displayed to buyer after canceling transaction 
    NVP.Add("Version", "93")  '                                                  Version = 93 '## API version
    NVP.Add("PAYMENTREQUEST_0_CURRENCYCODE", PAYMENTCURRENCYCODE)  '             ## Start primary level information For first payment                        
    NVP.Add("PAYMENTREQUEST_0_AMT", "250")  '                                     
    NVP.Add("PAYMENTREQUEST_0_ITEMAMT", "225")  '                                     
    NVP.Add("PAYMENTREQUEST_0_TAXAMT", "25")  '                                     
    NVP.Add("PAYMENTREQUEST_0_PAYMENTACTION", SALEPAYMENTACTION)  '                                     
    NVP.Add("PAYMENTREQUEST_0_DESC", PaymentDescription)  '                                     
    NVP.Add("PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID", "email1@address.com")  ' ## PayPal e-mail Of first receiver                                    
    NVP.Add("PAYMENTREQUEST_0_PAYMENTREQUESTID", "CIYP CART1")  '              PAYMENTREQUEST_0_PAYMENTREQUESTID = CART1 '## unique ID Of first payment – End primary level information For first payment                       
    NVP.Add("L_PAYMENTREQUEST_0_NAME0", "Super Sub CIYP")  '                    L_PAYMENTREQUEST_0_NAME0 = Super Sub '## Start secondary level information For first payment first item                 
    NVP.Add("L_PAYMENTREQUEST_0_NUMBER0", "SS - 101")  '                                     
    NVP.Add("L_PAYMENTREQUEST_0_QTY0", "1")  '                                     
    NVP.Add("L_PAYMENTREQUEST_0_AMT0", "125")
    NVP.Add("L_PAYMENTREQUEST_0_TAXAMT0", "15")  '                               ## End secondary level information For first payment first item      
    NVP.Add("L_PAYMENTREQUEST_0_NAME1", "Classic Wine Example")  '                      L_PAYMENTREQUEST_0_NAME1 = EXAMPLE Classic Wine '## Start secondary level information For first payment second item                
    NVP.Add("L_PAYMENTREQUEST_0_QTY1", "1")  '                                     
    NVP.Add("L_PAYMENTREQUEST_0_AMT1", "100")  '                                     
    NVP.Add("L_PAYMENTREQUEST_0_TAXAMT1", "10")  '                               ## End secondary level information For first payment second item                 
    NVP.Add("PAYMENTREQUEST_1_CURRENCYCODE", PAYMENTCURRENCYCODE)  '             ## Start primary level information For second payment                                   
    NVP.Add("PAYMENTREQUEST_1_AMT", "75")  '                                     ## total amount Of second payment           
    NVP.Add("PAYMENTREQUEST_1_ITEMAMT", "65")  '                                     
    NVP.Add("PAYMENTREQUEST_1_TAXAMT", "10")  '                                     
    NVP.Add("PAYMENTREQUEST_1_PAYMENTACTION", SALEPAYMENTACTION)  '                                     
    NVP.Add("PAYMENTREQUEST_1_DESC", "Mocktail Large")  '                                     
    NVP.Add("PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID", "secondpayee@address.com")  '        ## PayPal e-mail Of second receiver                             
    NVP.Add("PAYMENTREQUEST_1_PAYMENTREQUESTID", "CART2")  '                     ## unique ID Of second payment – End primary level information For secondary payment                        
    NVP.Add("L_PAYMENTREQUEST_1_NAME0", "Orange crush")  '                       ## Start secondary level information For secondary payment first item             
    NVP.Add("L_PAYMENTREQUEST_1_NUMBER0", "MC - 77")  '                                     
    NVP.Add("L_PAYMENTREQUEST_1_QTY0", "1")  '                                     
    NVP.Add("L_PAYMENTREQUEST_1_AMT0", "65")  '                                     
    NVP.Add("L_PAYMENTREQUEST_1_TAXAMT0", "10")  '                               ## End secondary level information For second payment first item      



    ''build the parameter string
    Dim paramBuilder As New StringBuilder
    For Each kv As KeyValuePair(Of String, String) In NVP
        Dim st As String
        st = kv.Key & "=" & HttpUtility.UrlEncode(kv.Value) & "&"
        paramBuilder.Append(st)
    Next

    Dim param As String
    param = paramBuilder.ToString
    param = param.Substring(0, param.Length - 1) ''remove the last '&'


    ''Create web request and web response objects, make sure you using the correct server (sandbox/live)
    Dim wrWebRequest As Net.HttpWebRequest = DirectCast(Net.WebRequest.Create(paypalApiServerUrl), Net.HttpWebRequest)
    wrWebRequest.Method = "POST"


    Dim requestWriter As New IO.StreamWriter(wrWebRequest.GetRequestStream())
    requestWriter.Write(param)
    requestWriter.Close()

    '' Get the responseReader
    Dim responseReader As IO.StreamReader
    responseReader = New IO.StreamReader(wrWebRequest.GetResponse().GetResponseStream())

    ''read the response
    Dim responseData As String
    responseData = responseReader.ReadToEnd()
    responseReader.Close()


    ''url-decode the results
    Dim result As String
    result = HttpUtility.UrlDecode(responseData)

    Dim formattedResult As String

    formattedResult = "Request on " & paypalApiServerUrl & vbCrLf &
                     HttpUtility.UrlDecode(param.Replace("&", vbCrLf & "  ")) & vbCrLf & vbCrLf &
                     "Result:" & vbCrLf & HttpUtility.UrlDecode(responseData.Replace("&", vbCrLf & "  ")) & vbCrLf & vbCrLf &
                     "--------------------------------------" & vbCrLf

    ''show the results
    Console.WriteLine(formattedResult)
    Response.Write(formattedResult)
    MSG.Text = formattedResult



End Sub

What I came up with is not working,我想出的是行不通的,


Message: The request was aborted: Could not create SSL/TLS secure channel.消息:请求已中止:无法创建 SSL/TLS 安全通道。


Found these resources which helped shed some light on the subject找到了这些有助于阐明该主题的资源

http://brad.w3portals.com/2008/03/paypal-nvp-api-example-for-v.net-as.net.html http://brad.w3portals.com/2008/03/paypal-nvp-api-example-for-v.net-as.net.html

How to create Encrypted PayNow button "on the fly" for Third-party customers, using Paypal NVP API? 如何使用 Paypal NVP API 为第三方客户“即时”创建加密的 PayNow 按钮?

https://www.paypal.com/businessprofile/mytools/apiaccess/firstparty/signature https://www.paypal.com/businessprofile/mytools/apiaccess/firstparty/signature

For name value pair format, the values (right hand side) should be URL encoded, and the pairs should be separated by ampersands (&)对于名称值对格式,值(右侧)应为 URL 编码,并且这些对应由与号 (&) 分隔

You can have a function that builds the request string text out of an array or dictionary您可以使用 function 从数组或字典中构建请求字符串文本

Are you using a valid USER/PWD/Signature from the profile of a Sandbox Business account at https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F ?您是否在https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts中使用来自沙盒企业帐户配置文件的有效用户/PWD/签名%2F


An SSL/TLS error may be due a lack of TLSv1.2 support on the server or framework environment, among other possible causes like not trusting the root CA issuer of the SSL certificate of the api-3t.paypal.com server it's connecting to SSL/TLS 错误可能是由于服务器或框架环境缺乏 TLSv1.2 支持,以及其他可能的原因,例如不信任它所连接的 api-3t.paypal.com 服务器的 SSL 证书的根 CA 颁发者

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM