README
Stripe Library
A simple stripe interface module
Getting Started
This library binds the model to the stripe library, the model interface is defined below
Installation
Run npm install highoutput-stripe
to install
Features
- Card CRUD methods for a given user
- Uses async/await, does not support callbacks
Quickstart
const Stripe = require('highoutput-stripe');
const model = {
async retrieveUserbyId(userId) { ... },
async bindStripeToUser({ sourceId, cardId, stripeId, userId }) { ... },
async retrieveCard(cardId, userId) { ... },
};
const stripe = new Stripe({
key: 'sk_test_NkaNTcylDUjmP0hoG075J7S5p1mFZ9',
model: model,
});
stripe.createCard({
userId: '',
sourceId: 'tok_visa',
description: 'Sample VISA Card'
}).then((card) => { console.log(card); });
new Stripe(options)
The stripe constructor accepts the following configuration
- key: the stripe key
- model: the model object that contains the defined methods used to access data
Model Specification
async retrieveUserById()
Retrieve the user by its id
Arguments
- userId
{ String }
the user's id
Returns
- obj.userId
{ String }
the user's id - obj.stripeId
{ String }
the binded stripe's customer id - obj.email
{ String }
the user's email
async bindStripeToUser()
Map the user by its stripe ids
Arguments
- obj.userId
{ String }
the user's id - obj.stripeId
{ String }
the stripe customer id - obj.cardId
{ String }
the stripe card id - obj.sourceId
{ String }
the stripe source id
Returns
- obj.userId
{ String }
the user's id - obj.stripeId
{ String }
the stripe customer id - obj.cardId
{ String }
the stripe card id - obj.sourceId
{ String }
the stripe source id
async retrieveCard()
Retrieve the card by userId and cardId
Arguments
- userId
{ String }
the user's id - cardId
{ String }
the stripe card id
Returns
- obj.userId
{ String }
the user's id - obj.stripeId
{ String }
the stripe customer id - obj.cardId
{ String }
the stripe card id - obj.sourceId
{ String }
the stripe source id