Invitation only for signup

This commit is contained in:
Adolfo Reyna
2021-10-04 10:13:06 -07:00
parent e886b2bd57
commit 74f9108fa7
9 changed files with 192 additions and 10 deletions

44
Payments.js Normal file
View File

@@ -0,0 +1,44 @@
const Stripe = require('stripe');
const stripe = Stripe(process.env.STRIPE);
const addNewCustomer = async (email, profile) => {
const customer = await Stripe.customers.create({
email,
description: profile ? profile.firstName + " " + profile.lastName : "new costumer",
});
return customer;
}
const getCustomerByID = async (id) => {
const customer = await Stripe.customers.retrieve(id);
return customer;
}
const addNewCustomerCard = async (customer, cardInfo) => {
let template = {
"address_city": cardInfo.address_city,
"address_country": cardInfo.address_country,
"address_line1": cardInfo.address_line1,
"address_line2": cardInfo.address_line2,
"address_state": cardInfo.address_state,
"address_zip": cardInfo.address_zip,
customer,
"exp_month": cardInfo.exp_month,
"exp_year": cardInfo.exp_year,
"name": cardInfo.name,
};
const card = await stripe.customers.createSource(
'cus_KKsGI28Nrbm61K',
template
);
return card;
}
const getCustomerCard = async (customer, card) => {
const card = await stripe.customers.retrieveSource(
customer,
card
);
return card;
}