libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 83 forks source link

Testing for amazon - billing unavailable #40

Closed StanDem closed 9 years ago

StanDem commented 9 years ago

(0.5.0-snapshot)

build gradle, android part: ... compile "com.badlogicgames.gdxpay:gdx-pay-android:$gdxPayVersion" compile "com.badlogicgames.gdxpay:gdx-pay-android-openiab:$gdxPayVersion:library" compile "com.badlogicgames.gdxpay:gdx-pay-android-ouya:$gdxPayVersion:library ...

I've tried all possible combinations but I always get this on start when testing for amazon :

error installing purchase manager: java.lang.RuntimeException: Problem setting up in-app billing: IabResult: 3, No suitable appstore was found (response: 3:Billing Unavailable)

What am I doing wrong? App tester is there, json on sdcard and store app is installed and also installing apk using this:

adb install -i com.amazon.venezia com.package.name

But with gdx-pay I get only billing unavailable. What's interesting using the same environment with clean OpenIAB works fine!

Amazon AppStore is even supported at this time? Please let me know if you know how to fix it.

just4phil commented 9 years ago

you can try using the alternative PurchaseManagerAndroidAmazon.java just set it manually as purchasemanager and try it.

StanDem commented 9 years ago

How exactly can I do it?

just4phil commented 9 years ago

check the wiki https://github.com/libgdx/gdx-pay/wiki/Integration-example-with-resolvers i hope it helps

noblemaster commented 9 years ago

I updated the OpenIAB backend with the latest OpenIAB-jar (0.9.8.7). Use release 0.5.0-SNAPSHOT if you want to give it a try. However, I somewhat doubt this will resolve the issue?

You said you were successfully able to use OpenIAB directly. In order to fix the problem, it would help a lot if you could post your direct OpenIAB configuration. What parameters do you pass in, i.e. especially related to Amazon? How do you set the store search-option? - Thanks!

StanDem commented 9 years ago

We planned to release a build on Amazon yesterday so I had to quickly switch to OpenIAB. Maybe I'll switch back to Gdx-pay later for iOS porting.

Anyway here's our working setup:

AndroidManifest.xml (important thing here is the amazon receiver)

 <?xml version="1.0" encoding="utf-8"?>

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.sunraygames.bearflipworld.android"
    android:versionCode="8"
    android:versionName="1.03">

  <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="22" />
    <!--all-->
    <uses-permission android:name="android.permission.INTERNET" />
    <!--Google Play-->
    <uses-permission android:name="com.android.vending.BILLING" />
    <!--Open Store-->
    <uses-permission android:name="org.onepf.openiab.permission.BILLING" />
    <!--Samsung Apps-->
    <uses-permission android:name="com.sec.android.iap.permission.BILLING" />

    <meta-data
        android:name="iap:api_version"
        android:value="13" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme">

        <!--Amazon start-->
        <receiver android:name="com.amazon.device.iap.ResponseReceiver">
            <intent-filter>
                <action
                    android:name="com.amazon.inapp.purchasing.NOTIFY"
                    android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
            </intent-filter>
        </receiver>
        <!--Amazon end-->

      <activity
            android:name="com.sunraygames.flipworld.android.AndroidLauncher"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="sensorLandscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

gradle android dependencies:

dependencies {
    compile 'org.onepf:openiab:0.9.8.6'
    compile 'com.amazon:in-app-purchasing:2.0.1'  (required!)
}

and add this to repositories in main build.grdle

     maven { url 'https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/' }

Regarding the initialization. I'm using default OpenIAB setup from trivialdrive example. The only difference I've noticed that Gdx-pay uses Options.VERIFY_SKIP, Is there any reason for that? By default they use Options.VERIFY_EVERYTHING. Anyway if I'm correct this is not related to Amazon. (we use VERIFY_EVERYTHING)

Now regarding the testing. If you want to test on non-kindle device then there should be Amazon Apps apk installed. But there are two options of apk that you can donwload. One of them is only for Apps, another is a whole amazon store. As far as I know many people download the second one by mistake and they can't test. http://www.amazon.com/gp/mas/get/amazonapp - wrong http://www.amazon.com/gp/mas/get/androidapp - correct

And the rest as I said in my previous message.

1) Amazon App tester 2) sdktester.json on sdcard root downloaded from dev console 3) Install using this: adb install -i com.amazon.venezia your.package.name

Now OpenIAB automatically recognizes the installer of the app as Amazon.

I hope this is complete guide and I've not missed anything.

noblemaster commented 9 years ago

Thanks for posting your configuration! Very helpful.

re-VERIFY_SKIP: I run into some errors when not supplying a key, so I change it to be less restrictive. But then, it might be better to add the option VERIFY_EVERYTHING as you suggested.

How about that part: "compile 'com.amazon:in-app-purchasing:2.0.1'" Does that need to be in gdx-pay (it's missing now)? Not much of a maven/gradle-expert.

StanDem commented 9 years ago

Looks like this is required for OpenIAB, without compile 'com.amazon:in-app-purchasing:2.0.1' the Amazon Receiver from xml will not be recognized and won't work. And they use it in their example.

https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/build.gradle

noblemaster commented 9 years ago

Does that have to be in gdx-pay? Seems to me this has to be used for the app, not gdx-pay? If that's the case, I should update the documentation.

EDIT: I integrated Amazon's purchasing api into the fat-library jar generated by gdx-pay for the OpenIAB backend. I assume that will fix the problems for others. New SNAPSHOT-release generated.

StanDem commented 9 years ago

I've checked it. Now it works!

But this code is still required to be added in manifest:

  <!--Amazon start-->
        <receiver android:name="com.amazon.device.iap.ResponseReceiver">
            <intent-filter>
                <action
                    android:name="com.amazon.inapp.purchasing.NOTIFY"
                    android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
            </intent-filter>
        </receiver>
        <!--Amazon end-->
noblemaster commented 9 years ago

Great - thanks for the update! I will close the issue for now.