簡體   English   中英

如何從asp.net中的paypal(Sandbox)獲取返回URL中的參數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM