firebasegoogle-cloud-functionsgoogle-play-developer-apiplay-billing-library

ClassyTaxiServer with Server error: Cannot read property 'get' of undefined


I'm implementing the ClassyTaxiAppKotlin + ClassyTaxiServer project but without success.

I followed all the steps in the tutorial.

Apparently the ClassyTaxiAppKotlin android app is functional, processes the subscription purchase order and sends the information to the CLOUD FUNCTIONS, but does not receive the purchase registration/confirmation.

In my understanding, upon receiving the payment confirmation, PLAY STORE must send this confirmation to the ClassyTaxiServer server so that the server returns the registration/confirmation of the purchase and grants access to the ClassyTaxiAppKotlin application.

So when confirming payment in ClassyTaxiAppKotlin app, I notice that I get some logs in firebase functions from (instanceId_register_v2, realtime_notification_listener AND subscription_register_v2), but the registration/confirmation of payment doesn't complete due to a server error (500) and doesn't release the access in the ClassyTaxiAppKotlin app.

Note: service-account.json is already configured

Does anyone have any idea why this error is occurring and indicate how I can solve it?

Code where the error points:

   private async querySubscriptionPurchaseWithTriggerV2(packageName: string, product: string, purchaseToken: string, triggerNotificationType?: NotificationType): Promise<SubscriptionPurchaseV2> {
     // STEP 1. Query Play Developer API to verify the purchase token
     const apiResponseV2 = await new Promise((resolve, reject) => {
       this.playDeveloperApiClient.purchases.subscriptionsv2.get({ // <<=== Server error: Cannot read property 'get' of undefined
         packageName: packageName,
         token: purchaseToken
       }, (err, result) => {
         if (err) {
           reject(this.convertPlayAPIErrorToLibraryError(err));
         } else {
           resolve(result.data);
         }
       })
     });

LOGS Firebase Functions

6:55:28.798 PM instanceId_register_v2 Function execution started
6:55:31.025 PM instanceId_register_v2 Instance id is ddR1Hi...NOO2Z
6:55:31.122 PM instanceId_register_v2 Instance Id specified and verified
6:55:31.122 PM instanceId_register_v2 Instance verification passed
6:55:31.774 PM instanceId_register_v2 Function execution took 2976 ms, finished with status code: 200

6:55:53.623 PM realtime_notification_listener ========> purchase: null PACKAGE_NAME: com.example.subscriptions
6:55:53.624 PM realtime_notification_listener Function execution took 5 ms, finished with status: 'ok'

6:55:57.537 PM subscription_register_v2 Function execution started
6:55:59.817 PM subscription_register_v2 Server error: Cannot read property 'get' of undefined
6:55:59.825 PM subscription_register_v2 Function execution took 2289 ms, finished with status code: 500

LOGS Android Studio

D/OkHttp: --> PUT https://us-central1-postosgnv.cloudfunctions.net/subscription_register_v2 http/1.1 (437-byte body)
D/OkHttp: <-- 500  https://us-central1-postosgnv.cloudfunctions.net/subscription_register_v2 (2661ms, 86-byte body)
E/RemoteServerFunction: Failed to call API (Error code: 500) - {"status":500,"error":"not-found","message":"Cannot read property 'get' of undefined"}

Solution

  • As per the answer found HERE, the issue was solved by updating the GoogleApis package in the package.json from "googleapis": "^67.0.0" -> "googleapis": "105.0.0"