如何从asp.net中的paypal(Sandbox)获取返回url中的参数

Posted

技术标签:

【中文标题】如何从asp.net中的paypal(Sandbox)获取返回url中的参数【英文标题】:How to get parameters in return url from paypal(Sandbox) in asp.net 【发布时间】:2014-01-15 19:12:26 【问题描述】:

您好,我正在使用贝宝(沙盒帐户)集成到我的 asp.net 网站。我可以使用价格和商品名称进入贝宝,但我想在返回 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>

我已经尝试过***的一个链接,但是我没有正确地得到这个。

http://***.com/questions/15322148/paypal-multi-parameters-in-return-cancel-return-urls

我是第一次这样做所以请建议我您的宝贵答案。

谢谢

【问题讨论】:

点击以下链接希望您能找到答案。 [***.com/questions/24516642/…[1]:***.com/questions/24516642/… 【参考方案1】:

将您设置返回 url 的代码行更改为:

redirectUrl += "&return=" & ConfigurationManager.AppSettings("SuccessURL").ToString() & _
"&custom=MyCustomValue"

并跟踪任何其他类似的自定义参数。此外,您应该对整个返回 url 进行 url 编码,因为它在查询字符串中包含一个查询字符串。

【讨论】:

以上是关于如何从asp.net中的paypal(Sandbox)获取返回url中的参数的主要内容,如果未能解决你的问题,请参考以下文章

如何通过 ASP.NET 将资金从商家 Paypal 帐户转移到 EndUser Paypal 帐户?

Paypal 错误从 Asp.net 中的传输流中收到意外的 EOF 或 0 字节

如何在 asp .net mvc 中集成 paypal 付款并接收付款状态和信息?

ASP.Net WebForms + Paypal 表单

在 asp.net 中使用 paypal 授权后链式付款

使用 asp.net 和 C# 集成 Paypal [关闭]