0.0.5 • Published 7 years ago

redux-payment-form v0.0.5

Weekly downloads
14
License
MIT
Repository
github
Last release
7 years ago

redux-payment-form

React Redux payment form with advanced credit card and security code detection/validation (based on redux-form library)

Features

  • Supports the most of credit/debit cards used today (Visa, Mastercard, American Express, Discover and so on)
  • Credit/Debit card detection.
  • Security code (CVV, CDI and so on) detection based on credit card number.
  • Instant validation of the above-mentioned fields

Installation:

  1. npm install redux-form redux-payment-form --save
  2. Optional: Import Bootstrap CSS if you want the form to be formatted nicely (it was not included in the library to give users more flexibility to style the form)

Usage

import React, {Component} from 'react';
import PaymentForm from 'redux-payment-form';

class ExampleComp extends Component {

  onCardChange(paymentForm) {
    console.log("payment form updated:", paymentForm)
    /*
    payment form updated: {
       "card":{  
          "cardNumber":"342987115456829",
          "nameOnCard":"user name",
          "expiryMonth":"1",
          "expiryYear":"14",
          "securityCode":"1234"
       },
       "valid":true
    }
    */
  }

  render() {
    return (
      <div>
        <PaymentForm
          onCardChange={this.onCardChange}
          acceptedCards={['visa', 'american-express']}
        />
      </div>
    );
  }
}

export default ExampleComp;

Props

Credit/debit card detection

alt text alt text

Validation

alt text

Demo

You can see demo here: https://shotak.github.io/redux-payment-form/