DEV Community

Valentin Degenne
Valentin Degenne

Posted on

My journey as I try to install Stripe in my app.

Stripe is at core a REST API (somewhere) that you can use to manage a payment system for your application.

Fortunately, if you already use Firebase, the process of installing Stripe is extremely simplified, but it doesn't mean that it is just few buttons to push.

Here's a succinct list of all the steps:

Create a Stripe account.

Creating a stripe account is easy. By default Stripe comes with a testing environment (test key, ...). That means you don't need to provide your banking informations until you bring your app to production.

Install the Stripe extension into Firebase

Before installing the extension, you'll need to do few things:

  • Make sure to upgrade your project to Blaze Plan. Upgrading your account is necessary because the extension installs some "functions" which is how Firebase and Stripe services communicate together on special events.
  • Install Firestore and Authentication Firebase services before continuing.

Once that's done, you can install the firestore-stripe-payments extension from the extensions hub or directly from Firebase "extensions" section.

The installation takes few minutes.
And when it finishes successfully, you are ready to go.

However for me that's where things started to be confusing. And that's where we should start to ask the right questions:

- What does the extension install exactly?

Primarily the extension installs a bunch of functions. (If you are not familiar with functions and what they do please read this). Basically functions are like callbacks that are executed on special events (when a user is created/deleted, when a document is pushed inside a path in Firestore, etc...).

You can check all the installed functions inside your project going to the functions page in Firebase console:

Image description

(note: you can always see more details about functions going to the Cloud functions dedicated page)

The first function of interest is the first one. Basically Stripe API creates a checkout session when you push a checkout session document inside the checkout_sessions collection associated with a user. In turn Firebase will update this document with a session ID returned by Stripe API. You can then use this session ID to redirect the user on a Stripe customized checkout page providing this id.

- Is it possible to see the implementation of the functions?

Not directly inside Firebase, but here's the source page

Things that Stripe extension modifies in the cloud

  • Add a "Firebase Extensions firestore-stripe-payments service account"
  • Add the Stripe API key in Google Cloud Secret Manager. This key is used for Firebase functions to securely communicate with the Stripe API.

Article still in progress.....

Top comments (0)