angular-stripe

WebJar for angular-stripe

License

License

MIT
Categories

Categories

Github Development Tools Version Controls Angular User Interface Web Frameworks Stripe Business Logic Libraries Financial
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-bendrucker-angular-stripe
Last Version

Last Version

5.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

angular-stripe
WebJar for angular-stripe
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/bendrucker/angular-stripe

Download github-com-bendrucker-angular-stripe

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-bendrucker-angular-stripe/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-bendrucker-angular-stripe</artifactId>
    <version>5.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-bendrucker-angular-stripe/
implementation 'org.webjars.npm:github-com-bendrucker-angular-stripe:5.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-bendrucker-angular-stripe/
implementation ("org.webjars.npm:github-com-bendrucker-angular-stripe:5.0.0")
'org.webjars.npm:github-com-bendrucker-angular-stripe:jar:5.0.0'
<dependency org="org.webjars.npm" name="github-com-bendrucker-angular-stripe" rev="5.0.0">
  <artifact name="github-com-bendrucker-angular-stripe" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-bendrucker-angular-stripe', version='5.0.0')
)
libraryDependencies += "org.webjars.npm" % "github-com-bendrucker-angular-stripe" % "5.0.0"
[org.webjars.npm/github-com-bendrucker-angular-stripe "5.0.0"]

Dependencies

compile (9)

Group / Artifact Type Version
org.webjars.npm : dot-prop jar [3.0.0,3.1)
org.webjars.npm : ap jar [0.2.0,0.3)
org.webjars.npm » stripe-as-promised jar [2.1.0,2.2)
org.webjars.npm » lazy-async jar [1.0.1,1.1)
org.webjars.npm » angular-assert-q-constructor jar [1.0.1,1.1)
org.webjars.npm » load-script-global jar [1.0.2,1.1)
org.webjars.npm : pify jar [2.3.0,2.4)
org.webjars.npm » angular-q-promisify jar [3.0.0,3.1)
org.webjars.npm » stripe-errback jar [1.0.2,1.1)

Project Modules

There are no modules declared in this project.

angular-stripe Build Status

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 convenience
angular.module('myApp', [
  require('angular-stripe')
])

// otherwise, include the code first then the module name
angular.module('myApp', [
  'angular-stripe'
])

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
  .module('myApp', [
    'angular-stripe'
  ])
  .config(function (stripeProvider) {
    stripeProvider.setPublishableKey('my_key')
  })

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.controller('PaymentController', function ($scope, $http, stripe) {
  $scope.charge = function charge () {
    return stripe.card.createToken($scope.payment.card)
      .then(function (response) {
        console.log('token created for card ending in ', response.card.last4)
        var payment = angular.copy($scope.payment)
        payment.card = undefined
        payment.token = response.id
        return $http.post('https://yourserver.com/payments', payment)
      })
      .then(function (payment) {
        console.log('successfully submitted payment for $', payment.amount)
      })
      .catch(function (err) {
        if (err.type && /^Stripe/.test(err.type)) {
          console.log('Stripe error: ', err.message)
        }
        else {
          console.log('Other error occurred, possibly with your API', err.message)
        }
      })
  }
})

Versions

Version
5.0.0