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

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

Open jaredgibb opened 2 years ago

jaredgibb commented 2 years ago

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

jaredgibb commented 2 years ago

as a follow up here the purchases have not been acknowledged. When i use the call without developerPayload in the receipt object, i receive this same looking object each time


{
  "isSuccessful": boolean ,
    "errorMessage": false,
    "payload": {
        {
            "kind": "androidpublisher#subscriptionPurchase",
            "startTimeMillis": 16488056975169,
            "expiryTimeMillis": 16488056975169,
            "autoRenewing": false,
            "priceCurrencyCode": USD,
            "priceAmountMicros": 990000,
            "countryCode": US,
            "developerPayload": "",
            "cancelReason": 0,
            "userCancellationTimeMillis": 1653789734543,
            "orderId": GPA.3303-2342-2342-2342,
            "purchaseType": 0,
                         "acknowledgementState:0,
            "kind": "androidpublisher#subscriptionPurchase"
        }
    }
}
thearchitectxy commented 1 year ago

@jaredgibb hi did you ever solve it ?

sandesh-bhoir commented 11 months ago

@thearchitectxy @jaredgibb were you ble to fix this.. I'm stuck up at the same point, validate is working fine but acknowledge giving below response.


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