Page 1 of 2

Server Code Error SCSX014

Posted: Mon Jun 30, 2014 7:39 pm
by Bad Addy

Here is the code I have used:

precode
var info = '"headers": [{"Authorization": "'+newauth+'", "Content-Type" : "application/json"}], "parameters": [{"payer_id": "'+pid+'"}]';

console.log(info);

execute = XHR.send('POST', 'https://api.sandbox.paypal.com/v1/payments/payment/' + ppid[0].paymentid + '/execute', info );/code/pre

And this is the trace:

pre
Script urv_paypalPayments: Error: {"message":"Invalid object: 'headers': [{'Authorization': 'Bearer A015Oy84mklsdrdcwRC07MpRcbuEZoLWY7tl4d7BmNj1G5Q', 'Content-Type' : 'application/json'}], 'parameters': [{'payer_id': 'BH7ZNU3NU7Z6W'}]","code":"SCXH218"} ( @ 8 : 45 ) - var innerResult = GlobalXHRInner.send(method, url, GlobalJSON.stri
/pre

It says its a invalid object, but I copied it from Paypal and json validated it ?


Server Code Error SCSX014

Posted: Mon Jun 30, 2014 10:46 pm
by Yurii Orishchuk

Hi Addy.

You have wrong "info" JS object.

Please use following code:

pre

var info = {
"headers": {"Authorization": newauth, "Content-Type" : "application/json"},

Code: Select all

 "parameters": {"payer_id": pid} 

};

console.log(info);

execute = XHR.send('POST', 'https://api.sandbox.paypal.com/v1/payments/payment/' + ppid[0].paymentid + '/execute', info );

/pre

Regards.


Server Code Error SCSX014

Posted: Tue Jul 01, 2014 8:43 am
by Bad Addy

Thank you for that. I have now removed that error, but now i get a 401 error, here is the full error:

pre
{"body":"","headers":{"Content-Type":"application/json","Content-Length":"0","Date":"Tue, 01 Jul 2014 08:29:10 GMT","PROXY_SERVER_INFO":"host=slcsbjava3.slc.paypal.com;threadId=152362","Paypal-Debug-Id":"2662ffba91e72","Server":"Apache-Coyote/1.1"},"status":401}
/pre

I get no server code error and using console log, i can see all the variables are in in place, but the 401 is associated with the auth code ?

This is what is sent via the code:

prePOST https://api.sandbox.paypal.com/v1/payments/payment/PAY-9WR64408R3638134MKOYYRVY/execute { headers: { Authorization: 'Bearer A*y84mklsdrdcwpRcbuEZoLtl4d7BmNj1G5Q', 'Content-Type': 'application/json' }, parameters: { payer_id: 'BH7ZN***7Z6W' } }/pre

Seems okay to me ?


Server Code Error SCSX014

Posted: Tue Jul 01, 2014 3:56 pm
by Bad Addy

Any ideas ?


Server Code Error SCSX014

Posted: Tue Jul 01, 2014 8:43 pm
by Kateryna Grynko

Hi Addy,

How and when did you get an Authorization value? It could be outdated at the time of sending the request...


Server Code Error SCSX014

Posted: Tue Jul 01, 2014 8:50 pm
by Bad Addy

It gets it about 15 - 30 seconds before


Server Code Error SCSX014

Posted: Tue Jul 01, 2014 11:51 pm
by Yurii Orishchuk

Hi Addy.

In accordance with this document https://developer.paypal.com/docs/int...

you should send json parameters in request body.

So please try this code:

pre

var body = {"payer_id": pid};

var info = {
"headers": {"Authorization": newauth, "Content-Type" : "application/json"},
"body": JSON.stringify(body)
};
console.log(info);
execute = XHR.send('POST', 'https://api.sandbox.paypal.com/v1/payments/payment/' + ppid[0].paymentid + '/execute', info );

/pre

Regards.


Server Code Error SCSX014

Posted: Wed Jul 02, 2014 12:32 pm
by Bad Addy

Seems the server code takes too long and times out now... its like a never ending issue to get Paypal working... :(


Server Code Error SCSX014

Posted: Wed Jul 02, 2014 12:55 pm
by Bad Addy

Looking at it, the script only runs for 400ms, and my plan has 2s, which is 2000ms, so why is it running out of time ?


Server Code Error SCSX014

Posted: Wed Jul 02, 2014 11:31 pm
by Alena Prykhodko

Hello,

Sorry for delay, please share your script with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a, tell us its name and how should we correctly call it.