rpr

react-payment-request

A Payment Request component for React.js

Showing:

Popularity

Downloads/wk

0

GitHub Stars

9

Maintenance

Last Commit

5yrs ago

Contributors

3

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

React Payment Request

A Payment Request component for React.js

Installation

Npm

npm install react-payment-request --save

Umd

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

Usage

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

ParameterTypeDescription
detailsobjectRequired information about transaction.
methodDataarrayRequired payment method data.
onErrorfuncSomething bad happened.
onShippingAddressChangefuncWhen user selects a shipping address.
onShippingOptionChangefuncWhen user selects a shipping option.
onSuccessfuncProcess paymentResponse here.
optionsobjectOptional parameter for things like shipping, etc.

Test

npm test

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial