jcberquist / stripe-cfml

stripe-cfml is a CFML (Lucee and ColdFusion) library for interacting with the Stripe API.
MIT License
66 stars 31 forks source link

JSON parsing failure at character 1:'C' in Connection Failure #2

Closed ef1972 closed 9 years ago

ef1972 commented 9 years ago

I get the following error JSON parsing failure at character 1:'C' in Connection Failure when running the sample codel.

jcberquist commented 9 years ago

So this error happens because stripe.cfc is not getting an answer from the stripe api, it is actually failing to connect to it and so the http response body is "Connection Failure" which is not valid JSON, obviously. I should definitely look into handling an error like this better, and not try to parse the response if it is not JSON.

But as to the error itself, you can check out the following link: https://groups.google.com/a/lists.stripe.com/forum/#!msg/api-discuss/HXtnBXV_0Go/w4W899kkF9YJ and following out the link given there: http://www.raymondcamden.com/2011/01/12/Diagnosing-a-CFHTTP-issue-peer-not-authenticated http://www.mischefamily.com/nathan/index.cfm/2010/4/16/OpenID-And-ColdFusion

ef1972 commented 9 years ago

Do I need to use ssl in my test environment to get stripe.cfc to work?

On Tue, Mar 3, 2015 at 4:09 PM, jcberquist notifications@github.com wrote:

So this error happens because stripe.cfc is not getting an answer from the stripe api, it is actually failing to connect to it and so the http response body is "Connection Failure" which is not valid JSON, obviously. I should definitely look into handling an error like this better, and not try to parse the response if it is not JSON.

But as to the error itself, you can check out the following link:

https://groups.google.com/a/lists.stripe.com/forum/#!msg/api-discuss/HXtnBXV_0Go/w4W899kkF9YJ and following out the link given there:

http://www.raymondcamden.com/2011/01/12/Diagnosing-a-CFHTTP-issue-peer-not-authenticated

http://www.mischefamily.com/nathan/index.cfm/2010/4/16/OpenID-And-ColdFusion

— Reply to this email directly or view it on GitHub https://github.com/jcberquist/stripecfc/issues/2#issuecomment-77035042.

jcberquist commented 9 years ago

The stripe api is only accessible via an ssl connection

ef1972 commented 9 years ago

even in test mode?

On Tue, Mar 3, 2015 at 4:15 PM, jcberquist notifications@github.com wrote:

The stripe api is only accessible via an ssl connection

— Reply to this email directly or view it on GitHub https://github.com/jcberquist/stripecfc/issues/2#issuecomment-77035958.

ef1972 commented 9 years ago

The stripe documentation says you can test without ssl

https://stripe.com/help/ssl

On Tue, Mar 3, 2015 at 4:17 PM, Erik Fenkell efenkell@gmail.com wrote:

even in test mode?

On Tue, Mar 3, 2015 at 4:15 PM, jcberquist notifications@github.com wrote:

The stripe api is only accessible via an ssl connection

— Reply to this email directly or view it on GitHub https://github.com/jcberquist/stripecfc/issues/2#issuecomment-77035958.

jcberquist commented 9 years ago

I would try something like the following code when using stripe.cfc in a request to verify if this is the issue:

objSecurity = createObject("java", "java.security.Security");
objSecurity.removeProvider("JsafeJCE");
stripe = new path.to.stripe( "STRIPE_TESTING_KEY" );
card =  { number = "4242424242424242", exp_month = 5, exp_year = 2016 };
charge = stripe.createCharge( amount = 2000, card = card );
writeDump( charge );

If that works, then the issue is the one discussed in the above links.

I don't think the docs are referring to connecting to their api, which is only accessible via HTTPS but rather to your own site from which you are connecting to their api.

ef1972 commented 9 years ago

Seems to work. I am able to dump the object and the transaction shows up in my stripe dashboard. Thanks.

On Tue, Mar 3, 2015 at 4:26 PM, jcberquist notifications@github.com wrote:

I would try something like the following code when using stripe.cfc in a request to verify if this is the issue:

objSecurity = createObject("java", "java.security.Security"); objSecurity.removeProvider("JsafeJCE"); stripe = new path.to.stripe( "STRIPE_TESTING_KEY" ); card = { number = "4242424242424242", exp_month = 5, exp_year = 2016 }; charge = stripe.createCharge( amount = 2000, card = card ); writeDump( charge );

If that works, then the issue is the one discussed in the above links.

I don't think the docs are referring to connecting to their api, which is only accessible via HTTPS but rather to your own site from which you are connecting to their api.

— Reply to this email directly or view it on GitHub https://github.com/jcberquist/stripecfc/issues/2#issuecomment-77038235.

jcberquist commented 9 years ago

Glad it is working. I would like to point out two things: Those links specify that this is only an issue on CF9 Enterprise and Developer (not CF9 standard) so if your production machine is running CF9 standard you wouldn't need to remove the JsafeJCE provider on it. Also you shouldn't need to remove the provider over and over on each request, the comment where I got that code from specified that they ran it only in their onApplicationStart() method.