1.0.2 • Published 3 years ago

react-stripe-typescript-client v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

React Stripe Typescript Client

A small library for React / React Native which creates Stripe tokens using your Publishable API Key which can then safely be consumed by your backend

Installation

$ npm i install react-stripe-typescript-client

or

$ yarn add react-stripe-typescript-client

Usage

import { createToken } from "react-stripe-typescript-client"

const res: TokenResponse = await createToken(
    'YOUR_PUBLISHABLE_STRIPE_TOKEN',
      {
        cvc: 245,
        exp_month: 12,
        exp_year: 24,
        number: 42424242424242,
      }
    );

The createToken function also accepts all other Stripe card parameters within the card object

The TokenResponse interface has the following format

interface TokenResponse {
  id: string;
  object: string;
  card: Card;
  client_ip: string;
  created: number;
  livemode: boolean;
  type: string;
  used: boolean;
  error: TokenErrorResponse;
}

Error handling

If an error is sent back by Stripe, it's made available in the error key inside of the TokenResponse interface

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago