A Payment Request component for React.js
npm install react-payment-requestA Payment Request component for
React.js
``bash`
npm install react-payment-request --save
`html`
`jsx
const details = {...}
const methodData = [...]
const options = {...}
const getOptionsforAddress = shippingAddress => {...}
const updateTotal = shippingOption => {...}
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}
>
`
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.
`bash``
npm test