Angular Payment

Stripe's jquery.payment library converted to pure AngularJS

Dependencies

This repository contains a set of native AngularJS directives based on Stripe's jquery.payment library. As a result no dependencies (jQuery or the existing library) are required. The only required dependency is:

  • AngularJS (minimal version 1.0.4 or 1.1.2)

Files to download

Build files for all directives are distributed in several flavours: minified for production usage, un-minified for development, with or without templates. All the options are described and can be downloaded from here.

The good news is that the overall size of a download is very small: <9kB for all directives (~3kB with gzip compression!)

Installation

As soon as you've got all the files downloaded and included in your page you just need to declare a dependency on the payment module:
angular.module('myModule', ['payment']);

Restrict numeric directive that will restrict keyboard input to numbers only.


Valid: {{!cardCvcForm.$invalid}}

Formats card CVC: restricts length to 4 numbers, restricts input to numbers

Validates a card CVC: validates number, validates length to 4


Expiry: {{cardExpiry || 'undefined'}} - Valid: {{!cardExpiryForm.$invalid}}

Formats card expiry: includes a / between the month and year, restricts input to numbers, restricts length

Validates a card expiry: validates numbers, validates in the future, supports year shorthand


Card Type: {{cardType || 'unknown'}} - Valid: {{!cardForm.$invalid}}

Formats card numbers: including a space between every 4 digits, restricts input to numbers, limits to 16 numbers, American Express formatting support

Validates card numbers: numbers, Luhn algorithm and length

It also provides an optional attribute cardType representing the card type if it can be ascertained from the input value