Stream was not Readable for PayPalRest API - paypal

This occurs in the Sandbox or production. In the sandbox if I enter in a Visa of 4111111111111111 with a code, and exp date... When I hit the payment.Creat(token) line, an exception is thrown, "Stream was not readable". If I put in some other CC number like 4234567890123456 the payment works fine. In production, if I use that 4234... I get the stream was not readable error. I understand test cards do not always work, but I expect back a Credit Card invalid response. The problem I have is that some of my customers are getting the stream error.... If I put in a real CC in production, it works fine.. but if i change 1 number I get the invalid card error.... So sometimes it sends it back correctly, other times it is the Stream error... I recently update the package to latest and greatest API using Nuget, but does anyone else have any suggestions?
Here is my relevant code
try
{
var token = GetAPIToken();
var creditCard = new CreditCard();
creditCard.number = req.CardNumber;
creditCard.expire_month = req.ExpMonth;
creditCard.expire_year = req.ExpYear;
creditCard.first_name = req.FirstName;
creditCard.last_name = req.LastName;
creditCard.type = req.CardType;
creditCard.payer_id = req.UserId.ToString();
creditCard.cvv2 = req.SecurityCode;
creditCard.billing_address = new Address()
{
line1 = req.Address1,
city = req.City,
state = req.State,
postal_code = req.ZipCode,
country_code = "US"
};
var payment = new Payment();
payment.intent = "sale";
payment.payer = new Payer();
payment.transactions = new List<Transaction>();
var t = new Transaction()
{
description = req.Description,
amount = new Amount()
{
total = req.TotalPayment.ToString("N2"),
currency = "USD",
},
};
t.item_list = new ItemList();
t.item_list.items = new List<Item>();
t.item_list.items.Add(new Item()
{
name = req.Description,
quantity = "1",
price = req.TotalPayment.ToString("N2"),
currency = "USD",
});
payment.transactions.Add(t);
payment.payer.funding_instruments = new List<FundingInstrument>();
payment.payer.payment_method = "credit_card";
var fundingInstrument = new FundingInstrument();
fundingInstrument.credit_card = creditCard;
payment.payer.funding_instruments.Add(fundingInstrument);
var pay = payment.Create(token);
if (req.PaymentOption != PayOption.UsePayPal && pay.state == PayPalStateApproved
&& pay.transactions.Any() && pay.transactions[0].related_resources.Any()
&& pay.transactions[0].related_resources[0].sale != null
&& !String.IsNullOrEmpty(pay.transactions[0].related_resources[0].sale.id))
{
resp.TransactionID = pay.transactions[0].related_resources[0].sale.id;
}
else
{
resp.Status = Status.Error;
resp.Messages.Add(new Message { Code = "paypal", Text = pay.state });
}
}
catch (Exception ex)
{
var err = CheckPayPalError(ex);
resp.Messages.Add(new Message { Code = "paypal", Text = String.IsNullOrEmpty(err) ? ex.Message : err });
resp.Status = Status.Error;
}
return resp;
Here are the log entries, the first is if Retry is set to > 0, the second is with no retry
2013-08-29 09:41:45,852 [33] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052;bit=64;os=Windows 7 6.1.7601.65536;
2013-08-29 09:41:45,852 [33] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:a781e6bb-c0b0-4f06-abf8-1202dbc17a59
2013-08-29 09:41:45,920 [33] DEBUG PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","last_name":"Keenan","billing_address":{"line1":"123 Main St","city":"Denver","country_code":"US","postal_code":"80210","state":"CO"},"payer_id":"205"}}]},"transactions":[{"amount":{"currency":"USD","total":"4.75"},"description":"WFS Lunch Order","item_list":{"items":[{"quantity":"1","name":"WFS Lunch Order","price":"4.75","currency":"USD"}]}}]}
2013-08-29 09:41:49,505 [33] ERROR PayPal.Manager.ConnectionManager [(null)] Error Response: {"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"2520071cde1ca"}
2013-08-29 09:41:49,506 [33] INFO PayPal.Manager.ConnectionManager [(null)] Got InternalServerError status code from server
2013-08-29 09:41:49,507 [33] ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute: Stream was not readable.
PayPal.Exception.PayPalException: Exception in HttpConnection Execute: Stream was not readable. ---> System.ArgumentException: Stream was not readable.
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream)
at PayPal.HttpConnection.Execute(String payLoad, HttpWebRequest httpRequest)
--- End of inner exception stack trace ---
Here is the second
2013-08-29 09:44:27,685 [16] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052;bit=64;os=Windows 7 6.1.7601.65536;
2013-08-29 09:44:27,686 [16] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:1d5c68e5-4b4b-4876-8bf4-3b9f64d0afb6
2013-08-29 09:44:27,753 [16] DEBUG PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","last_name":"Keenan","billing_address":{"line1":"123 Main St","city":"Denver","country_code":"US","postal_code":"80210","state":"CO"},"payer_id":"205"}}]},"transactions":[{"amount":{"currency":"USD","total":"4.75"},"description":"WFS Lunch Order","item_list":{"items":[{"quantity":"1","name":"WFS Lunch Order","price":"4.75","currency":"USD"}]}}]}
2013-08-29 09:44:28,847 [16] ERROR PayPal.Manager.ConnectionManager [(null)] Error Response: {"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"465701e606a56"}
2013-08-29 09:44:28,848 [16] INFO PayPal.Manager.ConnectionManager [(null)] Got InternalServerError status code from server
2013-08-29 09:44:28,850 [16] ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute
PayPal.Exception.PayPalException: Exception in HttpConnection Execute

We sometimes see issue with the Test Card 4111xxx in sandbox and are investigating the fix for the same. Hence use the other Test card in sandbox for your testing.
Reg the stream read error, will test the provided code and update back.

Issue has been fixed in core SDK. Fix is available in branch https://github.com/paypal/sdk-core-dotnet/tree/fix-log4net-stream. Please see https://github.com/paypal/rest-api-sdk-dotnet/issues/10 for more details.

After talking with PayPal support about this same issue: apparently even in the Sandbox, if a credit card is used too many times it will be blocked. They suggested trying other fake card numbers, and referred me to this site for generating them:
http://www.fakenamegenerator.com/
Using cards generated there has been working for me.

Related

Powershell and selenium chromedriver getting SSL error opening website [duplicate]

I have added
ChromeOptions options = new ChromeOptions();
options.AddArgument("--ignore-certificate-errors-spki-list");
options.AddArgument("--ignore-ssl-errors");
options.AddArgument("test-type");
options.AddArguments("-incognito");
options.AddArgument("no-sandbox");
options.AddArgument("--start-maximized");
driver = new ChromeDriver(options);
But still getting:
ssl_client_socket_impl.cc(1061)] handshake failed error
How to suppress this error from console?
This error message...
[ERROR:ssl_client_socket_openssl.cc(855)] handshake failed; returned -1, SSL error code 1, net_error -2
...implies that the handshake failed between ChromeDriver and Chrome Browser failed at some point.
Root Cause
This error is generated due to net::SSLClientSocketImpl::DoHandshake and net::SSLClientSocketImpl implemented in ssl_client_socket_impl.cc
net::SSLClientSocketImpl::DoHandshake as follows:
int SSLClientSocketImpl::DoHandshake() {
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
int rv = SSL_do_handshake(ssl_.get());
int net_error = OK;
if (rv <= 0) {
int ssl_error = SSL_get_error(ssl_.get(), rv);
if (ssl_error == SSL_ERROR_WANT_CHANNEL_ID_LOOKUP) {
// The server supports channel ID. Stop to look one up before returning to
// the handshake.
next_handshake_state_ = STATE_CHANNEL_ID_LOOKUP;
return OK;
}
if (ssl_error == SSL_ERROR_WANT_X509_LOOKUP &&
!ssl_config_.send_client_cert) {
return ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
}
if (ssl_error == SSL_ERROR_WANT_PRIVATE_KEY_OPERATION) {
DCHECK(ssl_config_.client_private_key);
DCHECK_NE(kSSLClientSocketNoPendingResult, signature_result_);
next_handshake_state_ = STATE_HANDSHAKE;
return ERR_IO_PENDING;
}
OpenSSLErrorInfo error_info;
net_error = MapLastOpenSSLError(ssl_error, err_tracer, &error_info);
if (net_error == ERR_IO_PENDING) {
// If not done, stay in this state
next_handshake_state_ = STATE_HANDSHAKE;
return ERR_IO_PENDING;
}
LOG(ERROR) << "handshake failed; returned " << rv << ", SSL error code "
<< ssl_error << ", net_error " << net_error;
net_log_.AddEvent(
NetLogEventType::SSL_HANDSHAKE_ERROR,
CreateNetLogOpenSSLErrorCallback(net_error, ssl_error, error_info));
}
next_handshake_state_ = STATE_HANDSHAKE_COMPLETE;
return net_error;
}
As per ERROR:ssl_client_socket_openssl.cc handshake failed the main issue is the failure of handshake when ChromeDriver handshakes with SSL pages in Chrome. Though Chromium team conducts test for SSL handshake through net_unittests, content_tests, and browser_tests but were not exhaustive. Some usecases are left out relying on the upstream tests.
Conclusion
This error won't interupt the execution of your Test Suite and you can ignore this issue for the time being till it is fixed by the Chromium Team.
You can restrict Chromium's log level to 3, so that only fatal errors are logged. Please bear in mind that you won't see any other error-related messages which might cause mayhem in production! The code looks like this:
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("log-level=3");
var driver = new ChromeDriver(options : chromeOptions);
Chromium log levels are:
Description
Value
INFO
0
WARNING
1
LOG_ERROR
2
LOG_FATAL
3

RESTful client in Unity - validation error

I have a RESTful server created with ASP.Net and am trying to connect to it with the use of a RESTful client from Unity. GET works perfectly, however I am getting a validation error when sending a POST request. At the same time both GET and POST work when sending requests from Postman.
My Server:
[HttpPost]
public IActionResult Create(User user){
Console.WriteLine("***POST***");
Console.WriteLine(user.Id+", "+user.sex+", "+user.age);
if(!ModelState.IsValid)
return BadRequest(ModelState);
_context.Users.Add(user);
_context.SaveChanges();
return CreatedAtRoute("GetUser", new { id = user.Id }, user);
}
My client:
IEnumerator PostRequest(string uri, User user){
string u = JsonUtility.ToJson(user);
Debug.Log(u);
using (UnityWebRequest webRequest = UnityWebRequest.Post(uri, u)){
webRequest.SetRequestHeader("Content-Type","application/json");
yield return webRequest.SendWebRequest();
string[] pages = uri.Split('/');
int page = pages.Length - 1;
if (webRequest.isNetworkError || webRequest.isHttpError){
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
}
else{
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
}
}
}
I was trying both with the Json conversion and writing the string on my own, also with the WWWForm, but the error stays.
The error says that it's an unknown HTTP error. When printing the returned text it says:
"One or more validation errors occurred.","status":400,"traceId":"|b95d39b7-4b773429a8f72b3c.","errors":{"$":["'%' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0."]}}
On the server side it recognizes the correct method and controller, however, it doesn't even get to the first line of the method (Console.WriteLine). Then it says: "Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ValidationProblemDetails'".
Here're all of the server side messages:
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:5001/user application/json 53
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Route matched with {action = "Create", controller = "User"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Create(TheNewestDbConnect.Data.Entities.User) on controller TheNewestDbConnect.Controllers.UserController (TheNewestDbConnect).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ValidationProblemDetails'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect) in 6.680400000000001ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 11.3971ms 400 application/problem+json; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
I have no idea what is happening and how to solve it. Any help will be strongly appreciated!
Turned out I was just missing an upload handler. Adding this line solved it: webRequest.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(JsonObject));

Example code for IPN Listener is incorrect according to the docs. Is it?

Sample code provided by PayPal at this reference clearly contradicts all the code examples I can find. Specifically that it requires the "&cmd=_notify-validate" at the beginning and not at the end.
The following code passes the first test ie by just responding to the request in the IPN Simulator. Once the grunt code is added all I get is the "IPN was not sent, and the handshake was not verified. Please review your information." response.
I've commented the following code as much as seems appropriate:
protected void Page_Load(object sender, EventArgs e)
{
mclog.Info("entered PayPalListener Page_Load");
// Commenting out the rest results in a successful handshake etc with the IPN Simulator
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
// string strLive = "https://www.paypal.com/cgi-bin/webscr";
mclog.Info(string.Format("strSandBox = [{0}]", strSandbox));
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
// The following string can have the cmd text at the beginning or end. Both cause the IPN to spit the dummy.
string strRequest = "&cmd=_notify-validate&";
strRequest += Encoding.ASCII.GetString(param);
// "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
mclog.Info(string.Format("strRequest = [{0}]", strRequest));
//Send the request to PayPal and get the response
StreamWriter streamOut =
new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn =
new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
mclog.Info(string.Format("strResponse = [{0}]", strResponse));
}
The code appears correct so after much searching I assume there is something else I must do. There is mention of "enabling" IPN in my "profile" however there is no such option in the profiles that I can locate in my Developers Account.
I've been trying and searching for days and the frustration levels are of the scale. If you do have some suggestions then please be as detailed as possible because the PayPal documentation is very confusing and it seems much previous good advice is now out-of-date.
some logging results are:
2016-07-15 00:02:29:854 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 entered PayPalListener Page_Load
2016-07-15 00:02:29:854 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 Received
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strSandBox = [https://www.sandbox.paypal.com/cgi-bin/webscr]
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [payment_type=instant&payment_date=Fri%20Jul%2015%202016%2016%3A32%3A05%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=636818821&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AneSo.zKXXEtrcrzCxSU.y9TEUb1A9u2e-FoPLwAA6kE8qMzV0UNUYV5]
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [payment_type=instant&payment_date=Fri%20Jul%2015%202016%2016%3A32%3A05%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=636818821&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AneSo.zKXXEtrcrzCxSU.y9TEUb1A9u2e-FoPLwAA6kE8qMzV0UNUYV5&cmd=_notify-validate]
2016-07-15 00:45:09:012 W15 INFO MyPayPal.Global.createMCLog.0 ###################################
2016-07-15 00:45:09:106 W15 INFO MyPayPal.Global.createMCLog.0 MyPayPal v1.0.0.0 Startup
2016-07-15 00:45:12:700 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 entered PayPalListener Page_Load
2016-07-15 00:45:12:715 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strSandBox = [https://www.sandbox.paypal.com/cgi-bin/webscr]
2016-07-15 00:45:12:778 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [&cmd=_notify-validate&]
2016-07-15 00:45:12:778 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [&cmd=_notify-validate&payment_type=instant&payment_date=Fri%20Jul%2015%202016%2017%3A14%3A51%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=952340474&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31Ag-J5Edcf2.K.Ii9C6RoBck3ltT5]
In my experience of running a Java servlet-based IPN listener for several years, the order of the parameters in the verification message doesn't make the slightest bit of difference, contrary to numerous statements in the IPN documentation.
Paypal provide Java code for sending the verification message from a servlet, and a Java servlet doesn't have access to the parameters in the order they were sent in the first place, which also goes to prove the point.
EDIT NB This is not valid:
strRequest = [&cmd=_notify-validate&payment_type=instant&payment_date=...
The POST parameters should not start with &. It's a separator, between the name-value pairs.

Intuit Reporting services (Balancesheet / profilt and loss)

i am using the following code to get the balancesheet and profilt and loss data from quickbooks.
OAuthRequestValidator oauth = new OAuthRequestValidator(accessToken, accessTokenSecret,
consumerKey, consumerSecret);
ServiceContext serviceContext = new ServiceContext(realmId, IntuitServicesType.QBO, oauth);
serviceContext.IppConfiguration.Message.Request.SerializationFormat =
Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
ReportService reportService = new ReportService(serviceContext);
reportService.accounting_method = "Accrual";
reportService.start_date = "2014-01-01";
reportService.end_date = "2014-06-01";
Report report = reportService.ExecuteReport("BalanceSheet");
it compiles well, but when it runs it gives the following error.
"
**Ids service endpoint was not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Intuit.Ipp.Exception.EndpointNotFoundException: Ids service endpoint was not found.
Source Error:
Line 133: reportService.start_date = "2014-01-01";
Line 134: reportService.end_date = "2014-06-01";
Line 135: Report report = reportService.ExecuteReport("BalanceSheet");
Line 136:
Line 137:"**
Please use the correct date format YYYY-MM-DD.
Please use response format as JSON as xml is not supported. Your code will work then.
serviceContext.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;

Paypal responding to IPN verification with 500 error

Every once in a while Paypal is returning a 500 error code to my .net applications ipn script. It is returning that code in the response to the verification request
Here's the error that is logged:
System.Net.WebException
The remote server returned an error: (500) Internal Server Error.
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at ASP.ipn_aspx.Page_Load(Object sender, EventArgs e)
The code that Im using for the call is:
endPoint = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(endPoint);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
This probably happens about once per day and PayPal doesn't retry the ipn message. The other 95% of the PayPal ipn transactions are working fine. Any ideas?