npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-stripe-release

v4.2.12

Published

Angular service provider for interacting with Stripe

Downloads

6

Readme

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. angular-stripe is powered by stripe-as-promised.

Installing

$ npm install --save angular-stripe

Usage

angular-stripe expects Stripe.js to be available as window.Stripe when it loads.

// 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.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 () {
    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 = void 0;
        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);
        }
      });
  };
});