1.7.1 • Published 9 months ago

@goodhood/chargebee v1.7.1

Weekly downloads
9
License
MIT
Repository
github
Last release
9 months ago

@goodhood/chargebee

React chargebee components (Chargebee SDK https://www.chargebee.com/checkout-portal-docs/api.html)

Install

npm i @goodhood/chargebee

Install peer dependencies

npm i react // v16.x.x
npm i react-load-script // v0.x.x
npm i prop-types // v15.x.x
npm i @babel/runtime // v7.x.x

Usage:

import {
  Action,
  PortalLink,
  Checkout,
  SECTION_INVOICES,
  SECTION_EDIT_SUBSCRIPTION,
  SECTION_BILLING_ADDRESS,
} from '@goodhood/chargebee';

API

Action

import { Action } from '@goodhood/chargebee';

const App = () => (
  <Action
    {/* Your site name */}
    site="site-name"

    {/* If true onCall won't be called on click */}
    disabled={true || false}

    {/* Will be called on element click. Receives chargebee instance as an argument */}
    onCall={(chargebeeInstance, ChargebeeAPI) => {}}
  />
);

PortalLink

import { PortalLink, SECTION_INVOICES } from '@goodhood/chargebee';

const App = () => (
  // Inherits Action component props
  <PortalLink
    {/* Section in the customer portal */}
    section={SECTION_INVOICES}

    {/* Should return a promise that resolves a portal session object */}
    onSessionGet={() => Promise.resolve({ id: '', token: '' })}

    {/* Will be called once the portal is closed by the end user */}
    onClose={() => {}}
  />
);

Checkout

import { Checkout } from '@goodhood/chargebee';

const App = () => (
  // Inherits Action component props
  <Checkout
    {/* Should return a promise, that will resolve a hosted page object */}
    onHostedPageGet={() => Promise.resolve({ id: '', url: '' })}

    {/* Will be called once the checkout page is loaded */}
    onLoaded={() => {}}

    {/* Will be called everytime an user navigates from one step to another.
      * String values for currentStep see cb-checkout at 
      * {@link https://www.chargebee.com/docs/2.0/gtm.html} */}
    onStep={(currentStep) => {}}

    {/* This function will be called once the portal is closed by the end user */}
    onClose={() => {}}

    {/* Will be called when a successful checkout happens. */}
    onSuccess={() => {}}

    {/* Will be called if the promise passed in onHostedPageGet causes an error */}
    onError={() => {}}
  />
);

Development

Preview

  • Set chargebee site in root package config/local.js file (see config/default.js)
  • npm run start
  • Visit http://localhost:3000

Add a new component

  • Create src/*/index.jsx

    • Default exports will be re-exported with the chargebee name
    • Named exports will be re-exported as they are (watch out for collisions)

      // src/chargebee/index.jsx
      export const PortalLink = () => {};
      export const Action = () => {};
      
      // usage
      import { PortalLink, Action } from '@goodhood/chargebee';
  • Create src/*/index.stories.jsx

    • Preview will take it up automatically
1.7.1

9 months ago

1.7.0

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.6.0-alpha.0

1 year ago

1.5.0

2 years ago

1.5.0-beta.0

2 years ago

1.4.1

2 years ago

1.4.1-beta.1

2 years ago

1.4.1-beta.0

3 years ago

1.4.0-beta.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago