IPN Issue, Not Updating Database
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a paypal merchant account and some times people pay me on pay pal after subscribing.
Sometimes I have a problem of receiving IPN and updating my database and sometime my database don't get updated although payment is successfully made on PayPal for the same subscription.
I tried to use the IPN Message as suggested to see what went wrong locally, but it giving me forbidden errors.
The is sample of my code:
[HttpPost]
public HttpStatusCodeResult Receive()
{
//Store the IPN received from PayPal
LogRequest(Request);
//Fire and forget verification task
Task.Run(() => VerifyTask(Request));
//Reply back a 200 code
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
private void VerifyTask(HttpRequestBase ipnRequest)
{
var verificationResponse = string.Empty;
try
{
using (var client = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var param = Request.BinaryRead(ipnRequest.ContentLength);
var strRequest = Encoding.ASCII.GetString(param);
strRequest = "cmd=_notify-validate&" + strRequest;
verificationResponse = client.UploadString("https://www.paypal.com/cgi-bin/webscr", strRequest);
}
}
catch (Exception exception)
{
//Capture exception for manual investigation
}
ProcessVerificationResponse(verificationResponse);
}
private void ProcessVerificationResponse(string verificationResponse)
{
if (verificationResponse.Equals("VERIFIED"))
{
// check that Payment_status=Completed
// check that Txn_id has not been previously processed
// check that Receiver_email is your Primary PayPal email
// check that Payment_amount/Payment_currency are correct
// process payment
if (Request.Form["txn_type"] == "subscr_signup")
{
}
else if (Request.Form["txn_type"] == "subscr_payment" && Request.Form["payment_status"] == "Completed")
{
//do something
}
else if (Request.Form["txn_type"] == "subscr_cancel")
{
//do something 2
}
}
else if (verificationResponse.Equals("INVALID"))
{
//Log for manual investigation
}
else
{
//Log error
}
}
My Online IPN : https://vodapi.mtv.com.lb/IPN/Receive.
Please advice on how to debug what is going wrong.

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- If I don't capture within the 3 hour limit, how can I be sure that the payment went through? in REST APIs
- How do I resolve RESOURCE_NOT_FOUND Error? in REST APIs
- WooCommerce order error: CANNOT_MIX_CURRENCIES in Sandbox Environment
- Error: "Unable to change shipping method. Please try again." in PayPal popup in REST APIs
- Profile issue - Profile keep hanging, unable to access Developer side, unable to update/change API in REST APIs