Skip to content

extremevn/ebilling

Repository files navigation

Maven Central

E-Billing

An Android library for new in-app-purchase api

Getting Started

Check out the app directory for a sample app using this library

Install

Root build.gradle

    allprojects {
		repositories {
			...
			mavenCentral()
		}
	}

App build.gradle

    dependencies {
        implementation 'vn.com.extremevn:ebilling:1.1.0'
        ...
    }
Usage

For launch purchase flow, must use

        class MainActivity : AppCompatActivity() {
            lateinit var billingProcessor: BillingProcessor
            override fun onCreate(savedInstanceState: Bundle?) {
                super.onCreate(savedInstanceState)
                billingProcessor = Billing.createFor(this)
                // Other code
            }
        }

If don't need to launch purchase flow, can use

        class SampleService : Service() {
            lateinit var billingProcessor: BillingProcessor
            override fun onCreate() {
                super.onCreate()
                billingProcessor = Billing.createFor(this)
                // Other code
            }
        }

Then we can use billing api func similar to android in-app-billing api. For example

            val params =
                SkuDetailsParams.newBuilder()
                    .setType(BillingClient.SkuType.INAPP)
                    .setSkusList(
                        listOf("your.product.id")
                    ).build()
            billingProcessor.getSkuDetails(
                params,
                object : RequestListener<List<SkuDetails>> {
                    override fun onSuccess(result: List<SkuDetails>) {
                        Timber.tag("GET_SKU").i("$result")
                    }

                    override fun onError(response: Int, e: Exception) {
                        Timber.tag("GET_SKU").e(e, "code: $response")
                    }
                }
            )

Issues and feedback

If there is specific issues, bugs, or feature requests please report in our mailing list

Contributor & Maintainer

License

Apache License 2.0