[Outdated][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 5.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!

You will not be able to use any other method till connection is established.

Query Product Details:

After you have established a connection to Google Play, you are ready to query for your available products and display them to your users.

Querying for product details is an important step before displaying your products to your users, as it returns localized product information. For subscriptions, ensure your product display follows all Play policies.

component_method (7)

This method needs params productId and skuType.

If the product is successfully queried, then it will trigger following event. productDetails is the most important argument and it is used to launch the purchase flow.

If the product is failed to query, then it will trigger following event with response code.

Launch The Project Flow:

To start a purchase request from your app, you should use LaunchPurchaseFlow method which needs params like productDetails, offerToken, isOfferPersonalized and skuType.

component_method (8)


productDetails is same object you get from QueryProductDetails block.

offerToken is not compulsory. You can pass an empty string. However, for subscription, you can use GetOfferToken to get offer token.

component_method (9)

isOfferPersonalized accepts true or false. If your app can be distributed to users in the European Union, this method to disclose to users that an item’s price was personalized using automated decision-making.


If the project flow is successfully launched, then it will trigger PurchaseFlowLaunched event block.

component_event (16)

If the project flow is failed to launch then it will trigger PurchaseFlowFailedToLaunch block with a response code.

if the item is sucessfully purchased then an event GotPurchase is triggered with purchase object.

component_event (19)

if the purchase is cancelled by user, then an event PurchaseCancelled is triggered.

component_event (20)

If the purchase is failed by any other reason, then an event PurchaseFailed is triggered.

component_event (21)

A successful purchase also generates a purchase token, which is a unique identifier that represents the user and the product ID for the in-app product they purchased. Your apps can store the purchase token locally, though Google recommend passing the token to your secure backend server where you can then verify the purchase and protect against fraud. You can get purchase token as well as other purchase details from GetPurchaseDetails block.

component_method (11)

On Successfull, it will trigger following event GotPurchaseDetails.

Processing Purchase:

Once a user completes a purchase, your app then needs to process that purchase. your app is ready to grant entitlement to the user. The purchase can be handled as consumable or non-consumable. This acknowledgement communicates to Google Play that you have granted entitlement for the purchase.

NOTE: If you do not acknowledge a purchase within three days, the user automatically receives a refund, and Google Play revokes the purchase.

The process to grant entitlement and acknowledge the purchase depends on whether the purchase is a non-consumable, a consumable, or a subscription.

For consumables, the HandleConsumable method fulfills the acknowledgement requirement and indicates that your app has granted entitlement to the user. This method also enables your app to make the one-time product available for purchase again.

component_method

To acknowledge non-consumable purchases, HandleNonConsumable method can be used. Also, when you enable the AutoAcknowledge block, it will automatically handle the purchase made as Non-Consumable.

component_method (1)

purchase is same object that you get from GotPurchase block.

On successfully handled the purchase, it will trigger PurchaseSuccess event.

component_event

If purchase is failed to handle, then it will trigger PurchaseFailed event with response code.

Query Purchases:

You can get all active subscriptions and non-consumed one-time purchases using QueryPurchases block.

component_method (2)

If successfull then it will return list of Purchases on OnQueryPurchasesResponse event.

If failed, then it will trigger OnQueryPurchasesFailed event with response code.

Fetch Purchase History:

GetPurchasesHistory block will returns the most recent purchase made by the user for each product, even if that purchase is expired, canceled, or consumed.

component_method (3)

On successful, it will trigger GotPurchasesHistory with list of purchases history.

component_event (3)

If failed, then it will trigger FailedToGetPurchasesHistory with an error message.

Response Code & Its Meaning:

      SERVICE_TIMEOUT = -3;
      FEATURE_NOT_SUPPORTED = -2;
      SERVICE_DISCONNECTED = -1;
      OK = 0;
      USER_CANCELED = 1;
      SERVICE_UNAVAILABLE = 2;
      BILLING_UNAVAILABLE = 3;
      ITEM_UNAVAILABLE = 4;
      DEVELOPER_ERROR = 5;
      ERROR = 6;
      ITEM_ALREADY_OWNED = 7;
      ITEM_NOT_OWNED = 8;

Download Latest Version From Github :
com.oseamiya.inappbilling

This extension is open sourced here:

Donate:

14 Likes

Epic work @oseamiya :slight_smile:

3 Likes

@oseamiya Very niiiiic🤔

3 Likes

Very good work @Sneha_Sharma

3 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.

5 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

Sdk upgraded to latest version 5.0.0

I tried to set the blocks, but see the error message IAM seeing, can someone help me set the blocks correctly.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

the application does not compile when adding an Admob extension together with the InAppBilling v5 extension. Blocks are empty. can you help me?

Hello @Paulo3, you can use this (paid) extension with Admob extension together :arrow_down:

i dont understand the blocks :frowning: can someone give me a quick tutorial how to launch purchase?

How are you!
I am new to this and I would like you to help me find this block, I have downloaded the latest update of the extension but it does not appear.
Greetings!
component_method

You should read the first post.

Hello World,

I was tryng out https://community.appinventor.mit.edu/t/free-inappbilling-sell-your-digital-product-from-your-application/ but i wasn't able to set it up in my project because i miss those data: productDetails, offerToken, isOfferPersonalized and skuType
I wrote to the author but i didn't get a response
Can someone help me about how to find those data or even better, if someone can send me an example project with this extension so i can study how it is working
Let me know

Thanks

Anyone know if this extension is still working currently? I'm not currently a seller on Play Store so, i can't test for myself, don't want to waste my time with it if it doesnt work with the current playstore billing libraries.

This extension is outdated, please use an alternative extension, thread closed