0.0.17 • Published 7 years ago
@igorlima-draft/react-credit-card-input v0.0.17
React Credit Card Input
A credit/debit card input field for React
Example
Click here for an interactive demo

Install
$ npm install --save react-credit-card-input styled-componentsUsage
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
Error handling
<CreditCardInput
onError={({ inputName, err }) => console.log(`credit card input error: ${err}`)}
cardCVCInputProps={{
onBlur: e => console.log('cvc blur', e),
onChange: e => console.log('cvc change', e),
onError: err => console.log(`cvc error: ${err}`)
}}
cardExpiryInputProps={{
onBlur: e => console.log('expiry blur', e),
onChange: e => console.log('expiry change', e),
onError: err => console.log(`expiry error: ${err}`)
}}
cardNumberInputProps={{
onBlur: e => console.log('number blur', e),
onChange: e => console.log('number change', e),
onError: err => console.log(`number error: ${err}`)
}}
/>
/>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)
)}
/>
)}
/>Custom text labels usage
<CreditCardInput
customTextLabels={{
invalidCardNumber: 'El número de la tarjeta es inválido',
expiryError: {
invalidExpiryDate: 'La fecha de expiración es inválida',
monthOutOfRange: 'El mes de expiración debe estar entre 01 y 12',
yearOutOfRange: 'El año de expiración no puede estar en el pasado',
dateOutOfRange: 'La fecha de expiración no puede estar en el pasado'
},
invalidCvc: 'El código de seguridad es inválido',
invalidZipCode: 'El código postal es inválido',
cardNumberPlaceholder: 'Número de tarjeta',
expiryPlaceholder: 'MM/AA',
cvcPlaceholder: 'COD',
zipPlaceholder: 'C.P.'
}}
/>Contributing
Contributing to react-credit-card-input is easy! With four simple steps:
Create a branch
- Fork the repository
git clone <your-repo-url>to clone your GitHub repo to your local onegit pull origin masterto pull the latest codenpm installto install the project's dependenciesgit checkout -b the-name-of-my-branchto create a branch (use something short and comprehensible, such as:fix-card-number-issue).git remote add upstream https://github.com/medipass/react-credit-card-input.gitandgit pull upstream masterto 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
- Run
npm run fixfrom the project root (This will run Prettier and ESLint and automatically fix any issues).
Push the change!
git add -A && git commit -m "My message (#issue-number/pr-number)"(replacingMy message (#issue-number/pr-number)with a commit message, such asFixed card number issue (#43)) to stage and commit your changesgit push my-fork-name the-name-of-my-branch
License
MIT © Medipass Solutions
0.0.17
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.0-separation-of-duties.7
7 years ago
0.0.0-separation-of-duties.6
7 years ago
0.0.0-separation-of-duties.5
7 years ago
0.0.0-separation-of-duties.4
7 years ago
0.0.0-separation-of-duties.3
7 years ago
0.0.0-separation-of-duties.2
7 years ago
0.0.0-separation-of-duties.1
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago