AlexDisler / cordova-plugin-inapppurchase

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

Can't get products. Return empty array. How to resolve? #80

Open rubinchyk opened 8 years ago

rubinchyk commented 8 years ago

Chronology of what I did: 1) Set: `cordova plugin add cordova plugin add cordova-plugin-inapppurchase'

2) add to the manifest.json: {" play_store_key ":" MyRSA key "}

3) AndroidManifest added permission for billing:

<uses-permission android:name="android.permission.BILLING" />
<uses-permission android:name="com.android.vending.BILLING" />

4) In the Template page I have button with loading products and field with foreach of product list.

5) The controller file:

$scope.loadProducts = function () {
      $ionicLoading.show({ template: spinner + 'Loading Products...' });

      alert('If Isset inAppPurchase: ' + inAppPurchase);

      inAppPurchase
      .getProducts(productIds)
      .then(function (products) {
        $ionicLoading.hide();
        alert('If Isset products: ' + products);
        $scope.products = products;
      })
      .catch(function (err) {
        $ionicLoading.hide();
        alert('Error: ' + err);
        alert(err);
      });
    };

6) Create a build: cordova build --release android , sign, archive and install to a real phone.

7) On Google Play have the same version of the android - beta, status Published. 2 Products in Active status.

Q: What have I forgotten? I did not finish? By clicking on the button to receive all of the products, the result - an empty array on success of promise. I would appreciate any comments!

jashick commented 8 years ago

Is the BILLING_KEY used in step 1 the same as the RSA key in step 2? If not, where did you find the Billing Key?

rubinchyk commented 8 years ago

@jashick Yes the same, I'm using billing key from 'Services & API' from Google Play (Base64-encoded RSA public key).

jashick commented 8 years ago

@rubinchyk I am having the same problem as you then. I continue to get an empty array when calling getProducts

jashick commented 8 years ago

After much trial and error, I was able to get it working. In the end, I had to upload a signed APK to the play store as an alpha release. The version in alpha has to match the version on the testing device. Also, I had to publish the app. If it is in Draft it won't work. It had to be published. Since I am still testing and haven't uploaded a Production APK, it isn't live on the app store yet, even though it shows as published.

anonrig commented 8 years ago

You're installing a different plugin rather than the plugin you're writing the isssue for.

rubinchyk commented 8 years ago

Yes, you right, it's my text mistake. I rewrite to correct plugin which I have. Problem still relevant. App consist the same version like in Google App store in Beta and Published. Tried to testing after upload to Google Play with installation on 2 devices, not working, no data.

rubinchyk commented 8 years ago

@jashick did you use code from example? How you specify build version, in config.xml (for ex. version="0.0.4")?

vernondegoede commented 7 years ago

I'm having this issue as well on iOS. getProducts returns an empty array of products.

jashick commented 7 years ago

@rubinchyk No, I didn't use the code above. My issue ended up being that although I had uploaded an APK to alpha, I had not published my app. It was still listed as draft. Setting it to published resolved my issue.

Jay031 commented 7 years ago

@rubinchyk @vernondegoede I have the same problem; As @vernondegoede already said: getProductsreturns an empty array of products on iOS.

Do you guys have any solution for this already? I've been working on it for days now

vernondegoede commented 7 years ago

I haven't found a solution for this yet. This plugin seems to be using the RMStore, which hasn't been updated for a couple of months already.

Our client decided to skip in app purchases for now since there doesn't seem to be a solution.

JohnScottMcNerney commented 7 years ago

@rubinchyk @vernondegoede Ditto on iOS returning an empty array.

vernondegoede commented 7 years ago

@JohnScottMcNerney Do you have a valid Paid contract in iTunes Connect? This appeared to be the problem at our project.

smallbiz13 commented 7 years ago

@vernondegoede we have a valid paid contract in iTunes Connect as well. But still returning an empty array. This might be a silly question, but what is the format of the product ID you used? Ours is com.company.mobile.iap.prod.10, com.company.mobile.iap.prod.20 etc. We have set it so that it matches the product ID's in iTunes Connect.

akships commented 7 years ago

had the same problem : for android apps you need to deploy a signed apk on your device to test in app purchases.

So basically, either you deploy a beta on goole play store and install it on the device or you generate a signed apk and install it on the device by using "adb install".

smallbiz13 commented 7 years ago

Turns out that the Paid Contract Agreement was not completed properly. Works now. Thanks all.

philippe-desplats commented 7 years ago

Good evening everyone !

I post this message to tell you that I managed to solve the problem of the empty array. Indeed I work there for more than 6 hours on and it turns out that my problem came from the "productsId". Indeed we can see everywhere that we have to put rather com.nameapp.productName while we just have to put productName.

Hope you helped!

vernondegoede commented 7 years ago

Maybe we should add some known issues section to the Readme to prevent others from experiencing the same issues?

philippe-desplats commented 7 years ago

I proposed a pull request of the ReadMe with modification and add new section known issues. It is awaiting validation by the creator.