最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google cloud functions - Firebase gen2: unkown trigger despite successful deployment - Stack Overflow

programmeradmin1浏览0评论

I made a firebase function and defined a pub/sub trigger: google_play_purchase_handler.py:

        @pubsub_fn.on_message_published(topic=GOOGLE_PLAY_PUBSUB_TOPIC, region=REGION)
    async def handle_server_event(self, event: pubsub_fn.CloudEvent[pubsub_fn.MessagePublishedData]):
        try:
            event = json.loads(event.data.message.decode("utf-8"))
        except json.JSONDecodeError as e:
            logging.error(f"Could not parse Google Play billing event: {e}")
            return

        purchase_token = event.get("subscriptionNotification", {}).get("purchaseToken") or \
                         event.get("oneTimeProductNotification", {}).get("purchaseToken")
        product_id = event.get("subscriptionNotification", {}).get("subscriptionId") or \
                     event.get("oneTimeProductNotification", {}).get("sku")

        product_data = product_data_map.get(product_id)
        if not product_data:
            return

        if product_data["type"] == "SUBSCRIPTION":
            await self.handle_subscription(None, product_data, purchase_token)
        elif product_data["type"] == "NON_SUBSCRIPTION":
            await self.handle_non_subscription(None, product_data, purchase_token)


        .....

In main.py:

from google_play_purchase_handler import GooglePlayPurchaseHandler
handle_google_server_event = GooglePlayPurchaseHandler.handle_server_event

i ran firebase deploy and it was successful.

However when I checked in the Firebase console, it says the trigger is unknown:

I created the pub/sub topic on google cloud, set the proper permissions to the topic and added it in Google Play(at monetization setup option).

发布评论

评论列表(0)

  1. 暂无评论