[][I
I used Cloud Functions to process payments using stripe.But I encountered the following error.How to connect to stripe??
and this is my index.js file
const https = require( 'firebase-functions');
const functions = require('firebase-functions');
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore();
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.helloUser = functions.firestore
.document('stripetoken/{tokenId}')
.onCreate(event =>{
//var tokendata = event.data.data();
var tokenId = event.params.tokenId;
const stripe = require("stripe")("sk_test_l3ehpEzKMk4EAGZQ0QS64vgO")
stripe.customers.create({
email: "galladivya3@gmail.com",
source: tokenId,
}).then(function(customer) {
// YOUR CODE: Save the customer ID and other info in a database for later.
return stripe.charges.create({
amount: 1000,
currency: "usd",
customer: customer.id,
});
}).then(function(charge) {
// Use and save the charge info.
});
});