0.1.0 • Published 7 years ago

react-native-stripe-api v0.1.0

Weekly downloads
655
License
MIT
Repository
github
Last release
7 years ago

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

NPM version Downloads Circle CI

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

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

// Create a Stripe token with new card infos
const token = await client.createToken('4242424242424242' , '09', '18', '111');

// 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

NameReturn TypeArgumentsDescription
createTokenPromisecardNumber: string expMonth: stringexpYear: stringcvc: stringCreate a new token (equivalent of a new card)
createCustomerPromisetoken: stringemail: stringCreate a new customer and add card (or token)
getCustomerPromisecustomerId: stringRetrieve customer by its id
createChargePromiseamount: numbercustomer: stringdescription: stringcurrency: string = 'eur'Create a new charge
refundChargePromisechargeId: stringRefund a previous charge
addCardToCustomerPromisetoken: string customerId: stringAdd a new card to a customer
destroyCardOfCustomerPromisecardId: stringcustomerId: stringDelete a card from a customer
createSubscriptionPromisecustomerId: stringplan: stringSubscribes a customer to a subscription plan
retrieveSubscriptionPromisesubscriptionId: stringRetrieve the data of a subscription

Platform support

Contribution

Questions

Feel free to contact me or create an issue

made with ♥