private void VerifyTask(HttpRequestBase ipnRequest, string memo) { try { var verificationRequest = (HttpWebRequest)WebRequest.Create(Application.PayPalIPNUrl); //Set values for the verification request verificationRequest.Method = "POST"; verificationRequest.ContentType = "application/x-www-form-urlencoded"; var param = Request.BinaryRead(ipnRequest.ContentLength); var strRequest = Encoding.ASCII.GetString(param); //Add cmd=_notify-validate to the payload strRequest = "cmd=_notify-validate&" + strRequest; verificationRequest.ContentLength = strRequest.Length; //Attach payload to the verification request var streamOut = new StreamWriter(verificationRequest.GetRequestStream(), Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); //Send the request to PayPal and get the response var streamIn = new StreamReader(verificationRequest.GetResponse().GetResponseStream()); var verificationResponse = streamIn.ReadToEnd(); streamIn.Close(); var transactionIdentifier = memo.Split(':')[1].Trim(); //_logger.Info($"strRequest: {strRequest}"); //_logger.Info($"verificationResponse: {verificationResponse}"); // We receive 2 messages from PayPal. Only complete this for one... if (verificationResponse.Equals("VERIFIED")) { if (strRequest.Contains("payment_type=instant")) { _paymentManager.CompleteTransaction(transactionIdentifier); _logger.Info($"IPNController.VerifyTask. Payment marked as 'Paid'. transactionIdentifier={transactionIdentifier}"); } } else { _logger.Warn($"IPNController.VerifyTask. A non-verified request was received. transactionIdentifier={transactionIdentifier}"); } } catch (Exception ex) { _logger.Error("IPNController.VerifyTask", ex); } }