# react-payment-card-hook

> A React Hook to help with payment card input fields.

Latest version **1.0.5** (published 2021-08-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-payment-card-hook
pnpm add react-payment-card-hook
yarn add react-payment-card-hook
bun add react-payment-card-hook
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-08-25 |
| First published | 2021-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Volodymyr Pastukh |
| Maintainers | pastvolodymyr |
| Keywords | react, react-hook, hook, payment, card, payment-card, input, mask, input-mask, secure-code |

## Links

- npm: https://www.npmjs.com/package/react-payment-card-hook
- Repository: https://github.com/pastvolodymyr/react-payment-card-hook
- Homepage: https://pastvolodymyr.github.io/react-payment-card-hook/
- Issues: https://github.com/pastvolodymyr/react-payment-card-hook/issues
- npm.io page: https://npm.io/package/react-payment-card-hook

## 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

- 1.0.5 (latest) — 2021-08-25
- 1.0.4 — 2021-08-25
- 1.0.3 — 2021-08-25
- 1.0.2 — 2021-08-23
- 1.0.1 — 2021-08-23

## README

# react-payment-card-hook  💳
[![NPM version](http://img.shields.io/npm/v/react-payment-card-hook.svg?style=flat-square)](https://www.npmjs.org/package/react-payment-card-hook) [![NPM license](http://img.shields.io/npm/l/react-payment-card-hook.svg?style=flat-square)](https://www.npmjs.org/package/react-payment-card-hook)

## Demo
https://pastvolodymyr.github.io/react-payment-card-hook/

## Install
Via package managers:

```bash
# With npm
npm i react-payment-card-hook

# With Yarn
yarn add react-payment-card-hook
```

## Usage
Here's an example of basic usage:
```js
import React, { useState } from 'react';
import {usePaymentCard} from "react-payment-card-hook";

export const App = () => {
    const {onFocus, onChange, onBlur, fieldsData} = usePaymentCard()

    return (
        <div>
            <h1>Example react-payment-card</h1>
            <label htmlFor="cardNumber">
                <p>Card number</p>
                <p>Card type: {fieldsData.cardType}</p>
                <input
                    name='cardNumber'
                    type="text"
                    id='cardNumber'
                    onFocus={onFocus}
                    onChange={onChange}
                    onBlur={onBlur}
                    value={fieldsData.cardNumberHideValue || fieldsData.cardNumberValue || ''}
                />
            </label>
            <label htmlFor="expire">
                <p>Expire date</p>
                <input
                    name='expire'
                    type="text"
                    id='expire'
                    onFocus={onFocus}
                    onChange={onChange}
                    onBlur={onBlur}
                    value={fieldsData.expireValue || ''}
                />
            </label>
            <label htmlFor="secureCode">
                <p>Secure code</p>
                <input
                    name='secureCode'
                    type="text"
                    id='secureCode'
                    onFocus={onFocus}
                    onChange={onChange}
                    onBlur={onBlur}
                    value={fieldsData.secureCodeHideValue || fieldsData.secureCodeValue || ''}
                />
            </label>
        </div>
    )
}
```
## Props
```bash
cardNumberInitialValue: '', // Initial card number field value
cardNumberHideChar: '*',    // Card number field secure symbol
cardNumberSeparator: ' ',   // Card numbers separator
expireInitialValue: '',     // Initial expire date field value
expireSeparator: '/',       // Initial expire date field separator
secureCodeInitialValue: '', // Initial secure code field value
secureCodeHideChar: '*',    // Secure code field secure symbol
```

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