Sync Stripe subscription status to your Firebase users

The moment a customer's Stripe subscription changes, we update their Firebase user record so their paid access always matches their real billing status.

Deterministic Code
StripeFirebaseFinanceEngineeringData Sync
PromptCreate

This is a deterministic field-mapping sync that keeps a Firebase (Firestore) user record in step with a customer's real Stripe billing state. Use a webhook trigger: run this workflow whenever Stripe reports that a subscription was updated or canceled (the customer.subscription.updated and customer.subscription.deleted events). From the incoming event, read the subscription id and the Stripe customer id.

Call Stripe "Retrieve Subscription" with that subscription id to fetch the authoritative current state: the subscription status, the plan (from the price or product on the subscription's first line item), and the current period end (a Unix timestamp). Always re-retrieve the subscription rather than trusting the numbers in the event payload, so the record reflects the very latest state.

Locate the matching user document with Firebase "Run Firestore Query" against the users collection, filtering where the stored Stripe customer id field equals the customer id from the event. Take the first matching document and note its full document path.

Update that document with Firebase "Update Firestore Document", patching only the billing fields: subscriptionStatus (the Stripe status such as active, past_due, or canceled), plan (the price or product identifier), and currentPeriodEnd (convert the Unix timestamp from Stripe into an RFC3339 timestamp for Firestore). Use an update mask so the rest of the user document is left untouched.

Let me configure the collection that holds users, the field on that document that stores the Stripe customer id used for matching, and the exact field names to write (for example subscriptionStatus, plan, and currentPeriodEnd). If no matching user document is found for the customer, log that and skip rather than creating a new record.

Additional information

What does this prompt do?
  • Watches for subscription changes in Stripe (upgrades, downgrades, renewals, and cancellations) and reacts the moment they happen.
  • Finds the matching person in your Firebase (Firestore) database by the Stripe customer id stored on their record.
  • Writes the current subscription status, plan, and renewal date onto that user's record.
  • Keeps the paid access level in your app accurate without any manual updates or exports.
What do I need to use this?
  • A Stripe account with active subscriptions.
  • A Firebase project that stores your users in Firestore.
  • Each user record needs to store that customer's Stripe customer id so we can match the right person.
How can I customize it?
  • Choose which Firestore collection holds your users.
  • Set the exact field names to write, for example subscriptionStatus, plan, and currentPeriodEnd.
  • Decide which subscription events to act on: updates, cancellations, or both.

Frequently asked questions

Do I need to write any code to set this up?
No. You connect your Stripe and Firebase accounts, tell us which Firestore collection holds your users and which fields to write, and the sync runs on its own whenever a subscription changes.
How does it know which user to update?
It matches on the Stripe customer id. As long as each user record stores that customer's Stripe customer id, we look up the right person and update only their record.
What happens when a customer cancels?
Stripe reports the cancellation right away, and we update that user's record so its status reflects the canceled subscription. Your app can then downgrade their access based on that field.
Will this work with any Stripe plan or price?
Yes. It reads whatever plan the subscription is on and writes it to the record, so it works across all of your pricing tiers.
How quickly does the record update?
Almost instantly. The sync runs as soon as Stripe reports the subscription change, so your Firebase records stay current without waiting for a nightly job.

Stop letting Stripe and Firebase drift out of sync.

Set this up once and every user's paid access in Firebase always reflects their real Stripe billing state.