Angular provider for easy interaction with Stripe.js. angular-stripe wraps Stripe.js's async operations in $q
promises, making response handling easier and eliminating $scope.$apply
calls and other repetitive boilerplate in your application. Check out angular-credit-cards for validating your credit card forms.
Installing
npm install --save angular-stripe
Usage
angular-stripe will load Stripe.js when it's first called. You don't need to directly include Stripe.js via a <script>
tag.
// node module exports the string 'angular-stripe' for convenienceangular // otherwise, include the code first then the module nameangular
API
stripeProvider
angular-stripe exposes stripeProvider
for configuring Stripe.js.
stripeProvider.url
The URL that will be used to fetch the Stripe.js library.
stripeProvider.setPublishableKey(key)
-> undefined
Sets your Stripe publishable key.
angular
stripe
Inject stripe
into your services or controllers to access the API methods. createToken
returns a $q
promise. If Stripe responds with an error, the promise will be rejected.
stripe.setPublishableKey(key)
-> undefined
Same as stripeProvider.setPublishableKey
stripe.card
stripe.card.createToken(card [, params])
-> promise
Tokenizes a card using Stripe.card.createToken
. You can optionally pass a key
property under params
to use a different publishable key than the default to create that token. This is especially useful for applications using Stripe Connect.
The following utility methods are also exposed:
stripe.bankAccount
stripe.bankAccount.createToken(bankAccount [, params])
-> promise
Tokenizes a card using Stripe.bankAccount.createToken
.
The following utility methods are also exposed:
stripe.bitcoinReceiver
stripe.bitcoinReceiver.createReceiver
-> promise
Creates a bitcoin receiver using Stripe.bitcoinReceiver.createReceiver
.
stripe.bitcoinReceiver.pollReceiver
-> promise
Polls a bitcoin receiver using Stripe.bitcoinReceiver.pollReceiver
. Note that you'll need to implement additional logic if you need to cancel receivers.
The following utility methods are also exposed:
Examples
Charging a card
app