Jump to content


Photo

Sandbox Express Checkout In Dot Net Throws Exception


  • Please log in to reply
No replies to this topic

#1 Jitendra

Jitendra

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 20 February 2016 - 08:26 AM

I am using the sandbox API - https://api-3t.sandbox.paypal.com/nvpfor express chekout. 

 

Below is the Httprequest code:

 

 public string HttpCall(string NvpRequest) //CallNvpServer
 {
 
string strPost = NvpRequest + "&" + buildCredentialsNVPString();
strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode(BNCode);
 
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
 
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Timeout = Timeout;
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
 
 using (Stream stm = objRequest.GetRequestStream())
 {
         using (StreamWriter sw = new StreamWriter(stm))
         {
                sw.Write(strPost);
         }
 }

}

 
The strPost value in the above code is -
 
METHOD=SetExpressCheckout
&RETURNURL=http%3a%2f%2flocalhost%3a11002%2fsuccess.aspx
&CANCELURL=http%3a%2f%2flocalhost%3a11002%2fcancel.aspx
&L_PAYMENTREQUEST_0_NAME0=TestItem
&L_PAYMENTREQUEST_0_DESC0=Description+of+item
&L_PAYMENTREQUEST_0_AMT0=2.99
&L_PAYMENTREQUEST_0_QTY0=3
&PAYMENTREQUEST_0_AMT=8.97
&PAYMENTREQUEST_0_ITEMAMT=8.97
&PAYMENTREQUEST_0_PAYMENTACTION=SALE
&PAYMENTREQUEST_0_CURRENCYCODE=GBP
&USER=<my sandbox API userName>
&PWD=<my sandbox API password>
&SIGNATURE=<my sandbox API signature>
&VERSION=84.0
&BUTTONSOURCE=PP-ECWizard
 
I get the exception at the line Stream stm = objRequest.GetRequestStream(), it throws the exception "Received an unexpected EOF or 0 bytes from the transport stream". 

I tried using  ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; before creating the request, but it did not resolve the issue. Settings objRequest.Credentials and objRequest.ProxyCredentials also didn't help.

 

Please help.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users