AlexDisler / cordova-plugin-inapppurchase

A lightweight cordova plugin for in app purchases on iOS/Android
316 stars 191 forks source link

Error retrieving SKU details - Ionic 2 #87

Open philipphalder opened 7 years ago

philipphalder commented 7 years ago

Hello, the first time i purchased an item everything worked fine. and from now one i still get this error.

Your code / steps to reproduce

  buyItem(productID: string){
    setTimeout(function() {
      InAppPurchase
        .getProducts([productID])
        .then(function (products) {
            console.log(products)

                InAppPurchase
                .buy(productID)
                .then((products) => {
                  console.log(products)
                  })
                .then((res) => {
                  // Unlock item on my server
                })
                .catch(function (err) {
                  console.log(err)
              });

        })
        .catch(function (err) {
           //Error retrieving SKU details !!  
        });  
    }, 500);
  }

Console output

Error retrieving SKU details

Type of product you are working with consumable/non-consumable/subscription

non-consumable

Version of cordova

6.4.0 I'm using this plugin with Ionic 2.1.8

Version of iOS/Android

Android 5.1.1

nunomsh commented 7 years ago

Is the app publish in playstore? You must publish the app, in beta or alpha. Have you changed the version? If you publish version 1.0.0 in playstore, only this version will work. If update to 1.2.0, you need to submit this new version. Have you update Android sdk? I had the same issue, try to remove platform, all the other plugins, checking play.services version, nothing worked. I manage to get it working again removing and install again some SDK packages in Android SDK manager: Android Support Repository Android Support Library Google Play Services Google Repository Google Play Billing Library

I'm using cordova 6.3.1 (downgrade from 6.4 because some issues with Ionic resources)

philipphalder commented 7 years ago

Hi @nunomsh thank you i'll test it tomorrow - and let you know if it works.

cristian-milea commented 7 years ago

i'm having the same problem. will test now with the version number question: if i publish the app in beta and then run my app with local development (ex: ionic run android --device) will my products load? i have only 2 items set on google, same version number 1.0.2 and i get

Error retrieving SKU details

thanks

cristian-milea commented 7 years ago

i found my problem. forgot to add in manifest.json { "play_store_key": "<Base64-encoded public key from the Google Play Store>" }

speedfl commented 7 years ago

I have the same issue. I am trying with statics android.test.purchased The first buy worked and now I am getting this error

philipphalder commented 7 years ago

You need to consume the product after purchasing.

InAppPurchase
      .buy(productID)
      .then((data) => {
           return InAppPurchase.consume(data.productType, data.receipt, data.signature);
    })
speedfl commented 7 years ago

Ok. So as i did the issue how can i consume this fake product? For information I tried as well with the android.test.item_unavailable and android.test.canceled and nothing work. :)

speedfl commented 7 years ago

So I found a solution by doing a restorePurchaseBefore. It worked great but for the first time only.

After I got error: Error retrieving purchase details

I think this is maybe linked to the non publication in alpha as I am tested with statics.

I will try with my real product in sandbox with alpha version and I will let you know

regards

richardmarais commented 7 years ago

I am getting the same error when .getProducts(this.PRODUCT_IDS):

Error retrieving SKU details

It was working perfectly, until I added a test user. I tried to make a purchase with the test user.

this.iap.buy(item.productId).then((data) => {
  return this.iap.consume(data.productType, data.receipt, data.signature);
}).then(() => {
  console.log('product was successfully consumed!');

But now I cannot access the products any longer.

I have read here that the reason may be because testers cannot consume a product and offers this solution:

SOLUTION: Pull up "orders" on the Play Console and "cancel" the pending purchase.

However, then I have two questions:

  1. How do you test purchases, if a tester cannot consume a product?
  2. Where do you pull up orders on the Play Console? I do look at "Order Management", but there are no orders listed.

Thanks

cadti commented 7 years ago

Alguém tem uma solução?

PrithiviRajG commented 7 years ago

@richardmarais I am also facing this same issue. did you able to find the solution?

MrVibe commented 6 years ago

There is no "cancel"for orders via inAppPurchase. Only refund and it does not help. I was able to make it work. In my case, I forgot to consume the product and created a promotion coupon to purchase the inapp product which locked my Google playstore test account. Sadly, Google does not allow cancellation of promotions. I had to test it with a new Google play account and it started working again.