您好,我正在使用 paypal(沙盒帐户)集成到我的 asp.net 网站。我可以使用价格和商品名称进入 paypal,但我想在返回 url 中获取这些参数,以便将它们保存在我记录的数据库。
我正在尝试这是在本地进行的。(这是否有可能在本地的返回 url 中获取参数)。
在 Paypal 上,当我单击“返回服务商帐户的测试商店”时,它会返回到 successpage.aspx。
如何在此返回 url 中获取参数值。
这里是我编写结帐页面的代码:
Protected Sub imgbtn_Click(sender As Object, e As ImageClickEventArgs) Handles imgbtn.Click
Dim qty As Integer = Request.QueryString("qty")
Dim Amount As String = Request.QueryString("price")
Dim ItemDescription As String = Request.QueryString("ItemDescription")
Dim redirectUrl As String = ""
'Mention URL to redirect content to paypal site
redirectUrl += "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" & ConfigurationManager.AppSettings("paypalemail").ToString()
'Product Name
redirectUrl += "&item_name=" + ItemDescription
'Product Amount
redirectUrl += "&amount=" + Amount
'Business contact paypal EmailID
redirectUrl += "&xxxxx-facilitator@gmail.com"
'Quantiy of product, Here statically added quantity 1
redirectUrl += "&quantity=" + qty.ToString()
'If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer
redirectUrl += "&return=" & ConfigurationManager.AppSettings("SuccessURL").ToString()
redirectUrl += "&cancel_return=" & ConfigurationManager.AppSettings("FailedURL").ToString()
Response.Redirect(redirectUrl)
结束子
网络配置代码:
<appSettings>
<add key="paypalemail" value="xxxx-facilitator@gmail.com" />
<add key="SuccessURL" value="http://localhost:53725/Project/SuccessPayment.aspx " />
<add key="FailedURL" value="http://localhost:53725/Project/Index.aspx" />
</appSettings>
我已经尝试了stackoverflow的一个链接,但是我没有得到正确的链接。
http://stackoverflow.com/questions/15322148/paypal-multi-parameters-in-return-cancel-return-urls
我是第一次这样做,所以请向我推荐您宝贵的答案。
谢谢
最佳答案
将设置返回 url 的代码行更改为:
redirectUrl += "&return=" & ConfigurationManager.AppSettings("SuccessURL").ToString() & _
"&custom=MyCustomValue"
并像这样跟踪任何其他自定义参数。此外,您应该对整个返回 url 进行 url 编码,因为它在查询字符串中包含一个查询字符串。
关于c# - 如何在 asp.net 中从 paypal(Sandbox) 获取返回 url 中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20813478/