0

I am trying to listen to the invoice.paid event triggered by the Stripe Payments extension, and I'm following this documentation, trying to adapt examples to the fact all my code is in TypeScript. Another thing is that I deployed the extension to a region that's different from the default us-central1 so that my extensions are hosted in the EU, just like my cloud functions.

So here is what my firestore-stripe-payments.env looks like:

ALLOWED_EVENT_TYPES=com.stripe.v1.invoice.paid,com.stripe.v1.invoice.payment_succeeded,com.stripe.v1.invoice.payment_failed,com.stripe.v1.invoice.upcoming
CREATE_CHECKOUT_SESSION_MIN_INSTANCES=0
CUSTOMERS_COLLECTION=users
DELETE_STRIPE_CUSTOMERS=Do not delete
EVENTARC_CHANNEL=projects/${param:PROJECT_ID}/locations/europe-west4/channels/firebase
LOCATION=europe-west1
PRODUCTS_COLLECTION=products
STRIPE_API_KEY=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_API_KEY/versions/latest
STRIPE_CONFIG_COLLECTION=configuration
STRIPE_WEBHOOK_SECRET=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_WEBHOOK_SECRET/versions/latest
SYNC_USERS_ON_CREATE=Sync

Then in my index.ts, I have the following to try and subscribe the invoice.paid event:

import {onCustomEventPublished} from "firebase-functions/v2/eventarc";

export const onInvoicePaid = onCustomEventPublished(
    {
      eventType: "com.stripe.v1.invoice.paid",
      channel: "projects/[MY_PROJECT_ID]/locations/europe-west4/channels/firebase",
      region: "europe-west4",
    },
    (event) => {
      functions.logger.debug(`[onInvoicePaid] Received event: ${JSON.stringify(event)}`);
      return null;
    });

But even though it is successfully deployed, this function is never called, as evidenced by the fact that the Stripe Payment extension itself logs that it successfully processed an invoice.paid event, but the log in onInvoicePaid does not show up in the logs.

I updated all the NPM dependencies of my Cloud Functions so I'm using firebase-admin version 11.7.0 and firebase-functions 4.3.1.

I feel like I'm making a mistake somewhere and my event ends up in a black hole. What is the right way to do this?

Sebastien
  • 3,583
  • 4
  • 43
  • 82

1 Answers1

-2

But even though it is successfully deployed, this function is never called

Then double-check the event routine configuration, either through console, or gcloud CLI.

For instance, make sure you did enable the Cloud Logging, Eventarc, and Eventarc Publishing APIs.

gcloud services enable logging.googleapis.com \
  eventarc.googleapis.com \
  eventarcpublishing.googleapis.com

And make sure the API related to the direct events is enabled.
For example, for Cloud Functions events, enable cloudfunctions.googleapis.com.

Double-check your service account has the Identity and Access Management (IAM) roles or permissions for authenticated or unauthenticated invocations.


Try also to align the LOCATION as and the EVENTARC_CHANNEL location as in your firestore-stripe-payments.env file. Change LOCATION to europe-west4.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250