Paypal Express购物车结账前的价格

我使用PayPal快速结帐,并试图在用户决定结帐时获取购物车中的总价值。 我的运费将以总价为基础,虽然我的PayPal帐户设置中填写了运费计算,但运费在结帐屏幕上并未显示。 如何在结帐时获取总购物车价格,以便我可以添加运费? 到目前为止,我所拥有的只是用户签出后的价值,他们会被退回到我的网站,但在这一点上,加入运费已经太迟了。

Dim authToken As String = "sdf5414FdsfDFS5eEF52s336DFLLJUhhbuzek64"
    Dim txToken As String = Request.QueryString("tx")
    txToken = "4GGSES84eEWSS" 
    Dim strRequest As String = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken

    'Dim Payerinfo As New PayerInfo
    'Dim trans As New Transaction
    'Dim tra As New PayPal.PayPalAPIInterfaceService.Model.GetTransactionDetailsReq




    'post back to either sandbox or live
    Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
    Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
    Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)
    'req.Headers = valHeader
    'Set values for the request back
    req.Method = "POST"
    req.ContentType = "application/x-www-form-urlencoded"
    req.ContentLength = strRequest.Length

    'Send the request to PayPal and get the response
    Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
    streamOut.Write(strRequest)
    streamOut.Close()
    Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
    Dim strResponse As String = streamIn.ReadToEnd()
    streamIn.Close()

    If Not String.IsNullOrEmpty(strResponse) Then

        Dim results As New Dictionary(Of String, String)
        Dim reader As New StringReader(strResponse)
        Dim line As String = reader.ReadLine()
        If line = "SUCCESS" Then
            'FormView1.Visible = False
            While True
                Dim aLine As String
                aLine = reader.ReadLine
                If aLine IsNot Nothing Then
                    Dim strArr() As String
                    strArr = aLine.Split("=")
                    results.Add(strArr(0), strArr(1))
                Else
                    Exit While
                End If
            End While

            ' Displays all the keys for results, helps to see what the keys are named for writing to text file

            For Each kvp As KeyValuePair(Of String, String) In results
                Dim v1 As String = kvp.Key
                Dim v2 As String = kvp.Value
                Response.Write(v1.ToString _
                        + ":  " + v2 + "<br /> ")
            Next

        End If

我也一直在尝试声明一个会话变量,并在每次点击添加到购物车按钮时添加它,但是我在此看到一个问题,因为我不知道这些项目将保留在PayPal购物车中多久,如果会话变量会话耗尽时间并被清除,他们将收到免费送货,因为运送金额清除。 他们有什么方法可以做到这一点?

Protected Sub AddToCartBtn_Click(sender As Object, e As EventArgs)
Session("CartAmount")     

 Dim itemNumber As String = str2
    Dim itemAmount As String = price
    Dim currencyCode As String = "USD"
    Dim addItem As Integer = 1

    Dim ppHref As StringBuilder = New StringBuilder()
    ppHref.Append("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart")
    ppHref.Append("&business=" + business)
    ppHref.Append("&item_name=" + itemName)
    ppHref.Append("&item_number=" + itemNumber)
    ppHref.Append("&amount=" + itemAmount)
    ppHref.Append("&currency_code=" + currencyCode)   
Session("CartAmount") = (cartTotal + Session("CartAmount"))
End Sub

您可以通过以下url参考提供的变量传递购物车值,https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HF080O3

链接地址: http://www.djcxy.com/p/35911.html

上一篇: Get Paypal Express cart Price right before checkout

下一篇: IIS7 webserver linq to sql error