简体   繁体   English

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

[英]How to get parameters in return url from paypal(Sandbox) in asp.net

Hi i am using paypal (sandbox account) to integrate to my asp.net website.I am able to enter into paypal with price and item name,But i want to get these paramaters in return url so i can save them in database for my records. 嗨,我正在使用paypal(沙盒帐户)集成到我的asp.net网站。我能够使用价格和商品名称输入paypal,但是我想在返回URL中获取这些参数,以便将其保存在数据库中记录。

I am trying this is on local.(Is this possible to get parameters in return url for local). 我正在尝试这是在本地上的(这是否有可能在本地的返回URL中获取参数)。

On Paypal when i click on "Return to facilitator account's Test Store" then it return me to successpage.aspx. 在Paypal上,当我单击“返回主持人帐户的测试存储”时,它将返回到successpage.aspx。

How i can get parameters value in this return url. 我如何在此返回URL中获取参数值。

Here code that i have write checkout page : 这是我写了结帐页面的代码:

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)

End Sub 结束子

webconfig code: 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>

I have tried one link of stackoverflow,But i did not get this properly. 我已经尝试了stackoverflow的一个链接,但是我没有正确地获得它。

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

I am doing this first time So please suggest me with your valuable answers. 我是第一次这样做,所以请提出宝贵的建议给我。

Thanks 谢谢

Change the line of code where you set the return url to this: 更改将返回网址设置为此的代码行:

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

And track any other custom parameters like this. 并跟踪任何其他这样的自定义参数。 Also, you should url encode the entire return url as it includes a query-string within query-string. 另外,您应该对整个返回URL进行url编码,因为它在query-string中包含一个query-string。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM