Deishelon / google-play-billing-validator

Npm module for Node.js to validate In-app purchases and Subscriptions on your backend
https://medium.com/androidhub/how-to-validate-in-app-purchase-subscription-on-your-node-js-backend-a2b823470034
90 stars 32 forks source link

Firebase function deploy error ! #23

Open khalifa007 opened 3 years ago

khalifa007 commented 3 years ago

Description

Everything works but when I upload my function to firebase functions it gives me an error

Steps to Reproduce

  1. I tried to Reproduce but the same it gives me an error but if I didn't import var Verifier = require('google-play-billing-validator'); the function will be uploaded .

    Sample code

exports.buycoins = functions.https.onCall(async (data, context) => {
  const productID = data['productID'];
  const token = data['token'];
  const packageName = "";
  const user_id = data['uid'];

  const options = {
      "email": '',
      "key": ''
  };
  var verifier = new Verifier(options);

  let receipt = {
      packageName: packageName,
      productId: productID,
      purchaseToken: token
  };

  }
  let promiseData = verifier.verifyINAPP(receipt).then(async (response)=> {
          if(response['isSuccessful'] == true){
return true;

          }else{
              return false;
          }

      })
      .catch(function (error) {
          return false;

      });

    });

Images :

Capture Capture

Actual behavior:

[What actually happened]

Versions

You can get this information from executing npm version.

{
  npm: '6.14.14',
  ares: '1.17.2',

  brotli: '1.0.9',
  cldr: '39.0',
  icu: '69.1',
  llhttp: '2.1.3',
  modules: '83',
  napi: '8',
  nghttp2: '1.42.0',
  node: '14.17.5',
  openssl: '1.1.1k',
  tz: '2021a',
  unicode: '13.0',
  uv: '1.41.0',
  v8: '8.4.371.23-node.76',
  zlib: '1.2.11'
}
khalifa007 commented 3 years ago

This issue is fixed. I should install pkg inside the function folder, not in the main folder.