bendrucker / angularjs-stripe

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

No connection callback #48

Closed OxMarco closed 8 years ago

OxMarco commented 8 years ago

Hello, it looks like the module needs a callback in case there is no connection (and Stripe API is consequently unavailable), otherwise the whole angular app crashes in a WSOD with the following error:

Error: [$injector:modulerr] Failed to instantiate module washery due to: [$injector:modulerr] Failed to instantiate module angular-stripe due to: Stripe must be available as window.Stripe

Thanks

bendrucker commented 8 years ago

Hi there,

I've chosen to keep this module simple and almost entirely source code free by expecting Stripe at boot time. If you want to do something more involved, including handling script loading errors, I'd recommend handling the script loading yourself and building your own provider/service to replace angular-stripe. You can pass Stripe and $q to the stripe-as-promised to get the promise interface. For script loading you can grab load-script-global.