Reputation: 75
I am trying to add Stripe payments inside of my iOS application with node.js and firebase.
As of now, my main goal is to create a stripe customer when a user creates an account with my application.
I am trying to follow these instructions but I am having issues.
https://www.iosapptemplates.com/blog/ios-development/stripe-firebase-swift
const logging = require('@google-cloud/logging');
const stripe = require('stripe')(functions.config().stripe.token);
const currency = functions.config().stripe.currency || 'USD';
exports.createStripeCustomer = functions.auth.user().onCreate((user) => {
return stripe.customers.create({
email: user.email,
}).then((customer) => {
return admin.database().ref(`/stripe_customers/${user.uid}/customer_id`).set(customer.id);
});
});
When I try to run firebase deploy --only functions
inside of my terminal, I am hit with
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'token' of undefined
Am I supposed to define token? I assumed it was an autocomplete value associated with stripe?
EDIT to show package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "10"
},
"dependencies": {
"firebase": "^7.15.5",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.0"
},
"private": true
}
Upvotes: 0
Views: 789
Reputation: 5847
token
in this instance is probably a bit poorly named, what you actually pass into that function is a Stripe API key.
You'll want to first grab your API keys from the Stripe dashboard directly, then you'll want to set your firebase config to have that API key set:
firebase functions:config:set stripe.token=<YOUR STRIPE SECRET KEY>
I've set the parameter to be called token
so your index.js
file doesn't need any amendments, however it would be better named as stripe.secret
or stripe.apiKey
.
Upvotes: 1