All Projects → betterme-dev → RxBilling

betterme-dev / RxBilling

Licence: MIT license
Rx wrapper for Billing Library with connection management

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to RxBilling

Google-IAP
Android Library for easing Google Play Billing to your apps with support for Subscriptions, In-App Purchases and Consumables with a beautiful sample app.
Stars: ✭ 129 (+63.29%)
Mutual labels:  purchase, billing, subscriptions, inapppurchase
Android-MonetizeApp
A sample which uses Google's Play Billing Library and it makes In-app Purchases and Subscriptions.
Stars: ✭ 149 (+88.61%)
Mutual labels:  inapppurchase, inapp-billing, inapp
Jetstream Cashier Billing Portal
Jetstream Cashier Billing Portal is a simple scaffolding billing portal to manage subscriptions, invoices and payment methods, built on top of Jetstream & Cashier Register.
Stars: ✭ 45 (-43.04%)
Mutual labels:  billing, subscriptions
Killbill
Open-Source Subscription Billing & Payments Platform
Stars: ✭ 2,396 (+2932.91%)
Mutual labels:  billing, subscriptions
kbcli
GO client library for Kill Bill
Stars: ✭ 22 (-72.15%)
Mutual labels:  billing, subscriptions
development
An Enterprise-ready Cloud Services Management Software
Stars: ✭ 38 (-51.9%)
Mutual labels:  billing, subscriptions
killbill-client-java
Java client library for Kill Bill
Stars: ✭ 30 (-62.03%)
Mutual labels:  billing, subscriptions
In App Purchase
A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
Stars: ✭ 868 (+998.73%)
Mutual labels:  purchase, billing
Android-SDK-Payment
A Simple Library for handle ZarinPal Payment on Android
Stars: ✭ 19 (-75.95%)
Mutual labels:  inapppurchase, inapp-billing
Premiumer
Premiumer makes removing ads with a single in-app purchase on Android as easy as pie.
Stars: ✭ 153 (+93.67%)
Mutual labels:  purchase, billing
Flutter iap
Flutter iap plugin
Stars: ✭ 101 (+27.85%)
Mutual labels:  purchase, billing
Qonversion Ios Sdk
iOS SDK for cross-platform in-app purchase and subscription infrastructure, revenue analytics, engagement automation, and integrations
Stars: ✭ 206 (+160.76%)
Mutual labels:  purchase, subscriptions
cashier-paystack
Cashier provides an expressive, fluent interface to Paystack's subscription billing services.
Stars: ✭ 44 (-44.3%)
Mutual labels:  billing, subscriptions
killbill-admin-ui
Kill Bill Administrative UI engine
Stars: ✭ 39 (-50.63%)
Mutual labels:  billing, subscriptions
Dj Stripe
Django + Stripe Made Easy
Stars: ✭ 1,022 (+1193.67%)
Mutual labels:  billing, subscriptions
nami-apple
Easy Apple subscriptions & in-app purchases, powered by on-device machine learning to grow your revenue. The smartest way to sell subscriptions.
Stars: ✭ 34 (-56.96%)
Mutual labels:  subscriptions, inapp
KinApp
A Kotlin In App Purchase library that lets you easily manage your billing process in Android
Stars: ✭ 79 (+0%)
Mutual labels:  inapppurchase, inapp-billing
Android Checkout
Library for Android In-App Billing (Version 3+)
Stars: ✭ 986 (+1148.1%)
Mutual labels:  purchase, billing
killbill-stripe-plugin
Kill Bill plugin for Stripe
Stars: ✭ 16 (-79.75%)
Mutual labels:  billing, subscriptions
react-native-cafe-bazaar
In-App billing for Cafe Bazaar (local android market)
Stars: ✭ 26 (-67.09%)
Mutual labels:  billing, inapp-billing

RxBilling

RxBilling is a simple wrapper above Google Billing library with connection management

Download

implementation 'com.github.betterme-dev:RxBilling:$latestVersion'
implementation 'com.android.billingclient:billing:$billingClientVer'

How to use

Connection management

BillingConnectionManager

The entry point to Billing connection management is BillingConnectionManager, that connect and disconnect in onStart() / onStop() callbacks of your LifecycleOwner

Add next lines to your Activity, Fragment or any other lifecycle owner

class MainActivity : AppCompatActivity() {

    private lateinit var rxBilling: RxBilling

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        rxBilling = RxBillingImpl(BillingClientFactory(applicationContext))
        lifecycle.addObserver(BillingConnectionManager(rxBilling))
    }
}

Retry / Repeat connection

The default implementation of retry transformation is RepeatConnectionTransformer().

You can provide your own transformer to BillingClientFactory and BillingServiceFactory

val clientFactory = BillingClientFactory(this, FlowableTransformer { upstream ->
    upstream.retry(2)
})

Observe Billing updates

override fun onStart() {
    super.onStart()
    disposable.add(
            rxBilling.observeUpdates()
            .subscribe({
                //handle update here
            }, {
                //handle error
            })
    )
}

override fun onStop() {
    disposable.clear()
    super.onStop()
}

Launch Billing flow

The result of this operation will be delivered to your updates observer

private fun startFlowWithClient() {
       disposable.add(rxBilling.launchFlow(this, BillingFlowParams.newBuilder()
               .setSkuDetails(SkuDetails) // see ## Load sku details
               .setType(BillingClient.SkuType.SUBS)
               .build())
               .subscribe({
                   //flow started
               }, {
                  //handle error
               }))
    }

Load owned products

private fun loadPurchases() {
     disposable.add(rxBilling.getPurchases(BillingClient.SkuType.INAPP)
              .subscribe({
                  //handle purchases
              }, {
                  //handle error
              }))
}

Load owned purchases

private fun loadPurchases() {
    disposable.add(
            rxBilling.getPurchases(BillingClient.SkuType.SUBS)
                    .subscribe({
                        Timber.d("getPurchases $it")
                        tvPurchases.text = it.toString()
                    }, {
                        Timber.e(it)
                    }))
}

Load history

private fun loadHistory() {
    disposable.add(
            rxBilling.getPurchaseHistory(BillingClient.SkuType.SUBS)
                    .subscribe({
                        Timber.d("getPurchaseHistory $it")
                        tvHistory.text = it.toString()
                    }, {
                        Timber.e(it)
                    }))
}

Load sku details

private fun loadDetails() {
    disposable.add(
            rxBilling.getSkuDetails(
                    SkuDetailsParams.newBuilder()
                            .setSkusList(listOf("your_id1", "your_id2"))
                            .setType(BillingClient.SkuType.SUBS)
                            .build())
                    .subscribe({
                        Timber.d("loadDetails $it")
                        tvDetails.text = it.toString()
                    }, {
                        Timber.e(it)
                    }))
}

Consume product

private fun consume() {
    disposable.add(
            rxBilling.consumeProduct(
                    ConsumeParams.newBuilder()
                            .setPurchaseToken("token")
                            .build())
                    .subscribe()
    )
}

Acknowledge item

private fun acknowledge() {
    disposable.add(
            rxBilling.acknowledge(
                    AcknowledgePurchaseParams.newBuilder()
                            .setPurchaseToken("token")
                            .build())
                    .subscribe({
                        Timber.d("acknowledge success")
                    }, {
                        Timber.e(it)
                    }))
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].