bendrucker / angularjs-stripe

Angular Stripe.js service that returns promises for token calls
MIT License
333 stars 72 forks source link

Causes app to break if Stripe not loaded #37

Closed PaddyMann closed 8 years ago

PaddyMann commented 8 years ago

This module won't instantiate if Stripe's JS isn't loaded, which causes the entire app to break.

While Stripe's uptime is > 99% (https://status.stripe.com/), we can't have our app going down if Stripe is down :)

Ideally, I'd like this module to load stripe.js for me when I want it, and then handle the error if it can't.

I'm on a deadline so will probably hand-crank our solution, but v interested if there are workarounds with the current module :)

bendrucker commented 8 years ago

handle the error if it can't

How? Swallowing errors (or printing to the console or any other option) is even worse for a lot of people.

Since this package is basically just boilerplate and a call to stripe-as-promised, I've generally said no to "advanced" features or anything else that serves a minority of users.

PaddyMann commented 8 years ago

By 'handle the error', I mean that it shouldn't kill the entire app, and could perhaps expose a 'errorLoadingStripe' variable similar.

To replicate what I'm talking about, take out the stripe.js <script> tag in one of your pages and see what happens. The same would happen if the Stripe site goes down.

Not too worried if you fix it as I've now handcranked, but thought I should raise the issue :)

bendrucker commented 8 years ago

Yup, I totally know what you mean, but would prefer to stick to more aggressive behavior for now to keep things simple.

Check out the code—you can get the promisification bits from stripe-as-promised with almost no effort. You can go as deep as you want (lazy loading, error handling, etc.) while still retaining the same interface.

PaddyMann commented 8 years ago

In that case, you should really add a warning to the front page:

Warning: This component is not production ready. If you use this component and the Stripe JS file fails to load for any reason at all, your app will no longer work.

(though honestly, I think it's a huge bug to simply close in the name of the keeping things simple!)