I installed stripe/firestore-stripe-payments
extension using Firebase Console (https://firebase.google.com/products/extensions/stripe-firestore-stripe-payments) and it works fine.
However, I wanted to install the extension locally so I can have a full testing environment using Firebase Local Emulator Suite.
The issue is that whenever I try to run firebase ext:install stripe/firestore-stripe-payments
using both firebase-tools
11.8.1
and 11.14.1
, it shows the following error:
I tried looking online but it seems that this error is not common.
Here’s my firebase.json
:
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix "$RESOURCE_DIR" run lint",
"npm --prefix "$RESOURCE_DIR" run build"
],
"source": "functions"
},
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"database": {
"port": 9000
},
"ui": {
"enabled": true
},
"firestore": {
"port": 8080
},
"storage": {
"port": 9199
},
"hosting": {
"port": 5000
},
"pubsub": {
"port": 8085
},
"eventarc": {
"port": 9299
}
},
"remoteconfig": {
"template": "remoteconfig.template.json"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage.rules"
},
"hosting": {
"public": "./web/build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Thank you in advance
2
Answers
I fixed the error by specifying the exact version, according to this GitHub comment.
The latest version can be found as
version
inextension.yaml
in the official repository, which "source code" link in Firebase's extension page can refer to it, in my case: https://github.com/stripe/stripe-firebase-extensions/blob/master/firestore-stripe-payments/extension.yamlSo, I used this command and it worked!
firebase ext:install stripe/[email protected]
It took care of the
firebase.json
andextensions/firestore-stripe-payments.env
automatically.If you already installed the extension via console.firebase.google.com, use the following command to import the configuration:
firebase ext:export --project=XXXX
Then, override any attribute in
extensions/firestore-stripe-payments.env.local
as @darren-ackers mentioned.There's a pending PR that covers most of these steps in addition to webhook configuration, here's the relevant file (README):
https://github.com/stripe/stripe-firebase-extensions/pull/436/files
The v11 version of firebase-tools works quite differently to previous major versions.
To run locally, you will need to make a few additions.
1). Add an
extensions
object to yourfirebase.json
and use a relative path to point to the route of the stripe extension (basically where the extension.yaml lives).2). Next you will require a new folder to host your extension configuration.
Add a new folder called "extensions" in the same directory as your firebase.json.
Create new files for local config (this must match the extension you are attempting to emulate).
For example:
firestore-stripe-payments.env.local
for main configurationfirestore-stripe-payments.secret.local
for secrets3). Finally, run
firebase emulators:start -P ${project_id}, it is recommended to use the prefix
demo-, as in
demo-project` to avoid emulating any production services.For more guidelines with Stripe, the official repository has an example or extensions tests https://github.com/stripe/stripe-firebase-extensions/tree/next/firestore-stripe-payments/_emulator