[Free] InAppBilling - Sell your digital product from your application

InAppBilling Extension

An Extension to enable service to sell digital product and contents in your android application.

This extension will help you to use Google Play's billing system in your application. It uses latest billing library 4.0.0.

Start Connection

First of all, you should establish a connection to Google Play. To connect to Google Play, you should use this method:

component_method

If billing client is ready and connection is established then it will trigger BillingClientReady event.

component_event

Else if connection is failed / Billing Service is disconnected then it will trigger BillingServiceDisconnect event. You can try to restart the connection by calling StartConnection method again!


Launch Purchase Flow

To start a purchase request from your app, you should call LaunchPurchaseFlow method. It needs productId as params aswell as skuType can either be InApp or Subs.

If application fails to launch PurchaseFlow then it will trigger FailedToLaunchPurchaseFlow with a response code.

If it is successfully purchased then it will trigger GotPurchase event and you will get Purchase object in the event block.

component_event (3)

If the product or subscription is cancelled by the user then it will trigger PurchaseCancelled Event.

component_event (4)

If the purchase is failed then it will trigger PurchaseFailed event.

component_event (5)


Processing Purchase

Once a user completes the purchase, your app needs to process the purchases as It's possible that your app might not be aware of all the purchases a user has made. You can find more information & scenarios where your app could lose track or be unaware of purchases from here.
You can either process the purchase either handling purchase as consumable or non-consumable. You can find more about the consumable, and non-consumable purchases from here.
However you don't need to process the purchase manually if you enabled AutoAcknowledge method as purchase is automatically handled as Non-Consumable ie acknowledged in this case.
To handle purchase as consumable,

component_method (1)

To handle purchase as non-consumable,

component_method (2)

Purchase is same purchase you get from GetPurchase block in LaunchProjectFlow .

If purchase was in pending state then it will trigger PurchaseStatePending event,

component_event (6)

If purchase was in unspecified state then it will trigger PurchaseStateUnspecified event.

If the purchase is successfully handled then it will trigger PurchaseSuccess Event,

component_event (8)

If the handeling purchase is failed then it will again trigger PurchaseFailed event.


Getting Purchase Details

You can get the details of a Purchase using this block :

Purchase is same purchase you get from GetPurchase block in LaunchProjectFlow .

If successful then it will trigger GotPurchaseDetails with orderId, isAcknowledged, isAutoRenewing, purchasedTime and json.


.

Getting Product/Subs Details

To get the details of either subscirption or product, you can use this block :

If success then it will trigger GotDetails event with title, description, price and originalJson.

component_event (10)

Getting Purchases History

You can get the history of purchase using this block :

After getting Purchase History successfully then it will trigger GotPurchaseHistory event with list of original jsons.

component_event (11)

Other blocks :

To check if purchase is acknowledged or not. It will return boolean.

To check if GooglePlay in your device supports subscription or not.

component_set_get

To check if billing client is ready or not.

component_set_get (1)
It returns Subscription skuType

component_set_get

It returns InApp skuType

component_set_get (1)

If Auto Acknowledge is enabled to true then purchase is automatically handled as Non-Consumable & so you doesn't need to handle it manually.

If Test is enabled then product Id everywhere is used as android.test.purchased . This product id can be used without publishing application to playstore.

component_set_get (3)

Issues (Tested on android version 8.1.0) :

LaunchPurchaseFlow doesn't seem to work on companion and always trigger FailedToLaunchPurchaseFlow event with response code of -1 which indicates service is disconnected, Refrence . This issue doesn't seem in Kodular Companion. Service work after compiling as application.

Downloads :

See All Releases From Here.

Download Test Aia : InApp.aia (135.1 KB)

Download Latest Version From Github :
com.oseamiya.inappbilling

This extension is open-sourced here :

8 Likes

Epic work @oseamiya :slight_smile:

3 Likes

@oseamiya Very niiiiic🤔

3 Likes

Very good work @Sneha_Sharma

3 Likes

This post was flagged by the community and is temporarily hidden.

2 Likes

I've started working on this extension from yesterday morning & have made this extension for my own application & first this extension was published on Kodular Community before AI Community . You can check the open-source from here.

4 Likes

Extension is updated to version 2.

Changes :

  1. New method AutoAcknowledge & Test is added. They are available in designer property as well.

    image
    If AutoAcknowledge is enabled then After you sucessfully got purchase, you no need to handle purchase manually. It will automatically handle purchase as Non-Consumable ie same product cant be bought again.
    If test is enabled then productId android.test.purchased is used everytime.

  2. Added skuType in LaunchPurchaseFlow method that will open a door to buy subscription too.

    component_method

  3. Added more parameters in GotPurchasesHistory event block. Now you can get lists of productIds, orderIds & original Jsons.

    component_event

Documentation has been updated in community aswell as in getaix. You can find changes in source code from Github commits.
:slight_smile:

1 Like

Nice cool extension @oseamiya

1 Like