gpt4 book ai didi

asp.net - 结帐前立即获取 Paypal Express 购物车价格

转载 作者:太空宇宙 更新时间:2023-11-03 16:00:56 24 4
gpt4 key购买 nike

我正在使用 paypal 快速结账,我试图在用户决定结账时获取购物车中的总值(value)。我的运费将基于总价,虽然我在我的 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

我也一直在尝试声明一个 session 变量,并在每次单击“添加到购物车”按钮时添加到它,但我看到了一个问题,因为我不知道这些项目将在 paypal 购物车中保留多长时间,并且如果 session 变量 session 超时并被清除,他们将收到免运费,因为运费已清零。他们有什么方法可以使这项工作成功吗?

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

最佳答案

关于asp.net - 结帐前立即获取 Paypal Express 购物车价格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28439463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com