You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by jude <fl...@gmail.com> on 2016/04/01 19:06:04 UTC

Re: PayPal integration - Error #2096

I ran into something like this before a few times. I don't remember the
exact issue but you might want to use url variables instead of object for
params. You also may need to set the content type. I'll try and look it up
when I'm not on mobile. Post this on stack overflow and I'll help over
there.
On Mar 25, 2016 8:46 AM, "leokan23" <le...@best-web.gr> wrote:

> So i am trying to integrate PayPal in my Flex Mobile app. I make my first
> call like this:
>
> (keys are sandbox by paypal dev resources)
>
> protected function getPaypal():void {
>   var client_id:String="EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp";
>   var secret:String="EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp";
>
>   var params:Object = new Object();
>   params.grant_type="client_credentials";
>
>   var encoder:Base64Encoder = new Base64Encoder();
>   encoder.encode(client_id + ":" + secret);
>
>   //var s:String = JSON.stringify(params);
>   paypal.contentType = "application/x-www-form-urlencoded";
>   paypal.headers["Authorization"] = "Basic " + encoder.toString();
>   paypal.method = "POST";
>   paypal.url = "https://api.sandbox.paypal.com/v1/oauth2/token";
>   paypal.send(params);
>   }
>
> This fails and returns the following:
> 'Error #2096: The HTTP request header Basic
>
> RU9KMlMtWjZPb05fbGVfS1MxZDc1d3NaNnkwU0ZkVnNZOTE4M0l2eEZ5WnA6RUNsdXNNRVVrOGU5
> aWhJN1pkVkxGNWNaNnkwU0ZkVnNZOTE4M0l2eEZ5WnA= cannot be set via
> ActionScript.' faultDetail:'null'
>
> I can't figure out what seems to be the problem.
>
> Any help?
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
Hi om,

they are just the paypals sandbox default (the ones provided in the API
Reference for the first call). They aren't the actually client_id and secret
i use. 

Thanks though :)



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12398.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by OmPrakash Muppirala <bi...@gmail.com>.
Next time, you might want to remove the client_id and secret strings when
posting on a public forum :-)

Thanks,
Om

On Fri, Apr 1, 2016 at 2:45 PM, leokan23 <le...@best-web.gr> wrote:

> Oh..OK,
>
> I thought that contentType should work as i have used it before (Implement
> a
> onesignal server).
>
> Again thanks for all the help :)
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12396.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
Oh..OK,

I thought that contentType should work as i have used it before (Implement a
onesignal server). 

Again thanks for all the help :)



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12396.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by Matthew Weir <ma...@yahoo.com.INVALID>.
Well....
If you want the easy answer, which I found about two minutes ago
//paypal.contentType = "application/x-www-form-urlencoded";   <-- this is the problem
paypal.headers["contentType"] = "application/x-www-form-urlencoded";
paypal.headers["Authorization"] = "Basic " + s;

 

    On Friday, April 1, 2016 5:11 PM, leokan23 <le...@best-web.gr> wrote:
 

 I tried it and this works perfectly. 

I have no idea why using httpservice instead didn't work. 

Thanks for all the help :)



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12394.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.


  

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
I tried it and this works perfectly. 

I have no idea why using httpservice instead didn't work. 

Thanks for all the help :)



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12394.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by psychobob <ma...@yahoo.com>.
Trying to format better

var encoder:Base64Encoder = new Base64Encoder();
	encoder.insertNewLines = false;
	encoder.encode(client_id + ":" + secret);

var s:String = encoder.toString();

var paramss:URLVariables = new URLVariables();
	paramss.grant_type='client_credentials'

var headers:Array = [
	new URLRequestHeader("contentType", "application/x-www-form-urlencoded"),
	new URLRequestHeader("Accept-Language", "en_US"),
	new URLRequestHeader("Authorization", "Basic " + s)
];

var urlReq:URLRequest = new
URLRequest('https://api.sandbox.paypal.com/v1/oauth2/token')
	urlReq.method = URLRequestMethod.POST;
	urlReq.data = paramss;
	urlReq.requestHeaders = headers;

var urlLoader:URLLoader = new URLLoader(urlReq);
	urlLoader.addEventListener(Event.COMPLETE, onLoadCompleteAgain);
	urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
	urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,
onHTTPResponse);
	urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus);
	urlLoader.load(urlReq);



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12393.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by Matthew Weir <ma...@yahoo.com.INVALID>.
That was a fun one :)

This should work for you.
var encoder:Base64Encoder = new Base64Encoder(); encoder.insertNewLines = false; encoder.encode(client_id + ":" + secret);
var s:String = encoder.toString();
var paramss:URLVariables = new URLVariables(); paramss.grant_type='client_credentials'
var headers:Array = [ new URLRequestHeader("contentType", "application/x-www-form-urlencoded"), new URLRequestHeader("Accept-Language", "en_US"), new URLRequestHeader("Authorization", "Basic " + s)];
var urlReq:URLRequest = new URLRequest('https://api.sandbox.paypal.com/v1/oauth2/token') urlReq.method = URLRequestMethod.POST; urlReq.data = paramss; urlReq.requestHeaders = headers;
var urlLoader:URLLoader = new URLLoader(urlReq); urlLoader.addEventListener(Event.COMPLETE, onLoadCompleteAgain); urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError); urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, onHTTPResponse); urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus); urlLoader.load(urlReq); 

    On Friday, April 1, 2016 3:16 PM, OmPrakash Muppirala <bi...@gmail.com> wrote:
 

 Looks like it is a well documented issue:
http://blogs.adobe.com/koestler/2010/12/dealing-with-argumenterrors-while-pushing-urlrequestheaders.html

Have you tried to do a search and replace for new line on the encoder
string?

Thanks,
Om

On Fri, Apr 1, 2016 at 11:41 AM, leokan23 <le...@best-web.gr> wrote:

> Hi Matthew,
>
> thanks for the notice :) i have been looking at this for a while. The app
> will be used to buy physical goods which will be shipped to the users
> address and this is why i am looking at PayPal.
>
> Thanks for the info though.
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12390.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>


   

Re: PayPal integration - Error #2096

Posted by OmPrakash Muppirala <bi...@gmail.com>.
Looks like it is a well documented issue:
http://blogs.adobe.com/koestler/2010/12/dealing-with-argumenterrors-while-pushing-urlrequestheaders.html

Have you tried to do a search and replace for new line on the encoder
string?

Thanks,
Om

On Fri, Apr 1, 2016 at 11:41 AM, leokan23 <le...@best-web.gr> wrote:

> Hi Matthew,
>
> thanks for the notice :) i have been looking at this for a while. The app
> will be used to buy physical goods which will be shipped to the users
> address and this is why i am looking at PayPal.
>
> Thanks for the info though.
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12390.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
Hi Matthew,

thanks for the notice :) i have been looking at this for a while. The app
will be used to buy physical goods which will be shipped to the users
address and this is why i am looking at PayPal.

Thanks for the info though.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12390.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by Matthew Weir <ma...@yahoo.com.INVALID>.
You mentioned it was mobile.  If you're using android you may want to consider the following before pursuing this error too much further
   
   - Developers offering products within another category of app downloaded on Google Play must use Google Play In-app Billing as the method of payment, except for the following cases:
   
   - Payment is solely for physical products
   - Payment is for digital content that may be consumed outside of the app itself (e.g. songs that can be played on other music players).

https://play.google.com/about/monetization.html



Unless, of course, I misunderstand their TOS
Matthew 

    On Friday, April 1, 2016 2:21 PM, leokan23 <le...@best-web.gr> wrote:
 

 i have already tried this, but when i use it, the PayPal service doesn't go
through. It just fails.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12388.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.


  

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
i have already tried this, but when i use it, the PayPal service doesn't go
through. It just fails.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12388.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: PayPal integration - Error #2096

Posted by Clint M <cm...@gmail.com>.
Maybe this:
http://stackoverflow.com/a/539173/3384609

Gist:
You can fix this by setting (in the above example) encoder.insertNewLines =
false; The default setting is true.

On Fri, Apr 1, 2016 at 10:28 AM, leokan23 <le...@best-web.gr> wrote:

> Thanks Jude,
>
> i have added the question to stackoverflow too
>
> paypal-integration-error-2096-in-flex-mobile
> <
> http://stackoverflow.com/questions/36362824/paypal-integration-error-2096-in-flex-mobile
> >
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12386.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: PayPal integration - Error #2096

Posted by leokan23 <le...@best-web.gr>.
Thanks Jude,

i have added the question to stackoverflow too

paypal-integration-error-2096-in-flex-mobile
<http://stackoverflow.com/questions/36362824/paypal-integration-error-2096-in-flex-mobile>  



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PayPal-integration-Error-2096-tp12359p12386.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.