# react-native-credit-card-form

> React native credit card form component

Latest version **0.1.1** (published 2016-09-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-native-credit-card-form
pnpm add react-native-credit-card-form
yarn add react-native-credit-card-form
bun add react-native-credit-card-form
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-09-02 |
| First published | 2016-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1506 |
| Author | sbycrosz |
| Maintainers | sbycrosz |
| Keywords | react-native, credit-card, credit-card form, skeuomorphic credit-card, form, flip, card, component, react-component, react-native-component |

## Links

- npm: https://www.npmjs.com/package/react-native-credit-card-form
- Repository: https://github.com/sbycrosz/react-native-credit-card-form
- Homepage: https://github.com/sbycrosz/react-native-credit-card-form#readme
- Issues: https://github.com/sbycrosz/react-native-credit-card-form/issues
- npm.io page: https://npm.io/package/react-native-credit-card-form

## Dependencies (2)

- [card-validator](https://npm.io/package/card-validator.md) ^2.2.0
- [react-native-credit-card](https://npm.io/package/react-native-credit-card.md) github:sbycrosz/react-native-credit-card#disable-clickable

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2016-09-02
- 0.1.0 — 2016-09-02

## README

# React Native Credit Card Form
Easy (and good looking) credit-card form for your React Native Project 💳 💳

<img src="https://github.com/sbycrosz/react-native-credit-card-form/blob/master/ios.gif?raw=true" width=200/>
<img src="https://github.com/sbycrosz/react-native-credit-card-form/blob/master/android.gif?raw=true" width=200/>

## Features
* Skeuomorphic credit-card 💳 (credits to: [react-native-credit-card](https://github.com/sonnylazuardi/react-native-credit-card))
* Credit-card input validations while you're typing
* Credit-card input formatting
* Works on both Android and iOS


## Usage

```bash
npm i -s react-native-credit-card-form
```

then add these lines in your react-native codebase

```js
import CreditCardForm from 'react-native-credit-card-form';

<CreditCardForm onChange={this._onChange} />
```

## API

| Property | Type | Description |
| --- | --- | --- | --- |
|autoFocus | PropTypes.bool | Automatically focus Card Number field on render|
|onChange | PropTypes.func | Will receive a `formData` object every time the form changes |
|labels | PropTypes.object | Defaults to <br/>`{ number: "CARD NUMBER", expiry: "EXPIRY", cvc: "CVC/CCV" }` |
|placeholders | PropTypes.object | Defaults to <br/>`{ number: "1234 5678 1234 5678", expiry: "MM/YY", cvc: "CVC" }` |
|cardViewSize | PropTypes.object | Size of the credit-card view.<br/>Defaults to `{ width: 300, height: 180 }` (managed by [react-native-credit-card](https://github.com/sonnylazuardi/react-native-credit-card))  |
|imageFront | PropTypes.number | Image for the credit-card view `e.g. require("./card.png")` |
|imageBack | PropTypes.number | Image for the credit-card view `e.g. require("./card.png")` |
|labelStyle | Text.propTypes.style | Style for credit-card form's labels |
|inputStyle | Text.propTypes.style | Style for credit-card form's textInput |
|inputContainerStyle | View.propTypes.style | Style for textInput's container<br/> Defaults to: `{ borderBottomWidth: 1, borderBottomColor: "black" }` |
|validColor | PropTypes.string | Color that will be applied for valid text input |
|invalidColor | PropTypes.string | Color that will be applied for invalid text input |
|placeholderColor | PropTypes.string | Color that will be applied for text input placeholder |

### onChange
will receives a `formData` object every keypress. e.g.

```js
{
  valid: true, // will be true once all field's statuses are "valid"
  focused: "number", // will be one of "number", "expiry", and "cvc"
  values: { // will be in the sanitized and formatted form
  	number: "4242 4242",
  	expiry: "06/19",
  	cvc: "300",
  	type: "visa", // will be one of null, "visa", "master-card", "american-express", "diners-club", "discover", "jcb", "unionpay", "maestro"
  },
  status: {  // will be one of "incomplete", "invalid", and "valid"
	number: "incomplete",
	expiry: "incomplete"
	cvc: "incomplete"
  },
};
```



## Example

In the `example` directory, do:

```bash
npm install
react-native run-ios
# or
react-native run-android
```

## Missing something?
Submit a pull request :D

## TODO
* Add eslint
* Add some unit tests for the formatter/validator logic
* Add props to resize credit-card view
* Accept initialValues
* Support `Name` and `postal code` field
* Handles orientation changes


## License
MIT

---
_Source: https://npm.io/package/react-native-credit-card-form · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
