Stripe payements in server code

Hello, I am migrating from Parse. I have set up server code with my app. I want to use Stripe API from within server code, but I am having trouble. I have included the Stripe libraries into the server code module. When I call a Stripe function, I receive a Backendless Fault error, this like example:

When I try:

Stripe.apiKey = "API_KEY";

I receive this error:

I/System.out: BackendlessFault{ code: '0', message: 'com/stripe/Stripe' }

What I get from this is that Backendless doesn’t like me trying to use Stripe’s functions. How can I get Stripe API to work with server code? It is very important to my project.

Turns out I wasn’t properly adding the Stripe Libraries to coderunner Libs folder. However now when I try to create customer instead of giving me the above error, an Exception is called as follows:

java.security.AccessControlException: access denied 
("java.util.PropertyPermission" "com.stripe.net.customURLStreamHandler" 
"read")

Can backendless support outbound network calls?

Hi Theo,

A couple of things to check for:

  • has stripe’s host name been added as approved host?
  • code runner does not allow creation of new threads, is it possible that their library (perhaps customURLStreamHandler) does that?

Regards,
Mark

Hello, thanks for responding. I have added ‘api.stripe.com’ to my list of external hosts, and when I added it said “APPROVED” right away. However I am not sure if this is the correct URL to use since I had to sort of play around with it to get it to work. On the Stripe API reference, it shows ‘https://api.stripe.com’, but when I tried to put that into the External Host URL here it said “Wrong host name”, so I took out the ‘https://’ and it went through.

Also I am not sure if their library creates a new thread or not. I talked to Stripe support and was told that it isn’t a problem on their end, but likely with how Backendless runs their code in a ‘sandbox’… what are your thoughts on that?

Theo,

I dug deeper into it. The problem occurs when Stripe’s library makes the following call:
System.getProperty(“com.stripe.net.customURLStreamHandler”, null);

It looks like CodeRunner’s sandbox policy does not allow System.getProperty calls. I am not sure why. I need to find out more about it from our dev team and will update you once I have the answer.

Regards,
Mark

Thank you

Mark, any word? Don’t mean to rush, just wondering if Stripe is something that I can get working with your system. If not I would like to know if there is any credit card processing API that does work with Backendless.

Hi Theo,

The upcoming release will contain the changes to allow the failing call. We anticipate the release to be out this week.

Regards,
Mark

The recent release did it for me. New customer is created and retrieved as desired. Thank you Mark!

Glad it is working for you. It is not just me, all of the team here is responsible for making little things like this happen.