The Reality of Making These Three Things Work Together

Firebase Architecture Overview

Let me be straight with you: this integration will fight you every step of the way. Firebase Auth randomly signs out users mid-payment. Stripe's React Native SDK throws cryptic errors when your Android build tools aren't exactly the right version. And Firebase Cloud Functions timeout under load because nobody told you to increase the memory allocation from the default 256MB.

What Actually Happens (Not What the Docs Say)

Firebase Auth Loses Its Mind
The onAuthStateChanged listener fires 3-4 times on app startup for no fucking reason. You'll spend hours implementing debouncing just to stop your user profile from flickering. And don't get me started on auth state persistence - it works until your user upgrades to iOS 17.2, then suddenly anonymous sessions vanish randomly. The Firebase Auth troubleshooting guide doesn't mention half the issues you'll encounter in React Native environments.

React Native Firebase Version Hell
React Native Firebase versions around 18.6.0 have auth persistence issues that make users sign out when they background the app. Version 18.5.0 works, but breaks with React Native 0.72+. Version 17.5.0 is stable but missing half the features you need. Check the compatibility matrix and migration guide before you upgrade anything. Pick your poison.

Stripe SDK Conflicts With Everything
The Stripe React Native SDK version 0.35.0 breaks Apple Pay on iOS because it conflicts with react-native-payments. Version 0.34.0 works but has Android keyboard overlap issues. Version 0.33.0 is stable but missing the PaymentSheet improvements you actually want. Read the release notes and changelog before upgrading.

The Integration That Actually Works

Stripe React Native Integration

Took me two months of production debugging to find a setup that actually works:

Client Layer (The Part That Breaks Most)
I'm running React Native 0.71.8 - don't upgrade to 0.72, it breaks everything. Firebase 18.5.0 is the sweet spot - 18.6+ has auth issues that'll drive you nuts. For Stripe, stick with 0.34.0 because newer versions break Apple Pay. And those real-time listeners? Yeah, you'll disable them after they crash your app.

Backend Layer (Firebase's Black Box)

  • Firebase Extensions work great until webhook endpoints randomly start returning 500 errors
  • Cloud Functions need 512MB memory minimum or they timeout during payment processing
  • Firestore security rules that look simple but break when users sign out mid-transaction

Payment Layer (Stripe's Actually Decent APIs)

  • Stripe API is solid but webhooks fail silently when your Functions crash
  • Stripe webhooks work perfectly except when Firebase cold starts add 5-second delays
  • Customer Portal redirects don't work in React Native WebViews without custom handling

Version Combinations That Don't Hate Each Other

This took way too many npm installs and several project rebuilds to figure out:

## The versions that don't hate each other
npm install @react-native-firebase/app@18.5.0
npm install @react-native-firebase/auth@18.5.0  
npm install @react-native-firebase/firestore@18.5.0
npm install @stripe/stripe-react-native@0.34.0

DO NOT upgrade anything without testing payment flows on both iOS and Android. I learned this the hard way when a "minor" Firebase 18.6.0 update broke customer creation for two days in production. Had to roll back at 2am on a Tuesday while customers were trying to pay.

Production Reality Check

Authentication Loops
Firebase Auth tokens expire during payment flows, causing infinite redirect loops. Add token refresh handling or watch your conversion rate tank when users can't complete purchases.

Webhook Failures
Stripe webhooks randomly get 500 errors from Cloud Functions during traffic spikes. Implement retry logic with exponential backoff or lose payments.

Cold Start Hell
Firebase Functions cold starts add 2-5 seconds to first payment attempts. Users think the app is broken and abandon checkout. Pre-warm functions or accept the conversion hit.

How to Actually Build This Without Breaking Everything

Firebase Cloud Functions Overview

Here's the step-by-step process that actually works in production, including the shit that will break and how to fix it when (not if) it happens.

Phase 1: Firebase Setup (This Will Take 3 Hours Minimum)

Set Up Firebase Auth (And Watch It Break)
Go to the Firebase Console and enable Email/Password authentication. Don't bother with anonymous auth - it breaks subscription continuity when users upgrade accounts. Check out the Firebase Auth best practices and security guidelines while you're at it.

The Firestore database needs these security rules, but they're more fragile than they look:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /customers/{uid} {
      // This breaks when users sign out mid-payment
      allow read, write: if request.auth != null && request.auth.uid == uid;
    }
    match /customers/{uid}/checkout_sessions/{id} {
      // Add this or webhook updates fail silently
      allow read, write: if request.auth != null && 
        (request.auth.uid == uid || resource == null);
    }
    match /customers/{uid}/subscriptions/{id} {
      // Read-only because Stripe manages these via webhooks
      allow read: if request.auth != null && request.auth.uid == uid;
    }
  }
}

Install the Firebase Extension (Prepare for Debugging Hell)
The Stripe Firebase Extension works great when it works. When it doesn't, good luck debugging Cloud Functions you can't see. Check the extension documentation and troubleshooting guide before you start.

Go to Extensions → Browse → Install "Run Payments with Stripe". You'll need:

  • Your Stripe restricted API key with these exact permissions:
    • Customers: Read, Write
    • Checkout Sessions: Read, Write
    • Customer Portal: Read, Write
    • Subscriptions: Read, Write
    • Prices: Read, Write

DO NOT use your full access key - the extension will work in development but fail security reviews. I learned this when our security audit flagged it as a critical vulnerability and I had to explain to legal why we were storing unrestricted API keys. That was a fun Monday morning meeting. Read the API key security guide and best practices before you make the same mistake.

The extension creates these Cloud Functions that will randomly timeout:

  • ext-firestore-stripe-payments-createCustomer
  • ext-firestore-stripe-payments-createCheckoutSession
  • ext-firestore-stripe-payments-handleWebhookEvents

Set memory to 512MB minimum or they'll timeout under load. I spent 3 hours one Thursday night debugging payment failures that turned out to be memory limits - the function was just running out of RAM during checkout. Took me way too long to figure out because Firebase doesn't tell you it's a memory issue, just "function execution failed". Check the Cloud Functions performance guide so you don't waste your evening like I did.

Phase 2: React Native Setup (Where Everything Breaks)

React Native Development Environment

Install Dependencies (And Pray They Work Together)

## Install these versions - seriously, don't get creative
npm install @stripe/stripe-react-native@0.34.0
npm install @react-native-firebase/app@18.5.0 
npm install @react-native-firebase/auth@18.5.0
npm install @react-native-firebase/firestore@18.5.0

## iOS setup (probably breaks on Xcode 15+)
cd ios && pod install

If pod install fails with dependency conflicts, delete Podfile.lock and your ios/build folder, then run it again. You'll do this dance at least 3 times.

Android Build Issues (Because Of Course)
Your Android build will fail with "ECONNREFUSED" errors. Add this to android/app/src/debug/res/xml/network_security_config.xml:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">10.0.2.2</domain>
        <domain includeSubdomains="true">10.0.3.2</domain>
    </domain-config>
</network-security-config>

Firebase Initialization (The Part That Randomly Fails)
Follow the setup guide, but ignore the part about automatic linking - it breaks half the time. Manual linking is more work but actually functions.

Your google-services.json and GoogleService-Info.plist files need to be in the exact right locations or Firebase will fail silently. Check the file paths 3 times.

Stripe Provider Setup (Simple But Fragile)

import { StripeProvider } from '@stripe/stripe-react-native';

export default function App() {
  return (
    <StripeProvider 
      publishableKey="pk_test_your_key_here"
      // Add these or PaymentSheet breaks on Android
      threeDSParams={{
        timeout: 5,
        uiCustomization: {}
      }}
    >
      <YourAppContent />
    </StripeProvider>
  );
}

DO NOT put your live publishable key in the code. Use environment variables or React Native Config. I've seen too many apps accidentally process real payments in development.

Phase 3: Auth Integration (Where Users Get Stuck in Loops)

Customer Creation That Actually Works
The Firebase Extension automatically creates Stripe customers when users authenticate - except when it doesn't. Here's what actually happens:

import auth from '@react-native-firebase/auth';
import firestore from '@react-native-firebase/firestore';

useEffect(() => {
  // This listener fires like 3 or 4 times on startup for some reason
  const unsubscribe = auth().onAuthStateChanged(async (user) => {
    if (user) {
      try {
        // Check if customer already exists to prevent duplicates
        const customerDoc = await firestore()
          .collection('customers')
          .doc(user.uid)
          .get();
          
        if (!customerDoc.exists) {
          // Trigger customer creation - this fails silently sometimes
          await firestore()
            .collection('customers')
            .doc(user.uid)
            .set({
              email: user.email,
              // Add this or the extension breaks
              created: firestore.FieldValue.serverTimestamp()
            });
        }
      } catch (error) {
        // This error happens when Firestore security rules are wrong
        console.log('Customer creation failed:', error);
      } 
    }
  });
  return unsubscribe;
}, []);

The Debouncing You'll Need
Without debouncing, the auth state change fires multiple times and your UI flickers:

import { debounce } from 'lodash';

const debouncedAuthHandler = debounce(async (user) => {
  if (user) {
    await initializeCustomerData(user.uid);
  }
}, 500);

useEffect(() => {
  const unsubscribe = auth().onAuthStateChanged(debouncedAuthHandler);
  return unsubscribe;
}, []);

Phase 4: Payment Processing (The Part That Randomly Fails)

Stripe Payment Elements

PaymentSheet Setup (It Will Break on Android)

import { useStripe } from '@stripe/stripe-react-native';

const { presentPaymentSheet } = useStripe();

const handlePayment = async () => {
  try {
    // Create checkout session in Firestore
    const checkoutSessionRef = await firestore()
      .collection('customers')
      .doc(user.uid)
      .collection('checkout_sessions')
      .add({
        price: 'price_your_price_id',
        // Add success_url or PaymentSheet breaks
        success_url: 'https://yourapp.com/success',
        cancel_url: 'https://yourapp.com/cancel'
      });

    // Wait for the Cloud Function to process it
    // This takes like 2-5 seconds because of cold starts
    const unsubscribe = checkoutSessionRef.onSnapshot((snap) => {
      const { sessionId } = snap.data() || {};
      if (sessionId) {
        unsubscribe();
        presentPaymentSheet({ 
          clientSecret: sessionId,
          // Add these or Android crashes
          googlePay: { merchantCountryCode: 'US' },
          applePay: { merchantCountryCode: 'US' }
        });
      }
    });
  } catch (error) {
    // Common errors:
    // - "Price not found" = wrong price ID
    // - "Customer not found" = auth token expired
    // - "Payment failed" = everything else
    console.log('Payment failed:', error);
  }
};

Webhook Debugging (When Payments Get Lost)
Stripe webhooks randomly fail with 500 errors when Cloud Functions timeout. Use the Stripe CLI to debug:

## Forward webhooks to your local dev server
stripe listen --forward-to localhost:3000/webhook

## Test webhook processing
stripe trigger payment_intent.succeeded

If webhooks keep failing, increase Cloud Function memory and add retry logic:

// In your Cloud Function (if you're writing custom ones)
exports.handleWebhook = functions
  .runWith({ memory: '512MB', timeoutSeconds: 60 })
  .https.onRequest(async (req, res) => {
    // Your webhook handling code here
  });

Phase 5: The Stuff That Breaks in Production

Subscription Access Control (Custom Claims Hell)
Firebase custom claims are great until they take 5 minutes to propagate. Users pay for subscriptions but can't access premium features:

// Check subscription status with fallback
const checkSubscriptionAccess = async () => {
  try {
    // Check custom claims first (cached)
    const idTokenResult = await auth().currentUser.getIdTokenResult(true);
    const subscriptionActive = idTokenResult.claims.subscription_status === 'active';
    
    if (!subscriptionActive) {
      // Fallback: Check Firestore directly
      const subscription = await firestore()
        .collection('customers')
        .doc(user.uid)
        .collection('subscriptions')
        .where('status', '==', 'active')
        .get();
      
      return !subscription.empty;
    }
    
    return subscriptionActive;
  } catch (error) {
    // Always fail open for better UX
    return false;
  }
};

Customer Portal Integration (WebView Nightmare)
The Customer Portal opens in WebView but redirects don't work:

import { Linking } from 'react-native';
import InAppBrowser from 'react-native-inappbrowser-reborn';

const openCustomerPortal = async () => {
  try {
    const portalRef = await firestore()
      .collection('customers')
      .doc(user.uid)
      .collection('checkout_sessions')
      .add({
        // Trigger customer portal creation
        mode: 'customer_portal',
        return_url: 'yourapp://billing'
      });

    // Use InAppBrowser instead of WebView
    await InAppBrowser.open(portal.url, {
      dismissButtonStyle: 'cancel',
      readerMode: false,
      modalPresentationStyle: 'fullScreen'
    });
  } catch (error) {
    console.log('Portal failed:', error);
  }
};

Production Monitoring (Or You'll Be Blind)
Set up actual monitoring because Stripe's dashboard doesn't show you when Firebase Extensions break:

  • Monitor Cloud Function errors in Firebase Console
  • Track payment success rates in Stripe Dashboard
  • Set up alerts for webhook failures
  • Log authentication issues to crash reporting

The integration works great when everything goes right. When it breaks, you'll need these debugging tools to figure out why payments disappear into the void.

Integration Approach Comparison

Approach

Complexity

Security

Scalability

Development Time

Maintenance

Stripe + Firebase Extension

Low complexity

High

High

2-3 weeks (more like 4)

Low maintenance (sure, until 3am)

Custom Cloud Functions

High development cost

High

High

4-6 weeks

Medium maintenance overhead

Direct Stripe Integration

Medium complexity

Medium

Medium

3-4 weeks

High maintenance requirements

Third-party Payment Aggregator

Low complexity

Medium

Medium

1-2 weeks

Medium

The Questions You'll Actually Ask While Debugging

Q

Why does Firebase Auth randomly sign out users during payment flows?

A

Firebase Auth tokens expire mid-transaction, causing authentication loops that break your payment flow.

This happens because: 1.

The default token expiration is 1 hour, but payment flows can take longer 2. iOS backgrounding sometimes invalidates tokens early 3. React Native Firebase versions around 18.6+ have auth persistence issuesFix: Use `auth().current

User.getIdToken(true)` to force token refresh before payment operations, and downgrade to RN Firebase 18.5.0.

Q

Why are my Stripe webhooks getting 500 errors from Cloud Functions?

A

Your Cloud Functions are timing out because the default 256MB memory allocation isn't enough for webhook processing. When Stripe sends webhook events during traffic spikes, Functions crash with out-of-memory errors.Fix: Increase memory allocation to 512MB minimum in the Firebase Extension configuration, or your webhook processing will randomly fail.

Q

How do I fix "Network request failed" errors that happen randomly?

A

This error means your React Native app can't reach Firebase or Stripe APIs.

Common causes:

  1. Android network security config
    • Add localhost exceptions for development
  2. iOS App Transport Security
    • Allow arbitrary loads for development
  3. Firebase project quota exceeded
    • You hit the free tier limits
  4. Stripe rate limits
    • Too many API calls in a short periodFix: Check network logs in Flipper, verify API quotas, and implement proper error handling with retry logic.
Q

Why does my app crash when users try to pay on Android?

A

The Stripe React Native SDK conflicts with other native modules, especially around keyboard handling and WebView components.

Common crashes:

  1. PaymentSheet keyboard overlap
    • Android keyboard covers payment fields
  2. Native module conflicts
    • Multiple libraries trying to handle WebViews
  3. Proguard obfuscation
    • Release builds break Stripe SDK functionalityFix: Pin Stripe SDK to version 0.34.0, add keyboard avoidance, and exclude Stripe classes from Proguard.
Q

How do I debug Firebase Extension when it stops working for no reason?

A

The Firebase Extension runs in Cloud Functions you can't directly access, making debugging absolutely miserable.

When payments stop processing:

  1. Check Cloud Functions logs
    • Look for timeout or memory errors
  2. Verify webhook endpoints
    • Test with Stripe CLI3. Validate API key permissions
    • Restricted keys might miss required scopes
  3. Monitor Firestore writes
    • See if checkout sessions are being createdFix: Use stripe listen --forward-to localhost:3000 to test webhooks locally and bypass the extension for debugging.
Q

Why do payments work in development but fail in production?

A

Production failures happen because development and production environments are completely different:

  1. Firebase project plan
    • Free tier limits break under real traffic
  2. Network latency
    • Production cold starts add 2-5 second delays
  3. Webhook endpoints
    • Development uses ngrok, production uses actual domains
  4. API rate limits
    • Stripe has different limits for live modeFix: Test with live Stripe keys in a staging environment that mirrors production resources and traffic patterns.
Q

How do I fix subscription access control that takes 5 minutes to update?

A

Firebase custom claims propagate slowly, leaving users who just paid unable to access premium features:javascript// Always implement a fallback checkconst hasAccess = async () => { // Check claims first (fast but stale) const claims = (await user.getIdTokenResult()).claims; if (claims.subscription_status === 'active') return true; // Fallback: Check Firestore directly (slower but current) const subscription = await firestore() .collection('customers') .doc(user.uid) .collection('subscriptions') .where('status', '==', 'active') .limit(1) .get(); return !subscription.empty;};

Q

Why does the Customer Portal redirect break in my React Native WebView?

A

Stripe's Customer Portal uses redirects that don't work properly in React Native WebViews. Users get stuck in the billing interface:Fix: Use react-native-inappbrowser-reborn instead of WebView to handle external redirects properly.

Q

How do I handle the Firebase Extension randomly stopping webhook processing?

A

The Firebase Extension Cloud Functions sometimes stop processing webhooks during deployments or updates, causing payments to get stuck in "processing" state:

  1. Monitor webhook delivery in Stripe Dashboard
  2. Set up alerts for webhook failures
  3. Implement manual retry for stuck payments
  4. Create backup webhook handler for critical eventsNuclear option: Disable automatic extension updates and manually test updates in staging first. I learned this after we brought down production for 4 hours when an extension auto-updated during Black Friday. Nothing else will save you.
Q

My React Native build breaks after adding Firebase - what's wrong?

A

Firebase native dependencies conflict with other libraries, especially on Android:

  1. Clean everything: rm -rf node_modules && npm install && cd ios && pod install2. Check Java versions: Firebase requires Java 11+ but your project might be on Java 83. Android Gradle conflicts: Firebase changes Gradle versions that break other plugins
  2. iOS Podfile conflicts: Firebase pods conflict with other native modulesFix: Pin exact versions of everything and test builds on clean machines regularly.
Q

How do I debug payments that disappear into the void?

A

When payments are charged in Stripe but don't update in your app:

  1. Check webhook logs
    • Were webhooks delivered successfully?2. Verify Firestore writes
    • Did webhook handlers update payment documents?3. Test authentication
    • Can webhooks write to Firestore with service account auth?4. Monitor real-time listeners
    • Are client listeners receiving updates?Debug command: stripe logs tail to see live webhook delivery attempts. I spent a whole Saturday morning staring at these logs trying to figure out why webhooks were delivering but payments weren't updating
  • turned out the Firestore security rules were blocking the writes. The logs showed success but Firestore was silently failing. Would've saved me 4 hours if Firebase actually logged the security rule failures instead of just pretending everything was fine.

Essential Resources and Documentation

Related Tools & Recommendations

compare
Similar content

Stripe vs Adyen vs Square AI: Real Payment Processing Features

After 3 Years of Payment Processor Hell, Here's What AI Features Don't Suck

Stripe
/compare/stripe/adyen/square/paypal/checkout-com/braintree/ai-automation-features-2025
100%
tool
Similar content

Stripe Terminal React Native SDK: Overview, Features & Implementation

Dive into the Stripe Terminal React Native SDK. Discover its capabilities, explore real-world implementation insights, and find solutions for building robust pa

Stripe Terminal React Native SDK
/tool/stripe-terminal-react-native-sdk/overview
82%
compare
Similar content

Flutter vs React Native vs Kotlin Multiplatform: Choose Your Framework

The Real Question: Which Framework Actually Ships Apps Without Breaking?

Flutter
/compare/flutter-react-native-kotlin-multiplatform/cross-platform-framework-comparison
78%
integration
Similar content

Firebase Flutter Production: Build Robust Apps Without Losing Sanity

Real-world production deployment that actually works (and won't bankrupt you)

Firebase
/integration/firebase-flutter/production-deployment-architecture
75%
compare
Similar content

Stripe, Adyen, Square, PayPal, Checkout.com: Processor Battle

Five payment processors that each break in spectacular ways when you need them most

Stripe
/compare/stripe/adyen/square/paypal/checkout-com/payment-processor-battle
58%
tool
Similar content

Firebase - Google's Backend Service for Serverless Development

Skip the infrastructure headaches - Firebase handles your database, auth, and hosting so you can actually build features instead of babysitting servers

Firebase
/tool/firebase/overview
52%
pricing
Similar content

Backend Pricing Reality Check: Supabase vs Firebase vs AWS Amplify

Got burned by a Firebase bill that went from like $40 to $800+ after Reddit hug of death. Firebase real-time listeners leak memory if you don't unsubscribe prop

Supabase
/pricing/supabase-firebase-amplify-cost-comparison/comprehensive-pricing-breakdown
49%
tool
Similar content

Checkout.com: Enterprise Payments for High-Volume Businesses

Built for enterprise scale - when Stripe and PayPal aren't enough

Checkout.com
/tool/checkout-com/enterprise-payment-powerhouse
45%
compare
Recommended

Python vs JavaScript vs Go vs Rust - Production Reality Check

What Actually Happens When You Ship Code With These Languages

python
/compare/python-javascript-go-rust/production-reality-check
45%
compare
Similar content

Stripe, Plaid, Dwolla, Yodlee: Unbiased Fintech API Comparison

Comparing: Stripe | Plaid | Dwolla | Yodlee

Stripe
/compare/stripe/plaid/dwolla/yodlee/payment-ecosystem-showdown
45%
integration
Similar content

Supabase + Next.js + Stripe Auth & Payments: The Least Broken Way

The least broken way to handle auth and payments (until it isn't)

Supabase
/integration/supabase-nextjs-stripe-authentication/customer-auth-payment-flow
43%
tool
Recommended

Node.js ESM Migration - Stop Writing 2018 Code Like It's Still Cool

How to migrate from CommonJS to ESM without your production apps shitting the bed

Node.js
/tool/node.js/modern-javascript-migration
37%
compare
Similar content

Stripe vs Plaid vs Dwolla - The 3AM Production Reality Check

Comparing a race car, a telescope, and a forklift - which one moves money?

Stripe
/compare/stripe/plaid/dwolla/production-reality-check
37%
integration
Similar content

Stripe Plaid Integration: KYC & Identity Verification to Stop Fraud

KYC setup that catches fraud single vendors miss

Stripe
/integration/stripe-plaid/identity-verification-kyc
36%
pricing
Recommended

How These Database Platforms Will Fuck Your Budget

alternative to MongoDB Atlas

MongoDB Atlas
/pricing/mongodb-atlas-vs-planetscale-vs-supabase/total-cost-comparison
36%
tool
Similar content

Supabase Overview: PostgreSQL with Bells & Whistles

Explore Supabase, the open-source Firebase alternative powered by PostgreSQL. Understand its architecture, features, and how it compares to Firebase for your ba

Supabase
/tool/supabase/overview
35%
tool
Recommended

Fix Flutter Performance Issues That Actually Matter in Production

Stop guessing why your app is slow. Debug frame drops, memory leaks, and rebuild hell with tools that work.

Flutter
/tool/flutter/performance-optimization
33%
pricing
Similar content

Supabase, Firebase, PlanetScale: Cut Database Costs from $2300 to $980

Learn how to drastically reduce your database expenses with expert cost optimization strategies for Supabase, Firebase, and PlanetScale. Cut your bill from $230

Supabase
/pricing/supabase-firebase-planetscale-comparison/cost-optimization-strategies
32%
tool
Recommended

MongoDB Atlas Enterprise Deployment Guide

built on MongoDB Atlas

MongoDB Atlas
/tool/mongodb-atlas/enterprise-deployment
31%
tool
Similar content

Stripe Overview: Payment Processing & API Ecosystem Guide

Finally, a payment platform that won't make you want to throw your laptop out the window when debugging webhooks at 3am

Stripe
/tool/stripe/overview
30%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization