📁 File Manager Pro
v10.0.3 | PHP: 8.2.31
Server: LiteSpeed
2026-07-01 19:17:04
📂
/ (Root)
/
home
/
orkouolp
/
node_js
/
orkofarms.com
/
helpers
📍 /home/orkouolp/node_js/orkofarms.com/helpers
🔄 Refresh
✏️
Editing: getCustomer.js
Writable
const stripeAPI = require('../stripe'); const firebase = require('../firebase'); async function createCustomer(userId) { const userSnapshot = await firebase.db.collection('users').doc(userId).get(); const { email } = userSnapshot.data(); let customer = null; //customer = await stripeAPI.customers.create({email, metadata: {firebaseUID: userId}}); if(customer) await userSnapshot.ref.update({ stripeCustomerId: customer.id }); return customer; } async function getCustomer(userId) { let customer = null; console.log("getCustomer:: userId:", userId); //const email = "mahbub.seaboard@gmail.com", pass = "123456"; try { //console.log("getCustomer:: firebase.auth:", firebase.auth); //-------------------------------------------------------------------------// // const decodeValue = await firebase.auth.verifyIdToken(' '); // const userCredential = firebase.auth.signInWithEmailAndPassword(email, pass); // console.log("userCredential:", userCredential); // const user = userCredential.user; console.log(`User ${user.email} is authenticated`); //-------------------------------------------------------------------------// const userSnapshot = await firebase.db.collection('users').doc(userId).get(); // console.log("userSnapshot:", userSnapshot); if(userSnapshot) { // console.log("userSnapshot.data():", userSnapshot.data()); if(userSnapshot.data()) { const { stripeCustomerId } = userSnapshot.data(); console.log("stripeCustomerId:", stripeCustomerId); if(!stripeCustomerId) return createCustomer(userId); //customer = await stripeAPI.customers.retrieve(stripeCustomerId); // const } } } catch(error) { console.log(error); } return customer; } module.exports = getCustomer;
💾 Save Changes
❌ Cancel