AntoineDoubovetzky / react-native-stripe-api

🤑 A small React Native library for Stripe Rest API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-stripe-api (only to create token)

NPM version Downloads Circle CI reactnative.gallery

Little Stripe library for React-Native.

Installation

$ npm i react-native-stripe-api --save

or

$ yarn add react-native-stripe-api

Roadmap

  • include a payment form component
  • include react-native-awesome-card-io
  • a new server project to keep secret

Setup

Security issue (fixed since 0.1.0)

https://github.com/xcarpentier/react-native-stripe-api/issues/8

Stripe API

This lib need a Stripe API Key

import Stripe from 'react-native-stripe-api';

const apiKey = '<your Stripe API Key>';
const client = new Stripe(apiKey);

// Create a Stripe token with new card infos
const token = await client.createToken({
       number: '4242424242424242' ,
       exp_month: '09', 
       exp_year: '18', 
       cvc: '111',
       address_zip: '12345'
    });

// Create a new customer and link your new card
// const customer = await client.createCustomer(token.id, 'customer@email.com', '<Your user ID>', 'John', 'Doe');

// Create charge, 1 USD
// const charge = await client.createCharge(1 * 100, customer.id, 'Payment example','USD');

Functions

Name Return Type Arguments Description
createToken Promise
  • cardNumber: string
  • expMonth: string
  • expYear: string
  • cvc: string
Create a new token (equivalent of a new card)
createCustomer Promise
  • token: string
  • email: string
Create a new customer and add card (or token)
getCustomer Promise customerId: string Retrieve customer by its id
createCharge Promise
  • amount: number
  • customer: string
  • description: string
  • currency: string = 'eur'
Create a new charge
refundCharge Promise chargeId: string Refund a previous charge
addCardToCustomer Promise
  • token: string
  • customerId: string
    Add a new card to a customer
    destroyCardOfCustomer Promise
    • cardId: string
    • customerId: string
    Delete a card from a customer
    createSubscription Promise
    • customerId: string
    • plan: string
    Subscribes a customer to a subscription plan
    retrieveSubscription Promise
    • subscriptionId: string
    Retrieve the data of a subscription

    Contribution

    Questions

    Feel free to contact me or create an issue

    made with ♥

    About

    🤑 A small React Native library for Stripe Rest API

    License:MIT License


    Languages

    Language:JavaScript 100.0%