Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stripe Tutorial - Dude Lemon
//stripeProcessor.jsw
import stripe from 'stripe';
const key = require("stripe")("sk_test_xxxxxx"); //Stripe SECRET API Key
//---------------------------------------------Create Customer---------------------------------------------//
export function createCustomer(token, emailId) {
return key.customers.create({
email: emailId,
source: token
})
.then( function(err, customer) {
if (err) {
return Promise.resolve(err); //does not work
}
return Promise.resolve(customer);
})
.catch( (err) => {
return err;
});
}
//---------------------------------------------Create Subscription---------------------------------------------//
export function createSubscription(cus, plan) {
return key.subscriptions.create({
customer: cus,
items: plan
})
.then( function(err, subscription) {
if (err) {
return Promise.resolve(err); //does not work
}
return Promise.resolve(subscription);
})
.catch( (err) => {
return err;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.