1.0.0 • Published 1 year ago

@butterpayments/butter-vaulting-react v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Butter Vaulting React

A set of React components to integrate Butter Payments vaulting without interrupting the payment flow.

Installation

Using Node Package Manager

npm install --save @butter-payments/butter-vaulting-react

Using Yarn

yarn add @butter-payments/butter-vaulting-react

Usage

Simply use the ButterForm component and the CardElement component to get your Stripe payment method. You will be able to grab the Stripe payment method from the onSubmit hook.

ButterForm

Properties

PropertyRequiredTypeDescription
merchantKeytruestringThe merchant key provided by Butter
sourceIdtruestringThe sourceId provided by Butter
stylefalseobjectReact style object for inline styling
classNamefalsestringClassnames to be passed onto the form

Requires a button component with type submit to trigger the form submission.

Example

import {
  ButterForm,
  CardElement,
} from '@butter-payments/butter-vaulting-react';

const App = () => {
  const handleSubmit = (event, paymentMethod) => {
    // Handle your business logic and continue the payment here with the newly created payment method
    console.log(paymentMethod);
  }

  return (
    <ButterForm merchantKey='xxx' sourceId='xxx' onSubmit={handleSubmit}>
      <CardElement />
      <button type="submit">
        Submit
      </button>
    </ButterForm>
  );
};

Styling

Minimal styling is applied to the components to make it easier to match your branding.