# react-payment-request

> A Payment Request component for React.js

Latest version **0.1.2** (published 2017-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-payment-request
pnpm add react-payment-request
yarn add react-payment-request
bun add react-payment-request
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2017-05-20 |
| First published | 2016-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | lucasmotta, michelebertoli |
| Keywords | react-component, payment-request, android-pay |

## Links

- npm: https://www.npmjs.com/package/react-payment-request
- Repository: https://github.com/MicheleBertoli/react-payment-request
- Homepage: https://github.com/MicheleBertoli/react-payment-request#readme
- Issues: https://github.com/MicheleBertoli/react-payment-request/issues
- npm.io page: https://npm.io/package/react-payment-request

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2017-05-20
- 0.1.1 — 2016-12-26
- 0.1.0 — 2016-08-18
- 0.0.9 — 2016-08-17
- 0.0.8 — 2016-08-17
- 0.0.7 — 2016-08-17
- 0.0.6 — 2016-08-17
- 0.0.5 — 2016-08-17
- 0.0.4 — 2016-08-17
- 0.0.3 — 2016-08-17
- 0.0.2 — 2016-08-17
- 0.0.0 — 2016-08-17

## README

# React Payment Request

A [Payment Request](https://developers.google.com/web/fundamentals/primers/payment-request/) component for
[React.js](https://facebook.github.io/react/)

## Installation

### Npm

```bash
npm install react-payment-request --save
```

### Umd

```html
<script src="https://unpkg.com/react-payment-request/dist/react-payment-request.js"></script>
```

## Usage

```jsx
const details = {...}
const methodData = [...]
const options = {...}

const getOptionsforAddress = shippingAddress => {...}
const updateTotal = shippingOption => {...}

<ReactPaymentRequest
  details={details}
  methodData={methodData}
  onError={error => console.log('💩', error)}
  onShippingAddressChange={(request, resolve, reject) => {
    details.shippingOptions = getOptionsforAddress(request.shippingAddress)
    resolve(details)
  }}
  onShippingOptionChange={(request, resolve, reject) => {
    details.shippingOptions = updateTotal(request.shippingOption)
    resolve(details)
  }}
  onSuccess={result => result.complete('success')}
  options={options}
>
  <button>Pay</button>
</ReactPaymentRequest>
```

## API

Parameter               | Type   | Description
----------------------- | ------ | -----------
details                 | object | Required information about transaction.
methodData              | array  | Required payment method data.
onError                 | func   | Something bad happened.
onShippingAddressChange | func   | When user selects a shipping address.
onShippingOptionChange  | func   | When user selects a shipping option.
onSuccess               | func   | Process paymentResponse here.
options                 | object | Optional parameter for things like shipping, etc.


## Test

```bash
npm test
```

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