Reputation: 21
I'm getting this error, Received an unexpected EOF or 0 bytes from the transport stream, when calling SetExpressCheckout in api-3t.sandbox.paypal.com. I'm using Asp.net to call the api.
Here is my code:
private static NameValueCollection Submit(string values)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
String.Format("https://{0}/nvp", PayPalSettings.ApiDomain));
request.Method = "POST";
request.ContentLength = values.Length;
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(values);
}
WebResponse webResponse = request.GetResponse();
Stream response = webResponse.GetResponseStream();
using (StreamReader reader = new StreamReader(response))
{
return HttpUtility.ParseQueryString(reader.ReadToEnd());
}
}
The error would occur when I call request.GetRequestStream().
The values parameter contains: USER=< username >&PWD=< password >&METHOD=SetExpressCheckout&VERSION=76.0&HDRIMG=< image url >&RETURNURL=< return url >&CANCELURL=< cancel url >&BUTTONSOURCE=PP-ECWizard&SUBJECT=&ALLOWNOTE=0&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_AMT=100&PAYMENTREQUEST_0_CURRENCYCODE=AUD&NOSHIPPING=1&L_PAYMENTREQUEST_0_NAME0=Registration&L_PAYMENTREQUEST_0_DESC0=Registration+Details&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_AMT0=100
PayPalSettings.ApiDomain = api-3t.sandbox.paypal.com
What's weird is that if I use the same code above and call the live/production paypal api it will work. Using the live/production url and credentials of course.
Also if I post the url mentioned above(https://api-3t.sandbox.paypal.com/nvp?USER=< username >&PWD=< password >&METHOD=SetExpressCheckout&VERSION=76.0&HDRIMG=< image url >&RETURNURL=< return url >&CANCELURL=< cancel url >&BUTTONSOURCE=PP-ECWizard&SUBJECT=&ALLOWNOTE=0&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_AMT=100&PAYMENTREQUEST_0_CURRENCYCODE=AUD&NOSHIPPING=1&L_PAYMENTREQUEST_0_NAME0=Registration&L_PAYMENTREQUEST_0_DESC0=Registration+Details&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_AMT0=100) in a browser it would return the desired result.
Your help would be greatly appreciated.
Thank you.
Upvotes: 2
Views: 1339
Reputation: 422
After some research I figured out.
Apparently since some months ago paypal
change the TLS version supported making version 1.2 the minimum supported.
The problem is that .Net Framework 3.5 does not support that version. For frameworks higher than 3.5 you can add the next line:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
Since this problem is almost from a year ago, I dont think Microsoft is going to make an update for fw 3.5, so I suggest to migrate your App to 4.5.
Upvotes: 3