@cloudflare/component-payment-method-form-v2
TypeScript icon, indicating that this package has built-in type declarations

7.0.52 • Public • Published

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.

  1. import fieldsReducer and set it to fields key (required by @cloudflare/redux-fields)
  2. import hCaptchaReducer and set it to the billing.captcha key
  3. import creditCardProcessorReducer and set it to billing.creditCardProcessor key
  4. Bootstrap Stripe Elements provider during app init. Documentation can be found https://stripe.com/docs/stripe-js/react#elements-provider.
  5. 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
  6. 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;

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudflare/component-payment-method-form-v2

Weekly Downloads

1,009

Version

7.0.52

License

BSD-3-Clause

Unpacked Size

1.19 MB

Total Files

182

Last publish

Collaborators

  • lbarthonet
  • cf-media-manager
  • jacobbednarz
  • celso
  • cf-radar
  • dash_service_account
  • g4brym
  • snigdha34
  • wrangler-publisher
  • marksteyn
  • chiminator
  • sgoodhew_cf
  • terinjokes
  • third774
  • jsteinberger
  • jasnell
  • asapzacy
  • pcostanzo
  • gregbrimble
  • geelen
  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • vasturiano
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga