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; }