Amazon InApp testing using OpenIab

1k views Asked by At

I am trying to implement In App purchases for an Android application. So, in order to support various app store(i.e., Samsung, Google Play, Amazon etc.,) I am using OpenIab from enter link description here

I have successfully used the OpenIab for Google Play Store.

But, for Amazon, I am not able to test the InApp purchases. I want to test the Amazon purchases using Amazon SDK tester. For that, I created the amazon.sdktester.json and placed at /sdcard/amazon.sdktester.json

Now, as usual, I am performing the following steps

String base64EncodedPublicKey = "xxxxxxxx";

Map<String, String> storeKeys = new HashMap<String, String>();
        storeKeys.put(OpenIabHelper.NAME_GOOGLE, base64EncodedPublicKey);
OpenIabHelper helper= new OpenIabHelper(this, storeKeys);
        helper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            
            @Override
            public void onIabSetupFinished(IabResult result) {
                // TODO Auto-generated method stub
                
                if (result.isSuccess()) {
                    System.out.println("Successfully Setup finished");
                }
                else {
                    System.out.println("Failed to setup IAB"+result.getMessage());
                }
                
            }
        });

Now, IabSetup is getting failed i.e., result.isSuccess() is returning false.

But, if I use IAP API, then Amazon SDK tester is launching perfectly.

So, my question is, how to use the Amazon SDK tester with OpenIab i.e., how to test the Amazon InApp purchases using OpenIab.

1

There are 1 answers

0
Oleg Orlov On

It happens because OpenIAB have to choose proper store to route purchases. OpenIAB route purchases to Amazon only if finds special attributes that comes with application from Amazon Store.

To force OpenIAB work through Amazon use following approaches:

1) If you use OpenIAB.jar don't want to deal with sources use constructor OpenIABHelper(context, Options) as shown below:

    Options opts = new Options();
    opts.storeKeys = new HashMap<String, String>();
    opts.availableStores = new ArrayList<Appstore>();
    opts.availableStores.add(new AmazonAppstore(context) {
        public boolean isBillingAvailable(String packageName) {
            return true;
        }
    });
    mHelper = new OpenIabHelper(context, opts);

This code should be used only for test purposes. Ensure you don't send it to production because OpenIAB will attempt to route purchases only to Amazon no matter where app was installed from

2) if you like to work with OpenIAB sources than just switch on couple of flags in AmazonStore:

public class AmazonAppstore extends DefaultAppstore {
    private static final boolean mDebugLog = false;
    private static final String TAG = AmazonAppstore.class.getSimpleName();

    private volatile Boolean sandboxMode = false; // <------- switch to false!!!