Skip to content

Commit

Permalink
fix: use correct RTDB instance in create-customer route
Browse files Browse the repository at this point in the history
Co-Authored-By: WeWrite <getwewrite@gmail.com>
  • Loading branch information
devin-ai-integration[bot] and getwewrite committed Dec 25, 2024
1 parent 7a08cb8 commit aa469cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/api/payments/create-customer/route.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NextResponse } from 'next/server';
import Stripe from 'stripe';
import { getDatabase } from '@/firebase/database';
import { getRTDB } from '@/firebase/rtdb';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const db = getDatabase();
const db = getRTDB();

export async function POST(request) {
try {
Expand All @@ -26,10 +26,13 @@ export async function POST(request) {
});

// Update user record with Stripe customer ID
await db.ref(`users/${userId}`).update({
const userRef = db.ref(`users/${userId}`);
await userRef.update({
stripeCustomerId: customer.id,
});

console.log('Successfully created Stripe customer:', customer.id, 'for user:', userId);

return NextResponse.json({
customerId: customer.id
});
Expand Down

0 comments on commit aa469cc

Please sign in to comment.