Developer Console

[UPDATED] Quickly monetize with the new Amazon Appstore Billing Compatibility SDK

Diana Stansfield Mar 15, 2023
Share:
Launch
Blog_Header_Post_Img

Update as of 31 October, 2023:

If your app currently uses subscriptions with Google Play In-app Billing, you can now launch on the Amazon Appstore without refactoring your code!

In addition to consumables and entitlements, you can now offer subscriptions to your customers with the Appstore Billing Compatibility SDK. This SDK helps reduce porting efforts from Android to Amazon Fire OS by streamlining your billing flow through a parallel API approach.

Feature Comparison Table
The following table shows a feature comparison between the Google Play Billing Library, the Appstore SDK, and the Appstore Billing Compatibility SDK.

Parallel API approach to streamline billing flows

To add subscriptions to your app, you need to create a subscription plan in the Developer Console. Review our technical documentation to learn more.

Previously published on March 15, 2023:

Have an existing Android app with Google Play In-app Billing? Use the Appstore Billing Compatibility SDK to simplify porting apps with Google Play Billing Library (IAB) requirements. If your app offers in-app purchasing for consumables and entitlements via Google Play, you can now launch on Amazon Appstore without refactoring your code!

Integrate in-app purchasing with minimal porting effort

If you are new to the Amazon Appstore, Android apps can now integrate with Appstore Billing Compatibility SDK for Amazon customers on Fire OS.

When comparing the SDKs, you’ll notice several differences between Google In-app Billing (IAB) and Amazon’s in-app purchasing APIs. To reduce the time and effort when porting to Amazon Appstore, we built the Appstore Billing Compatibility SDK as a solution for porting IAB to Fire OS. If you've already integrated with Google Play In-app Billing Library, you will have minimal changes to get up and running for Amazon customers.

A parallel API approach to streamline billing flows 
Parallel API approach to streamline billing flows

To ease the differences in API signatures and functionality, we developed these APIs in parallel with Google In-app Billing (IAB) functionality. Our endpoints handle the same parameters and return the expected values and billing functionality. The goal is once you edit the purchasing library name from IAB to IAP, your app has access to our full capabilities. Specifically, you will update all Google Play Billing imports in your app's codebase to use Appstore SDK imports by finding all usages of the com.android.billingclient.api prefix and replacing them with the com.amazon.device.iap.billingclient.api prefix.

The following example code shows how to add a BillingResponseReceiver to the AndroidManifest.xml file for the Appstore SDK:

Copied to clipboard
<application>
...
    <activity android:name="com.amazon.sample.iap.entitlement.MainActivity"
              android:label="@string/app_name" android:exported="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    <receiver android:name="com.amazon.device.iap.billingclient.api.BillingResponseReceiver" android:exported="true"
              android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY">
        <intent-filter>
            <action android:name="com.amazon.inapp.purchasing.NOTIFY" />
        </intent-filter>
    </receiver>
...
</application>

 

Once you have imported the SDK dependencies, it’s time to initialize a BillingClient instance:

Copied to clipboard
private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
    @Override
    public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
        // To be implemented
    }
};

private BillingClient billingClient = BillingClient.newBuilder(context)
    .setListener(purchasesUpdatedListener)
    .enablePendingPurchases()
    .build();

 

Launching a purchasing flow now has API parity between the app stores:

1. querySkuDetailsAsync() - The Query SKU details Async API retrieves your items from the Amazon Developer Console in addition to SKU type.

2. launchBillingFlow() - The SDK supports buying one product per in-app purchase request in your app’s main thread.

3. queryPurchasesAsync() - Will return the list of purchased items

4. consumeAsync() - This method is intended for marking consumables, and the acknowledgePurchase() tracks the delivery of entitlements.

Getting started

Download the Appstore Billing Compatibility SDK, which includes the Appstore SDK JAR file and API documentation. Follow the step by step guide.  

Related resources

Related articles

Sign up for our newsletter

Stay up to date with the latest Amazon Developer news, industry trends and blog posts.