payments v1
This commit is contained in:
+39
-41
@@ -1,44 +1,42 @@
|
||||
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;
|
||||
}
|
||||
module.exports = {
|
||||
async addNewCustomer(email, profile){
|
||||
const customer = await Stripe.customers.create({
|
||||
email,
|
||||
description: profile ? profile.firstName + " " + profile.lastName : "new costumer",
|
||||
});
|
||||
return customer;
|
||||
},
|
||||
async getCustomerByID(id){
|
||||
const customer = await Stripe.customers.retrieve(id);
|
||||
return customer;
|
||||
},
|
||||
async addNewCustomerCard(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(
|
||||
customer,
|
||||
template
|
||||
);
|
||||
return card;
|
||||
},
|
||||
async getCustomerCard(customer, cardId){
|
||||
const card = await stripe.customers.retrieveSource(
|
||||
customer,
|
||||
cardId
|
||||
);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user