[go: up one dir, main page]

Skip to content

vberezkin/billing-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

billing-android

RxJava wrapper for Android Play Billing Library

Usage

Make sure that your root project build.gradle file has this section

ext {
    compileSdkVersion = 28
    androidBillingLibraryVersion = ‘4.0.0’
    rxJavaVersion = ‘2.2.9’
}

Extend BillingManager with your payment requests

fun BillingManager.startBuyingCoins(activity: Activity) {
    initiatePurchaseFlow(activity, "buy_coins", BillingClient.SkuType.INAPP)
}

Instantiate BillingModel once as singleton or via Dagger2. In every Android component where you are going to use billing, add the next lines:

@Inject
BillingModel billingModel;
private Disposable billingSubscription;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    billingSubscription = billingModel.purchases.subscribe(purchases -> {
        //  Here our purchases come
    });
    ...
}

@Override
public void onDestroy() {
    ...
    billingSubscription.dispose();
    super.onDestroy();
}

To perform a purchaise, just add

BillingManager.startBuyingCoins(this)

About

RxJava wrapper for Android Play Billing Library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages