IAP :WARNING!, Products size is 0

Hi all,

I’m getting this error trying to use sdkbox iap on android with Google Play.

  • I’ve initialised the IAP plugin in Appdelegate

  • Created a listener and in the ctor called

    sdkbox::IAP::setDebug(true);
    sdkbox::IAP::setListener(this);

Do I need to do anything special in Google Play Console? Does the store listing need to be fully completed?

sdkbox_config.json

{
    "android": {
      "iap": {
        "items": {
          "remove_ads": {
            "type": "non_consumable",
            "id": "com.cocos2dx.non1"
          },
          "coin_package": {
            "id": "com.cocos2dx.plugintest2"
          },
          "double_coin": {
            "type": "non_consumable",
            "id": "com.cocos2dx.non2"
          },
          "coin_package2": {
            "id": "com.cocos2dx.plugintest3"
          }
        },
        "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7eIGu7dRcBRBSC05cYvxjBMd7cqq9w6++1er+cqO2tyWPtWB4vuTkliq4k/Fkylx5UMfptdOYOW8ENgQyVucs/NyuOAGmve4j5JFhLPcLa6LjO2HUSY6zk04DRR9Zw7YPET4WAezZTz8jYMGhPG08HYltVj8cmSpSFWd1nI0pGOJoLQIMkIkXplgnPQRbMpuOu70vnQQBS1RFcoFT7OjaV8U0cfJzMoS1TMkGqaJKks2T+qOBNTtkXzge92EnvYIkhpCfN98dj6aQmETNp5yj5Fa+jcbAVF8dy5xymJwioL89XQKfKkGR+P6ESMoBEPfIZYIlMU8EUwmC+UKGLujQIDAQAB"
      }
    },
    "ios": {
        "iap": {
            "items": {
                "remove_ads": {
                    "type": "non_consumable", 
                    "id": "com.cocos2dx.non1"
                }, 
                "double_coin": {
                    "type": "non_consumable", 
                    "id": "com.cocos2dx.non2"
                }, 
                "coin_package": {
                    "id": "com.cocos2dx.plugintest2"
                }, 
                "coin_package2": {
                    "id": "com.cocos2dx.plugintest3"
                }
            }
        }
    }
}

EDIT

Tried to compile the sample for Android but im getting an error:

[armeabi] SharedLibrary  : libcocos2dcpp.so
/Users/dmorton/Downloads/sdkbox-sample-iap-master/cpp/proj.android/../../../sdkbox-cocos2d-x-binary/cocos/editor-support/cocostudio/prebuilt-mk/../../../../prebuilt/android/armeabi/libcocostudio.a(CCActionNode.o):function std::vector<cocos2d::Vector<cocostudio::ActionFrame*>*, std::allocator<cocos2d::Vector<cocostudio::ActionFrame*>*> >::_M_range_check(unsigned int) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
/Users/dmorton/Downloads/sdkbox-sample-iap-master/cpp/proj.android/../../../sdkbox-cocos2d-x-binary/cocos/editor-support/cocostudio/prebuilt-mk/../../../../prebuilt/android/armeabi/libcocostudio.a(CCArmature.o):function std::vector<std::string, std::allocator<std::string> >::_M_range_check(unsigned int) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
/Users/dmorton/Downloads/sdkbox-sample-iap-master/cpp/proj.android/../../../sdkbox-cocos2d-x-binary/cocos/editor-support/cocostudio/prebuilt-mk/../../../../prebuilt/android/armeabi/libcocostudio.a(CCArmature.o):function std::vector<cocos2d::Vec2, std::allocator<cocos2d::Vec2> >::_M_range_check(unsigned int) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
/Users/dmorton/Downloads/sdkbox-sample-iap-master/cpp/proj.android/../../../sdkbox-cocos2d-x-binary/cocos/editor-support/cocosbuilder/prebuilt-mk/../../../../prebuilt/android/armeabi/libcocosbuilder.a(CCNodeLoader.o):function std::vector<cocos2d::Value, std::allocator<cocos2d::Value> >::_M_range_check(unsigned int) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/Users/dmorton/Downloads/sdkbox-sample-iap-master/cpp/proj.android'
Error running command, return code: 2.

EDIT

No luck with the sample project but I think the problem is with XCode and the ios simulator. I have compiled my project and run it on Android, got the Error Authentication thingy which is related to me not Publishing my Alpha APK to the store before testing the IAPs

As for XCode and iOS does anyone know if I need to sign up for the Developer license with Apple in order to use IAP in the simulator? Will I need to set up IAP on iTunes Connect also??

EDIT

Ok seems obvious now but when running the ios simulator the sdkbox_config.json IAP ios object is read and used. So this confirms that to test my app on the iOS simulator I need to set up my Apple developer account, lame.

I’m going to continue testing on my Android device for the Google Play Store, APK alpha version currently pending approval for publishing.

Final EDIT

Forgot to mention that I could only get the IAPs working with Googles test products and not with the ones from the sdkbox samples. These are the testing products for Android.

android.test.purchased : Buying this item will cause a successful purchase response.
android.test.canceled : Buying this item will act as if the user had canceled the purchase.
android.test.refunded : Buying this item will act as if the purchase was refunded.
android.test.item_unavailable : Buying this item will act as if this item was not added to the Google Developer Console for your game.

And my sdkbox_config.json

{
      "iap": {
          "coin_package": {
            "id": "android.test.purchased"
          }
        },
         "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7eIGu7dRcBRBSC05cYvxjBMd7cqq9w6++1er+cqO2tyWPtWB4vuTkliq4k/Fkylx5UMfptdOYOW8ENgQyVucs/NyuOAGmve4j5JFhLPcLa6LjO2HUSY6zk04DRR9Zw7YPET4WAezZTz8jYMGhPG08HYltVj8cmSpSFWd1nI0pGOJoLQIMkIkXplgnPQRbMpuOu70vnQQBS1RFcoFT7OjaV8U0cfJzMoS1TMkGqaJKks2T+qOBNTtkXzge92EnvYIkhpCfN98dj6aQmETNp5yj5Fa+jcbAVF8dy5xymJwioL89XQKfKkGR+P6ESMoBEPfIZYIlMU8EUwmC+UKGLujQIDAQAB"
      }
    },
    "ios": {
        "iap": {
            "items": {
                "coin_package": {
                  "id": "android.test.purchased"
                }
            }
        }
    }
}

Your app does indeed need to be published on Google Play (only alpha/beta is fine) as I found over here: SDKBOX IAP Android not showing prices

Also make sure you are running a signed copy of the app and matching a build number published to Google Play (just to be safe, but the signing definitely matters)

Got it all working fine now on Android device, iOS wont work until I buy a dev license.

One thing I did notice was that If I create a product and add my tester account as a “tester” for the alpha, when Im clicking through the IAP purchase process, at no point does it say that This is a test purchase or Fake product

Should there be a notification when buying a product when using a Tester account which is registered for Alpha testing??

EDIT

It also wanted my PayPal info to make payments, which I entered, along with other addressing details and things like that, and it all looked pretty Real and not a test, is this normal?

The first Google Play-provided dialog that appears when you call sdkbox::IAP::purchase should have a line at the top that says “This is a test purchase, you will not be charged” or something of the likes.
It’s in small text and fairly easy to miss while the rest of the whole prompt is the same as real

I didnt notice and was looking out for it, but if the rest of the process is the same as a real purchase then I must just have missed it. I guess only running a Production version of the APK will result in a real purchase occuring?

EDIT

Just rememberd that Im build the APK with -m release so this could cause some issues even if the APK is in alpha?

I’m pretty sure not being in the testers list and the app being in production will result in a real purchase, I don’t think build settings change this

So to reiterate being on the testers list, and using an APK built with -m release uploaded as an Alpha version, will result in Fake purchased for testing? Which may look like a Real purchase process, with the exception of one line at the beginning when the purchase is first initiated. For consecutive purchases there is not mention of a Test of Fake is this correct?

Even with the real purchase, if it’s your google play account, you can easily refund it.