invertase / stripe-firebase-extensions

Repository of Firebase Extensions built by Stripe.
https://firebase.google.com/products/extensions
Apache License 2.0
435 stars 164 forks source link

Error: No such customer: 'cus_....' #612

Open insivika opened 7 months ago

insivika commented 7 months ago

Bug report

firestore-stripe-payments

Describe the bug

I followed the instructions on how to set up and intigrate the extension with my firebase instance. I was able to add the product and see it being created in the firebase database which tells me the integration was successful. However when I make a request to create a check out session I get the following error:

No such customer: 'cus_PaXYUcDLJWD3Lo

What's odd is that I dont see any customer created on the stripe dashboard so I'm not even sure how it knows about his customer id.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Below is my code, I've set up a controller that returns the url via a rest request:

import { Users } from '../firebase.js';

export const createCheckoutUrl = async ({ userId, priceId, successUrl, cancelUrl }) => {
  return new Promise((resolve, reject) => {
    Users.doc(userId) // Use the provided userId instead of currentUser.uid
      .collection('checkout_sessions')
      .add({
        price: priceId,
        success_url: successUrl,
        cancel_url: cancelUrl,
      })
      .then((docRef) => {
        // Wait for the CheckoutSession to get attached by the extension
        const checkoutSessionListener = docRef.onSnapshot((snap) => {
          const { error, url } = snap.data();
          if (error) {
            // Show an error to your customer and
            // inspect your Cloud Function logs in the Firebase console.
            console.log(`An error occurred: ${error.message}`);
            reject(new Error(`An error occurred: ${error.message}`));
          }
          if (url) {
            console.log('url ==>', url);
            // Resolve the promise with the URL if available
            resolve(url);
            // Stop listening to further changes
            checkoutSessionListener();
          }
        });
      })
      .catch((error) => {
        // Handle any errors occurred during the process
        console.log(error);
        reject(error);
      });
  });
};

Expected behavior

I expect to get the url from the created session

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

I was successfully able to get sessions using the official stripe extension.

Bkdeets commented 4 months ago

Hey any update on this issue? Experiencing the same problem