1.0.0 • Published 6 years ago

rc-credit-card-input v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

React Credit Card Input

A credit/debit card input field for React

Example

Click here for an interactive demo

npm.io

Install

$ npm install --save react-credit-card-input

Usage

import CreditCardInput from 'react-credit-card-input';

<CreditCardInput
  cardNumberInputProps={{ value: cardNumber, onChange: this.handleCardNumberChange }}
  cardExpiryInputProps={{ value: expiry, onChange: this.handleCardExpiryChange }}
  cardCVCInputProps={{ value: cvc, onChange: this.handleCardCVCChange }}
  fieldClassName="input"
/>

Available props

Input renderer props

Custom input renderer usage

<CreditCardInput
  cardCVCInputRenderer={({ handleCardCVCChange, props }) => (
    <input
      {...props}
      onChange={handleCardCVCChange(e => console.log('cvc change', e))}
    />
  )}
  cardExpiryInputRenderer={({ handleCardExpiryChange, props }) => (
    <input
      {...props}
      onChange={handleCardExpiryChange(e =>
        console.log('expiry change', e)
      )}
    />
  )}
  cardNumberInputRenderer={({ handleCardNumberChange, props }) => (
    <input
      {...props}
      onChange={handleCardNumberChange(e =>
        console.log('number change', e)
      )}
    />
  )}
/>

Contributing

Contributing to react-credit-card-input is easy! With four simple steps:

Create a branch

  1. Fork the repository
  2. git clone <your-repo-url> to clone your GitHub repo to your local one
  3. git pull origin master to pull the latest code
  4. npm install to install the project's dependencies
  5. git checkout -b the-name-of-my-branch to create a branch (use something short and comprehensible, such as: fix-card-number-issue).
  6. git remote add upstream https://github.com/medipass/react-credit-card-input.git and git pull upstream master to update your fork from this source.

Make the change

Note: You can run npm run storybook, and then navigate to http://localhost:9001/ to interactively develop your changes. If you are developing a new feature, make sure to add a story for it!

Test the change

  1. Run npm run fix from the project root (This will run Prettier and ESLint and automatically fix any issues).

Push the change!

  1. git add -A && git commit -m "My message (#issue-number/pr-number)" (replacing My message (#issue-number/pr-number) with a commit message, such as Fixed card number issue (#43)) to stage and commit your changes
  2. git push my-fork-name the-name-of-my-branch

License

MIT © Medipass Solutions