jQuery.Payment – A Library For Building Credit Card Forms

jQuery.Payment – A Library For Building Credit Card Forms


SHARE & COMMENT

Stripe, one of the leading API-for-payments startup who in May of this year was in talks for new founding at a $5 billion valuation keeps their efforts to collaborate to the open source community. This time, we are introducing jQuery.payments, a general purpose library for building credit card forms, validating input, and formatting numbers. This library is behind a lot of the functionality in Stripe’s checkout page.

The small plugin was introduced to the community in early 2013, but the success of this library kept the community and the folks at Stripe motivated to keep this library up to date and in continuously development.

jQuery.payments provides an API of functions that are straightforward to use and can be used for any type of card form, whether it be Stripe, Braintree, Paymill, or just about anything else.

Features

  • Formatting:
    • $.fn.payment(‘formatCardNumber’) – Formats credit cards numbers
    • $.fn.payment(‘formatCardExpiry’) – Formats credit card expiry
    • $.fn.payment(‘formatCardCVC’) – Formats credit card CVC
  • Restriction:
    • $.fn.payment(‘restrictNumeric’) – General numeric input restriction
  • Validation:
    • $.payment.validateCardNumber(number) – Validates a credit card number
    • $.payment.validateCardExpiry(month, year) – Validates a credit card expiry
    • $.payment.validateCardCVC(cvc, type) – Validates a credit card CVC
    • $.payment.cardType(number) – Returns a credit card type
  • Parsing:
    • $.fn.payment(‘cardExpiryVal’) – Parses a credit card expiry in the form of MM/YYYY, returning an object containing the month and year

Bonus

If you are planning on adding some kind of payment functionality on your website and need to test credit card inputs, you can visit GetCreditCardNumbers.com and get unlimited valid credit card numbers for testing purposes.

 

View on GitHub   Demo

SHARE & COMMENT