Jump to content


Photo

Problems With Express Checkout

express checkout java timeout

Best Answer maxpp , 27 November 2014 - 12:22 AM

Well, it seems that paypal doesn't like the url in the way I wrote it, so I've changed the HttpURLConnection for org.apache.http.client.methods.HttpPost, so this is my code (working):

HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(SANBOX_URL);
post.setHeader("User-Agent", "Mozilla/5.0"); 
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair(USER, "SANDBOX_USER"));
urlParameters.add(new BasicNameValuePair(PASSWORD, "SANDBOX_PWD"));
urlParameters.add(new BasicNameValuePair(SIGNATURE, "SANDBOX_SIGNATURE"));
urlParameters.add(new BasicNameValuePair(VERSION, "VERSION"));
urlParameters.add(new BasicNameValuePair(ACTION, "ACTION"));
urlParameters.add(new BasicNameValuePair(AMOUNT, "AMOUNT"));
urlParameters.add(new BasicNameValuePair(RETURN_URL, "RETURN_URL"));
urlParameters.add(new BasicNameValuePair(CANCEL_URL, "CANCEL_URL"));
urlParameters.add(new BasicNameValuePair(METHOD, "METHOD"));

post.setEntity(new UrlEncodedFormEntity(urlParameters));

HttpResponse response = client.execute(post);
Another thing I had to change, was not encode the values of the parameters; once I did all of this changes, finally I've got "TOKEN=XXXX&TIMESTAMP=2014%2d11%2d27T00%3a08%3a29Z&CORRELATIONID=XXXX&ACK=Success&VERSION=119%2e0&BUILD=XXXX".

Hope it helps someone else

Go to the full post


  • Please log in to reply
1 reply to this topic

#1 maxpp

maxpp

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 25 November 2014 - 11:11 PM

Hi guys, this is my first time using the PayPal API, I'm trying to test the express checkout integration in a java web application, and I'm having problems in the first step. I'm calling the SetExpressCheckout operation and I get this error: "TIMESTAMP=2014%2d11%2d25T15%3a19%3a14Z&CORRELATIONID=523b6bcbe502f&ACK=Failure&L_ERRORCODE0=10001&L_SHORTMESSAGE0=Internal%20Error&L_LONGMESSAGE0=Timeout%20processing%20request"

 

As you can see in L_LONGMESSAGE0 the description is "Timeout processing request" and, I don't know if it's related, but the TIMESTAMP is 3 hours ahead (I'm in GMT-3, so when I sent the request it was 12:19:14 instead of 15:19:14). Besides this, I'm building my url according to PayPal's help, here is a sample (using the test user, password and signature provided for the sandbox account):

 

https :// api-3t.sandbox.paypal.com/nvp ? USER=sdk-three_api1.sdk.com & PWD=QFZCWN5HZM8VBG7Q & SIGNATURE=A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU & METHOD=SetExpressCheckout & VERSION=99.0 & RETURNURL=http%3A%2F%2Flocalhost%3A8080%2Fmysite%2Fsomepage & CANCELURL=http%3A%2F%2Flocalhost%3A8080%mysite%2Ferror & PAYMENTREQUEST_0_PAYMENTACTION=Sale & PAYMENTREQUEST_0_AMT=10.00

(sorry for the extra spaces, but without them the editor doesn't show the full url)

 

and this is the full code:

String sUrl = "https://api-3t.sandbox.paypal.com/nvp?USER=sdk-three_api1.sdk.com&...."; //the full URL shown above
URL obj = new URL(sUrl);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer sbResponse = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    sbResponse.append(inputLine);
}
in.close();

Does anybody knows what's going on here, or at least a tip so I can check it?

Thanks in advance, regards.



#2 maxpp

maxpp

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 27 November 2014 - 12:22 AM   Best Answer

Well, it seems that paypal doesn't like the url in the way I wrote it, so I've changed the HttpURLConnection for org.apache.http.client.methods.HttpPost, so this is my code (working):

HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(SANBOX_URL);
post.setHeader("User-Agent", "Mozilla/5.0"); 
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair(USER, "SANDBOX_USER"));
urlParameters.add(new BasicNameValuePair(PASSWORD, "SANDBOX_PWD"));
urlParameters.add(new BasicNameValuePair(SIGNATURE, "SANDBOX_SIGNATURE"));
urlParameters.add(new BasicNameValuePair(VERSION, "VERSION"));
urlParameters.add(new BasicNameValuePair(ACTION, "ACTION"));
urlParameters.add(new BasicNameValuePair(AMOUNT, "AMOUNT"));
urlParameters.add(new BasicNameValuePair(RETURN_URL, "RETURN_URL"));
urlParameters.add(new BasicNameValuePair(CANCEL_URL, "CANCEL_URL"));
urlParameters.add(new BasicNameValuePair(METHOD, "METHOD"));

post.setEntity(new UrlEncodedFormEntity(urlParameters));

HttpResponse response = client.execute(post);
Another thing I had to change, was not encode the values of the parameters; once I did all of this changes, finally I've got "TOKEN=XXXX&TIMESTAMP=2014%2d11%2d27T00%3a08%3a29Z&CORRELATIONID=XXXX&ACK=Success&VERSION=119%2e0&BUILD=XXXX".

Hope it helps someone else







Also tagged with one or more of these keywords: express checkout, java, timeout

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users