Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.
mikemee edited this page Sep 16, 2015 · 15 revisions

This BillingProvider implementation add support for Google Play.

Only API 3 is supported.

###Links

###Dependency

dependencies {
  compile 'org.onepf:opfiab-google:x.x.x@aar'
}

Adding as jar

Add following entry to your AndroidManifest.xml:

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

Usage

final GoogleBillingProvider google = new GoogleBillingProvider.Builder(context)
                 // optional
                .setPurchaseVerifier(new SimpleGooglePurchaseVerifier(GOOGLE_PLAY_KEY))
                 // required
                .setSkuResolver(new GoogleMapSkuResolver())
                .build();

Purchase Verification

According to Security and Design you should perform signature verification on all purchased items.

Easiest way to do it is extending PublicKeyPurchaseVerifier class.

It's strongly recommended to encrypt you public key in some way.

Testing

Documentation

Easiest way to test Google Play billing with your app is using pre-defined SKUs. Please note that Google doesn't sign purchases made with this SKUs, so you can't test purchase verification with them.

It's also strongly recommended to test your app thoroughly using one of the test distribution channels.

Proguard

-keepattributes InnerClasses
-keep class com.android.vending.billing.** {*;}

FAQ

I canceled my subscription from developer console but I get ITEM_ALREADY_OWNED status from library when I try to re-purchase it.

Unfortunately there's nothing to be done. Once subscription is canceled it's no longer returned in users inventory but purchasing it again remains unavailable.