/// <summary> /// Verifies the IPN message from PayPal /// </summary> /// <res> /// Add code under Create the IpnTransaction to process your IPN /// </res> public class IpnHandler : System.Web.UI.Page {private void Page_Load(object sender, System.EventArgs e) { string strFormValues = Request.Form.ToString(); string strNewValue; string strResponse; // Create the request back HttpWebRequest req = (HttpWebRequest) WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");// Set values for the request back req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; strNewValue = strFormValues + "&cmd=_notify-validate"; req.ContentLength = strNewValue.Length; // Write the request back IPN strings StreamWriter stOut = new StreamWriter (req.GetRequestStream(), System.Text.Encoding.ASCII); stOut.Write(strNewValue); stOut.Close();// Do the request to PayPal and get the response StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream()); strResponse = stIn.ReadToEnd(); stIn.Close();// Confirm whether the IPN was VERIFIED or INVALID. If INVALID, just ignore the IPN if (strResponse == "VERIFIED") { // Create the IpnTransaction} } }这是PAYPAL给的代码,可是有点看不懂,谁能帮讲解一下啊?
/// Verifies the IPN message from PayPal
/// </summary>
/// <res>
/// Add code under Create the IpnTransaction to process your IPN
/// </res>
public class IpnHandler : System.Web.UI.Page
{private void Page_Load(object sender, System.EventArgs e)
{
string strFormValues = Request.Form.ToString();
string strNewValue;
string strResponse;
// Create the request back
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
strNewValue = strFormValues + "&cmd=_notify-validate";
req.ContentLength = strNewValue.Length;
// Write the request back IPN strings
StreamWriter stOut = new StreamWriter (req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(strNewValue);
stOut.Close();// Do the request to PayPal and get the response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();// Confirm whether the IPN was VERIFIED or INVALID. If INVALID, just ignore the IPN
if (strResponse == "VERIFIED")
{
// Create the IpnTransaction}
}
}这是PAYPAL给的代码,可是有点看不懂,谁能帮讲解一下啊?