GithubHelp home page GithubHelp logo

office-murtaza / google-iap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akshaaatt/google-iap

0.0 0.0 0.0 186 KB

Android Library for easing Google Play Billing to your apps with support for Subscriptions, In App Purchases and Consumables with a beautiful sample app.

Home Page: https://play.google.com/store/apps/dev?id=8049209987547815414

License: GNU General Public License v3.0

Kotlin 100.00%

google-iap's Introduction

Webp-net-resizeimage-26.jpg 16113251508601.jpg

IAP is an Android library to handle In-App purchases with minimal code.

Features

  • Written in Kotlin
  • No boilerplate code
  • Easy initialisation
  • Supports InApp & Subscription products
  • Simple configuration for consumable products

Gradle Dependency

  • Add the JitPack repository to your project's build.gradle file
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Add the dependency in your app's build.gradle file
dependencies {
    implementation 'com.github.akshaaatt:Google-IAP:1.0.3'
}

Usage

Establishing connection with Play console

iapConnector = IapConnector(this, "...")
            .setInAppProductIds(listOf("id1", "id2"))   /*pass the list of INAPP IDs*/
            .setSubscriptionIds(listOf("id1", "id2"))   /*pass the list of SUBS IDs*/
            .setConsumableProductIds(listOf("id1", "id2"))  /*pass the list of consumable product IDs*/
            .autoAcknowledge()  /*to enable auto acknowledgement*/
            .connect()

Receiving events

iapConnector.setOnInAppEventsListener(object : InAppEventsListener {

            override fun onSubscriptionsFetched(skuDetailsList: List<DataWrappers.SkuInfo>) {
                /*provides list of product details of subs type*/
            }

            override fun onInAppProductsFetched(skuDetailsList: List<DataWrappers.SkuInfo>) {
                /*provides list of product details of inapp type*/
            }

            override fun onPurchaseAcknowledged(purchase: DataWrappers.PurchaseInfo) {
                /*callback after purchase being acknowledged*/
            }

            override fun onProductsPurchased(purchases: List<DataWrappers.PurchaseInfo>) {
                /*provides recent purchases*/
            }

            override fun onError(inAppConnector: EasyIapConnector, result: DataWrappers.BillingResponse?) {
                /*provides error message if anything goes wrong*/
            }
        })

Making a purchase

iapConnector.makePurchase("<sku>")

Sample App

  • Replace the key with your App's License Key
iapConnector = IapConnector(
                this, "key" // License Key
        )
  • Replace the games_ids.xml with your App's resources from the Play Console
achievementsClient?.unlock(getString(R.string.achievement_ultimate))
  • Replace the default_web_client_id with your App's client_id from the Play Sign In
requestIdToken(getString(R.string.default_web_client_id))

Contribution

You are most welcome to contribute to this project!

google-iap's People

Contributors

akshaaatt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.