0.1.2 • Published 7 years ago

react-payment-request v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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
0.1.2

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.0

8 years ago