-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
118 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,67 @@ | ||
# Configuring the "Run Payments with Stripe" Extension | ||
# Installing the "Run Payments with Stripe" Extension | ||
|
||
Once you've created a Stripe webhook, you'll need to configure the "Run Payments with Stripe" extension in Firebase to handle various Stripe events, such as payment successes, subscription updates, and cancellations. Follow the steps below to ensure everything is set up correctly. | ||
Now that Firebase and Stripe are set up, you'll need to configure the "Run Payments with Stripe" extension in Firebase to handle various Stripe events, such as payment successes, subscription updates, and cancellations. Follow the steps below to ensure everything is set up correctly. | ||
|
||
## Step 1: Configure the "Run Payments with Stripe" Extension | ||
|
||
1. Go to your Firebase Console. | ||
2. Navigate to `Extensions` and select the "Run Payments with Stripe" extension. | ||
3. Click `Install`. | ||
2. Navigate to `Extensions` and select the "Run Payments with Stripe" extension. There are two extensions with the same exact name, one made by Stripe and another made by Invertase. Oddly enough, the one we want is the one made by Invertase. Here is a direct link to the correct extension - [Run Payments With Stripe](https://extensions.dev/extensions/invertase/firestore-stripe-payments). | ||
|
||
Follow the on-screen instructions to install the extension, You will need to enable a billing account, continue to follow the on-screen instructions and enable the two neccessary services: | ||
3. Click `Install`. | ||
|
||
 | ||
Follow the on-screen instructions to install the extension. At some point you will need to enable a billing account, do so and then continue to follow the on-screen instructions and enable the neccessary services when asked. | ||
|
||
Click next (2 or three times) to be taken to the configuration form. I recommend the following settings, but you can change them as needed (e.g., if you want to use a different Cloud Functions deployment location). Replace the API and webhook secrets with your own. They can be found in your `.env.local` file. | ||
Click next (2 or three times) to be taken to the configuration form. I recommend the following settings, but you can change them as needed (e.g., if you want to use a different Cloud Functions deployment location). | ||
|
||
 | ||
 | ||
 | ||
|
||
## Step 4: Test the Integration | ||
Leave the API keys blank for now and head back to the stripe dashboard. Click the `Developers` button in the top-right corner and open the `API Keys` section from the pop-up menu. | ||
|
||
 | ||
|
||
Generate a new `Restricted Key` with | ||
|
||
- Write access to Customers | ||
- Write access to Checkout Sessions | ||
- Write access to Customer Portal | ||
- Read access to Subscriptions | ||
|
||
Before going live, it's important to test the webhook to ensure everything is working correctly. | ||
Once saved, copy the Restricted Key and put it in the Firebase Extension config in the "Stripe API Key with Restricted Access" field. Click "create key" to encrypt and save the key. | ||
|
||
1. In your Stripe Dashboard, go to **Developers > Webhooks**. | ||
2. Select your webhook and click **Send test webhook**. | ||
3. Choose an event type (e.g., `checkout.session.completed`) and click **Send test webhook**. | ||
4. Verify that the test event triggers the correct updates in your Firebase database. | ||
Click "Install" at the bottom. This process will take 3-5 minutes. | ||
|
||
## Step 5: Monitor and Troubleshoot | ||
After it is done installing, copy the url from the "How this extension works" tab. | ||
|
||
After deploying, keep an eye on both the Stripe Dashboard and Firebase Console to monitor for any issues. | ||
 | ||
 | ||
|
||
- **Stripe Dashboard:** Check the logs under **Developers > Webhooks** to ensure events are being delivered successfully. | ||
- **Firebase Console:** Monitor your Cloud Function logs to catch any errors or unexpected behavior. | ||
Go back to the Stripe Dashboard and click the `Developers` button in the top-right corner and open the `Webhooks` section from the pop-up menu. | ||
|
||
## Conclusion | ||
Click `Create new endpoint` and copy the url from the "How this extension works" tab as the endpoint. | ||
|
||
Your "Run Payments with Stripe" extension should now be fully configured and ready to handle Stripe events through your webhook. This setup allows you to automate payment processing and keep your Firebase database in sync with Stripe. | ||
Select the following events to send to the endpoint: | ||
|
||
For more advanced configurations: | ||
- product.created | ||
- product.updated | ||
- product.deleted | ||
- price.created | ||
- price.updated | ||
- price.deleted | ||
- checkout.session.completed | ||
- customer.subscription.created | ||
- customer.subscription.updated | ||
- customer.subscription.deleted | ||
- tax_rate.created (optional) | ||
- tax_rate.updated (optional) | ||
- invoice.paid (optional, will sync invoices to Cloud Firestore) | ||
- invoice.payment_succeeded (optional, will sync invoices to Cloud Firestore) | ||
- invoice.payment_failed (optional, will sync invoices to Cloud Firestore) | ||
- invoice.upcoming (optional, will sync invoices to Cloud Firestore) | ||
- invoice.marked_uncollectible (optional, will sync invoices to Cloud Firestore) | ||
- invoice.payment_action_required (optional, will sync invoices to Cloud Firestore) | ||
|
||
- [Stripe documentation](https://stripe.com/docs/webhooks) | ||
Once the webhook is complete, copy the signing secret and place it in the `env.local` file of your project. | ||
|
||
- [Firebase Extensions documentation](https://firebase.google.com/products/extensions). | ||
Now, head to the Firebase dashboard and click the Extensions tab. Find your "Run Payments With Stripe" extension and click 'Reconfigure'. Paste the webhook signing secret into the "Stripe Webhook Secret" field. | ||
|
||
Save the changes, this will take another 3-5 minutes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.