![](/img/trans.png)
[英]How to Get Transaction Details from return URL from Paypal Payment Gateway using ASP.Net and C#
[英]How to get parameters in return url from paypal(Sandbox) in asp.net
嗨,我正在使用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)
结束子
webconfig代码:
<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
我是第一次这样做,所以请提出宝贵的建议给我。
谢谢
更改将返回网址设置为此的代码行:
redirectUrl += "&return=" & ConfigurationManager.AppSettings("SuccessURL").ToString() & _
"&custom=MyCustomValue"
并跟踪任何其他这样的自定义参数。 另外,您应该对整个返回URL进行url编码,因为它在query-string中包含一个query-string。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.