简体   繁体   中英

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.

I am trying this is on local.(Is this possible to get parameters in return url for local).

On Paypal when i click on "Return to facilitator account's Test Store" then it return me to successpage.aspx.

How i can get parameters value in this return 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:

     <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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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