Process payments with Firebase
Stay organized with collections
Save and categorize content based on your preferences.
Using a few different Firebase features and Stripe, you can process payments in
your web app without building your own server infrastructure. This guide walks
you through customizing and deploying your own version of the open-source
cloud-functions-stripe-sample.web.app example app.
Before you start, create a project in the
Firebase console and set up a
Stripe account.
Implementation overview
- Set up a Stripe account.
- Create a project in the Firebase console.
- Upgrade your project to the pay-as-you-go Blaze pricing plan.
- Configure the Firebase CLI to use your project with
firebase use --add
.
- Get the source code
for the sample Firestripe app. Configure it with the right
information for your project and customize the code to fit your app.
- Once you've deployed your app, look for a list of users and transactions in
the Firebase console.
Set up and deploy the sample app
- Get the
source code.
- Enable Google & Email sign-in in your authentication provider settings.
- Enable Cloud Firestore.
- Install the Firebase CLI
if you haven't already, and log in with
firebase login
.
- Configure this sample to use your project with
firebase use --add
.
- Install dependencies locally by running
cd functions; npm install; cd -
Add your Stripe API Secret Key
to your Cloud Functions environment configuration:
firebase functions:config:set stripe.secret=<YOUR STRIPE SECRET KEY>
Set your Stripe publishable key
in /public/javascript/app.js
:
const STRIPE_PUBLISHABLE_KEY=<YOUR STRIPE PUBLISHABLE KEY>;
Deploy your project using firebase deploy
. This command:
- Sends all the files in the
public
directory to Hosting so that your website is available.
- Sends the code in the
functions
directory to Cloud Functions for Firebase.
- Sets security rules on your Cloud Firestore database as configured in
firestore.rules
. The provided rules only allow a user to read and
write their own payments and payment methods.
Test the sample app
Visit your payments app's URL at
your-firebase-project-id.web.app
and verify that the following features work:
- You can sign in via Google or Email.
- You can add a new Stripe test card and view it in the card select element.
- You can select one of your cards and charge it.
- You can sign out.
For comparison, see
cloud-functions-stripe-sample.web.app.
To provide a streamlined experience for your users, you can further customize
your payment page's appearance, or plug it into your existing app.
View processed payments
Once you've set up and deployed your payments page, you can check the Firebase
console and see a list of users along with their payment methods and payments.
- Go to Cloud Firestore.
- Check for a list of your users and, if they added any credit cards or made
any transactions, a list of those under each user.
Accept live payments
Once you’re ready to go live, you'll need to exchange your test keys for your
live keys. See the Stripe docs to learn more
about these keys.
Update your Stripe secret config:
firebase functions:config:set stripe.secret=<YOUR STRIPE LIVE SECRET KEY>
Set your live publishable key in
/public/javascript/app.js
.
Redeploy both Cloud Functions and Hosting for the changes to take effect:
firebase deploy
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
[null,null,["Last updated 2025-09-04 UTC."],[],[],null,["Using a few different Firebase features and Stripe, you can process payments in\nyour web app without building your own server infrastructure. This guide walks\nyou through customizing and deploying your own version of the open-source\n[cloud-functions-stripe-sample.web.app](//cloud-functions-stripe-sample.web.app/) example app.\n\nBefore you start, create a project in the\n[Firebase console](https://console.firebase.google.com) and set up a\n[Stripe](https://stripe.com/) account.\n| **Note:** Our partners at Stripe have introduced two new extensions, [Run Subscription Payments with Stripe](https://firebase.google.com/products/extensions/firestore-stripe-subscriptions) and [Send Invoices using Stripe](https://firebase.google.com/products/extensions/firestore-stripe-invoices), to make it possible to process payments with even less code!\n\nImplementation overview\n\n1. Set up a [Stripe](//stripe.com/) account.\n2. Create a project in the [Firebase console](//console.firebase.google.com).\n3. Upgrade your project to the [pay-as-you-go Blaze pricing plan](/pricing).\n4. Configure the Firebase CLI to use your project with `firebase use --add`.\n5. Get the [source code](//github.com/firebase/functions-samples/tree/main/Node-1st-gen/stripe) for the sample Firestripe app. Configure it with the right information for your project and customize the code to fit your app.\n6. Once you've deployed your app, look for a list of users and transactions in the Firebase console.\n\nSet up and deploy the sample app\n\n1. Get the [source code](//github.com/firebase/functions-samples/tree/main/Node-1st-gen/stripe).\n2. Enable Google \\& Email sign-in in your [authentication provider settings](//console.firebase.google.com/project/_/authentication/providers).\n3. Enable [Cloud Firestore](//console.firebase.google.com/project/_/firestore).\n4. Install the [Firebase CLI](//github.com/firebase/firebase-tools) if you haven't already, and log in with `firebase login`.\n5. Configure this sample to use your project with `firebase use --add`.\n6. Install dependencies locally by running `cd functions; npm install; cd -`\n7. Add your [Stripe API Secret Key](//dashboard.stripe.com/account/apikeys)\n to your Cloud Functions environment configuration:\n\n `firebase functions:config:set stripe.secret=\u003cYOUR STRIPE SECRET KEY\u003e`\n8. Set your [Stripe publishable key](//dashboard.stripe.com/account/apikeys)\n in [`/public/javascript/app.js`](//github.com/firebase/functions-samples/tree/main/Node-1st-gen/stripe/public/javascript/app.js#L16):\n\n `const STRIPE_PUBLISHABLE_KEY=\u003cYOUR STRIPE PUBLISHABLE KEY\u003e;`\n9. Deploy your project using `firebase deploy`. This command:\n\n 1. Sends all the files in the `public` directory to Hosting so that your website is available.\n 2. Sends the code in the `functions` directory to Cloud Functions for Firebase.\n 3. Sets security rules on your Cloud Firestore database as configured in `firestore.rules`. The provided rules only allow a user to read and write their own payments and payment methods.\n\nTest the sample app\n\nVisit your payments app's URL at\n`your-firebase-project-id.web.app` and verify that the following features work:\n\n- You can sign in via Google or Email.\n- You can add a new [Stripe test card](//stripe.com/docs/testing) and view it in the card select element.\n- You can select one of your cards and charge it.\n- You can sign out.\n\nFor comparison, see\n[cloud-functions-stripe-sample.web.app](//cloud-functions-stripe-sample.web.app/).\n\nTo provide a streamlined experience for your users, you can further customize\nyour payment page's appearance, or plug it into your existing app.\n\nView processed payments\n\nOnce you've set up and deployed your payments page, you can check the Firebase\nconsole and see a list of users along with their payment methods and payments.\n\n1. Go to [Cloud Firestore](https://console.firebase.google.com/project/_/firestore/data).\n2. Check for a list of your users and, if they added any credit cards or made any transactions, a list of those under each user.\n\nAccept live payments\n\nOnce you're ready to go live, you'll need to exchange your test keys for your\nlive keys. See the [Stripe docs](https://stripe.com/docs/keys) to learn more\nabout these keys.\n\n1. Update your Stripe secret config:\n\n `firebase functions:config:set stripe.secret=\u003cYOUR STRIPE LIVE SECRET KEY\u003e`\n2. Set your [live publishable key](//dashboard.stripe.com/account/apikeys) in\n [`/public/javascript/app.js`](//github.com/thorsten-stripe/functions-samples/blob/thorsten-stripe/update-stripe-template/stripe/public/javascript/app.js#L16).\n\n3. Redeploy both Cloud Functions and Hosting for the changes to take effect:\n `firebase deploy`."]]