Giter Club home page Giter Club logo

google-play-billing-validator's People

Contributors

deishelon avatar hvaddi9 avatar peterzeller avatar unpollito avatar yogibear52 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

google-play-billing-validator's Issues

Error while acknowledging purchase

I'm getting this error while acknowledging the purchase, but this issue is only there for purchase not with the subscription,

Please help me to solve this issue, till last month it was working,

{
  isSuccessful: false,
  errorCode: 400,
  errorMessage: 'Invalid response, please check ' +
    "'Verifier' configuration or the " +
    'statusCode above'
}

Sample code

        let receipt = {
            packageName: packageName,
            productId: productId,
            purchaseToken: purchaseToken,
            developerPayload: 'Acknowledged Purchase Successfully'
        };
        console.log(receipt);

        verifier.verifySub(receipt).then(result => {
            console.log(result);
        }).catch(err => {
            console.log(err);
            reject('err')
        });

Getting 503 error when doing the verify subscription

When I using verifier.verifySub(receipt), which correct data in receipt

let receipt = {
  packageName: "com.app.xxx.xxx",
  productId: "xxx_subscription",
  purchaseToken: "<token>"
};

Response

{
  isSuccessful: false,
  errorCode: 503,
  errorMessage: 'An internal error occurred.'
}

Firebase function deploy error !

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'
}

How to get productId and quantity?

Description

[Description of the bug]

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Sample code

// Include some code to help understand your context :)

Expected behavior:

[What you expected to happen]

Actual behavior:

[What actually happened]

Versions

You can get this information from executing npm version.

Support retry for API errors

Description

According to Google API docs, response code 5xx means that we should retry the validation. It would be great to have optional retry settings for the module, so it automatically retries in such cases.

Steps to Reproduce

  1. try to validate using verifySub, for example
  2. simulate 502 Bad Gateway error in code
  3. observe that, currently, the clients do not have any information whether the error was retriable, and the module will not retry the request

Sample code

N/A

Expected behavior:

// I expect the following method would retry in case of retriable 5xx errors, see promise-retry npm for example settings:
verifySub(token, { retries: 5 })

Actual behavior:

no retry is currently supported

Versions

2.0.3

What licence is this package under?

Hey there,

I'm just evaluating IAP packages and came across this one, it looks good but I don't see the licence type mentioned anywhere. Any plans on adding an OSS licence to it?

thanks!

Just want to say thanks for this project. I'm using it and appreciate it.

Error 401 - insufficient permissions

I've set up a service account and linked it to Google Play, granted all the permissions including "View financial data" under "API Access" page.

{
    "isSuccessful": false,
    "errorCode": 401,
    "errorMessage": "The current user has insufficient permissions to perform the requested operation."
}

When I am trying to verify a purchase, it throws error 401 even though I been waiting 24 hours maybe until Google servers update.
When I call this get API with OAuth2 token, it works so the account has the permissions:
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.my.package/purchases/products/<productId>/tokens/<purchaseToken>

Relevant code:

const Verifier = require("google-play-billing-validator");

const gpOptions = {
  email: gAccount.client_email,
  key: gAccount.private_key,
};

const verifier = new Verifier(gpOptions);

app.post("/verify", async (req, res) => {
  const { productId, purchaseToken } = req.body;
  verifier
    .verifyINAPP({
      productId,
      purchaseToken,
      packageName: "com.my.package",
    })
    .then((res) => res.status(200).json({ res }))
    .catch((error) => {
      res.status(500).send({
        success: false,
        error,
      });
    });
});

permissions

Failing, but an empty error message...

I've gone through and followed the guide, setting it up as close to outlined as possible. I've verified I'm checking a subscription with the proper parameters from the initial purchase receipt.

I'm receiving a response of
"error": { "isSuccessful": false, "errorMessage": { "inner": {} } }

The only thing that threw me off slightly was the private key. In the downloaded copy of the key I'm seeing newline characters, '\n', throughout. I've attempted validating the receipt with and without the newline characters, but both have given me the same response.

I also went through the Developer Console and confirmed "Users with access" included my newly created key's email. In the API Access my email is listed under Service Accounts, and the Finance role has been assigned to it.

Any guidance would be very much appreciated!

verify Subscriptions - sometimes works, sometimes get Error: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.

So, this only happens sometimes. Sometimes, I get a response, and the purchase was validated, sometimes, it does not validate, and I get this error:

Error: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.

Is there some sort of expiration date? I don't know why I only get this error some of the time, when I am in testing. Thanks!

reason: "Unsuported"

Description

I'm getting this

{"isSuccessful":false,"errorMessage":{"inner":{"library":"DECODER routines","reason":"unsupported","code":"ERR_OSSL_UNSUPPORTED"}}}

repeatedly receiving this during testing: Invalid response, please check 'Verifier' configuration or the statusCode above

Description

during testing, when acknowledging a subscription recently purchased then cancelled, i receive this
{"errorMessage":"Invalid response, please check 'Verifier' configuration or the statusCode above","errorCode":400,"isSuccessful":false}

Steps to Reproduce

  1. Make a purchase of a subscription
  2. acknowledge the subscription
  3. cancel the item in app
  4. repurchase the subscription

Sample code

exports.googlePlayBillingValidator = functions.https.onRequest((request, response) => {
 
  // capture the data from the request
  const {purchaseObject, subscriptionID, type} = request.body;
  console.log(subscriptionID, type);
  // inclue your app bundle id
  const bundleID = "edu.fit.my.jgibb2018.pob";
  // require the service account info
  const googleServiceAccountKey = require("./pc-api-6835501382478242417-177-5781829bedc5.json"); // see docs on how to generate a service account
  // require the verify module
  const Verifier = require("google-play-billing-validator");
  // create verifier opitons object
  const options = {
    "email": googleServiceAccountKey.client_email,
    "key": googleServiceAccountKey.private_key,
  };
  // create a new verifier instance
  const verifier = new Verifier(options);
  // create a receipt object
  const receipt = {
    packageName: bundleID,
    productId: purchaseObject.productId,
    purchaseToken: purchaseObject.purchaseToken,

  };
  if (type.includes("subscriptionAcknowledge")) {
    // add the following string to the receipt object `developerPayload: "some unique identifier",`
    receipt.developerPayload = "some unique identifier";
  }
  // acknowledge the receipt
  const promiseData = verifier.verifySub(receipt);

  promiseData.then(function(r) {
    response.send(r);
  })
      .catch(function(error) {
        functions.logger.error(error);
        response.send(error);
      });
});

Expected behavior:

i should be able to acknowledge the purchase.

Actual behavior:

i am receiving errors

Versions

2.1.3

Uncaught SyntaxError: Unexpected token N in JSON at position 0

Description

When calling verifySub with an invalid token, google returns 404 error, but the verify function which calls request() does not receive any error in the response callback - only a 404 return code and a "Not Found" text in the body parameter. This, in turn, causes the exception because "Not Found" is not a valid JSON

Steps to Reproduce

  1. Perform verifySub using a valid package ID and product ID, but an empty string as token
  2. Observe the call issues the above error

Sample code

opts = { email:"xxx", key:"yyy" }; const GooglePurchaseVerifier = require('google-play-billing-validator'); verifier = new GooglePurchaseVerifier(opts); receipt = { packageName: "pppp", productId: "product1ppppp", purchaseToken: "" }; verifier.verifySub(receipt);

Expected behavior:

The verifySub method should fail gracefully

Actual behavior:

The verifySub throws an uncaught exception

Versions

node 8.1.0
npm 6.1.0
google-play-billing-validator: 2.0.2

Method: purchases.subscriptionsv2.get

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/google-play-billing-validator/index.js b/node_modules/google-play-billing-validator/index.js
index ccc86bf..6a149ae 100644
--- a/node_modules/google-play-billing-validator/index.js
+++ b/node_modules/google-play-billing-validator/index.js
@@ -34,7 +34,7 @@ Verifier.prototype.verifySub = function (receipt) {
   this.options.body = "";
   this.options.json = false;
   
-  let urlPattern = "https://www.googleapis.com/androidpublisher/v3/applications/%s/purchases/subscriptions/%s/tokens/%s";
+  let urlPattern = "https://androidpublisher.googleapis.com/androidpublisher/v3/applications/%s/purchases/subscriptionsv2/tokens/%s";
   if ("developerPayload" in receipt) {
     urlPattern += ":acknowledge";
     this.options.body = {
@@ -43,7 +43,7 @@ Verifier.prototype.verifySub = function (receipt) {
     this.options.method = 'post';
     this.options.json = true;
   }
-  let finalUrl = util.format(urlPattern, encodeURIComponent(receipt.packageName), encodeURIComponent(receipt.productId), encodeURIComponent(receipt.purchaseToken));
+  let finalUrl = util.format(urlPattern, encodeURIComponent(receipt.packageName), encodeURIComponent(receipt.purchaseToken));
   
   return this.verify(finalUrl)
 };

This issue body was partially generated by patch-package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.