@cloudflare/component-payment-method-form-v2
v7.0.52
Published
> PaymentMethod Form for Dash and Teams Dash
Downloads
3,672
Maintainers
Keywords
Readme
component-payment-method-form-v2
PaymentMethod Form for Dash and Teams Dash
This component is created specifically to be used on Dash and Teams dashboard. There are some setup requirements needed in order to properly consumer @cloudflare/payment-method-form-v2
.
- import
fieldsReducer
and set it to fields key (required by@cloudflare/redux-fields
) - import
hCaptchaReducer
and set it to the billing.captcha key - import
creditCardProcessorReducer
and set it to billing.creditCardProcessor key - Bootstrap Stripe Elements provider during app init. Documentation can be found https://stripe.com/docs/stripe-js/react#elements-provider.
- We want to defer loading of stripe-js script until
loadStripe
is called. Explaination can be found https://github.com/stripe/stripe-js#importing-loadstripe-without-side-effects - import sparrow and initial. Documentaiotn can be found https://www.npmjs.com/package/@cloudflare/util-sparrow
import { loadStripe } from '@stripe/stripe-js/pure';
import { Elements } from '@stripe/react-stripe-js';
const stripePromise = loadStripe('pk_12345678');
render(
<Elements stripe={stripePromise}>
<App/>
</Elements>
);
import {
fieldsReducer as billingFieldsReducer,
hCaptchaReducer as billingHCaptchaReducer,
credititCardProcessorReducer
} from '@cloudflare/component-payment-method-form-v2'
const appReducers = combineReducers({
fields: billingFieldsReducer,
billing: combineReducers({
captcha: billingHCaptchaReducer,
creditCardProcessor: credititCardProcessorReducer
}),
})
import sparrow from '@cloudflare/util-sparrow'
sparrow.init({
clientId: 'client-id-string',
debug: production ? true : false,
enabled: production ? true : false
url: production ? 'https://sparrow.cloudflare.com' : ''
})
Installation
$ yarn add @cloudflare/component-payment-method-form-v2
Usage
import React from 'react';
import PaymentMethodForm from './src/index';
class ComponentWithPaymentMethodForm extends React.Component {
render() {
return (
<PaymentMethodForm
accountId={'12345'}
updateBillingProfile={() => {}}
createBillingProfile={() => {}}
/>
);
}
}
export default ComponentWithRecaptcha;