Firebase Function Deployment for Stripe

I’m working on a project using Firebase Functions with Stripe. Following these docs: https://docs.stripe.com/identity/verification-sessions

I keep getting this error when I deploy the function:

i functions: updating Node.js 18 (2nd Gen) function createVerificationSession(us-??>central1)…
Could not create or update Cloud Run service createverificationsession, Container >Healthcheck failed. Revision ‘createverificationsession-00014-jow’ is not ready and >cannot serve traffic. The user-provided container failed to start and listen on the port >defined provided by the PORT=8080 environment variable. Logs for this revision might >contain more information.

I check out the logs and see a few things:

{
  "textPayload": "    StripeInvalidGrantError: [class StripeInvalidGrantError extends StripeError],",
  "insertId": "663fc892000d43eabf84f867",
  [...]
  "logName": "projects/lectio-c2268/logs/run.googleapis.com%2Fstdout",
  "receiveTimestamp": "2024-05-11T19:35:47.208375619Z"
}
{
  "textPayload": "Default STARTUP TCP probe failed 1 time consecutively for container "worker" on port 8080. The instance was not started.",
  "insertId": "663fc893000cef0fae764d6a",
  [...]
}

Here’s the firebase function in question:

const { onCall } = require('firebase-functions/v2/https');
const { error } = require('firebase-functions/logger');
import admin = require('firebase-admin');const functions = require('firebase-functions');
const stripe = require('stripe')(
'sk_test_51O7T...',
);

[...]

exports.createVerificationSession = onCall(async (data: any, context: any) => {
  const verificationSession = await stripe.identity.verificationSessions.create(
    {
      type: 'document',
      metadata: {
        user_id: context.auth.uid,
      },
    },
  );
  const clientSecret = verificationSession.client_secret;
  console.log('Client secret:', clientSecret);
  return { clientSecret };
});

And here’s how i call it in the front end:

const stripePromise = loadStripe(
'pk_live_51O7...',
); 

function Payment() {
  const [clientSecret, setClientSecret] = useState('');

  useEffect(() => {
    const fetchClientSecret = async () => {
      console.log('Fetching client secret');
      const functions = getFunctions();
      const createVerificationSession = httpsCallable(
        functions,
        'createVerificationSession',
      );

      try {
        console.log('Calling createVerificationSession');
        await createVerificationSession().then((result) => {
          console.log('Result:', result);
        });
        // setClientSecret(response.data.clientSecret);
      } catch (error) {
        console.error('Failed to fetch client secret:', error);
        // Handle errors here appropriately
      }
    };

    fetchClientSecret();
  }, []);

  if (!stripePromise || !clientSecret) {
    return <p>Loading payment details...</p>;
  }

  const options = {
    clientSecret: clientSecret,
  };

  return (
    <Elements stripe={stripePromise} options={options}>
      <CheckoutForm />
    </Elements>
  );
}

export default Payment;

I am running on localhost:5173 with firebase emulators

{
  "functions": {
    "source": "../../functions",
    "predeploy": [
      "npm --prefix "$RESOURCE_DIR" run lint",
      "npm --prefix "$RESOURCE_DIR" run build"
    ]
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "emulators": {
    "auth": {
      "port": 9099
    },
    "firestore": {
      "port": 8080
    },
    "functions": {
      "port": 5001
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true
  }
}

I am totally stumped about how to debug this! Any guidance would be super appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật