voltrue2 / in-app-purchase

A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
http://iap.gracenode.org
Other
1.04k stars 287 forks source link

missing package name (google play) #301

Open fitmax-project opened 4 years ago

fitmax-project commented 4 years ago

hey. i am trying to validate iap for subscription product on google play. but i am getting Error: Missing Package Name my edited recipe look like that:

const editedRes = JSON.parse('' + transactionReceipt + '');

    const googleOrder = {
      packageName: editedRes.packageName,
      productId: editedRes.productId,
      purchaseToken: editedRes.purchaseToken,
      subscription: true // if the receipt is a subscription, then true
    };
    const recipt = {
      data: googleOrder,
      signature:
        '<my-google-play-Licensing-&-in-app-billing>'
    };

my iap settings:


  googleServiceAccount: {
    clientEmail:
      'xxxxxxxxxxxxxxxxxx,
    privateKey:
      'xxxxxxxxxxxxxxxxxx'
  },

  /* Configurations for Google Play */
  googlePublicKeyStrSandBox:  'xxxxxxxxxxxxxxxxxx, // this is the google iap-sandbox public key string
  googlePublicKeyStrLive: 'xxxxxxxxxxxxxxxxxx', // this is the google iap-live public key string
  googleAccToken:  'xxxxxxxxxxxxxxxxxx, // optional, for Google Play subscriptions
  googleRefToken: 'xxxxxxxxxxxxxxxxxx', // optional, for Google Play subscritions
  googleClientID: 'xxxxxx, // optional, for Google Play subscriptions
  googleClientSecret: 'xxxxxx', // optional, for Google Play subscriptions
  verbose: true,
  test: true

means - all is set...

any idea what could go wrong??

btw - signature prop and googlePublicKeyStrLive are same, isnt? p.s apple works great

bushev commented 3 years ago

Hey @fitmax-project!

Same here, did you able to find a solution?

ivanviskovic commented 3 years ago

I called validate app like this:

data = <JSON> 

iap.validate({
  data: receipt,
  signature
})

and i got the same error: {"error":{},"status":1,"message":"Missing Package Name"}

After looking through the code of the module i found that the validate function should be called a bit differently:

receipt.signature = signature;
iap.validate(receipt)

It looks like that it's using different parameters if the googleServiceAccount is provided in config

famictech2000 commented 3 years ago

Can you please let me know where you were able to get the following info:

googleServiceAccount: { clientEmail: 'xxxxxxxxxxxxxxxxxx, privateKey: 'xxxxxxxxxxxxxxxxxx' },

Where is the google Service account located!?

/ Configurations for Google Play / googlePublicKeyStrSandBox: 'xxxxxxxxxxxxxxxxxx, // this is the google iap-sandbox public key string googlePublicKeyStrLive: 'xxxxxxxxxxxxxxxxxx', // this is the google iap-live public key string

I am able to get the STRLive from play console, where can i get the sandbox?!