[OUTDATED] [Free] InAppBilling V5.0.0 - Sell your digital product from your android 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

Connect To Google Play :

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!

component_event (1)

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

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.

component_event

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

component_event

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


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 (1)

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 (1)

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

component_event (2)

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

component_event (3)

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

component_event (4)

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

component_event (5)

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 (2)

On Successfull, it will trigger following event GetPurchaseDetails.

component_event (6)

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 (3)

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 (4)

purchase is same object that you get from GotPurchase block.

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

component_event (7)

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 (5)

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

component_event (9)

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

component_event (10)

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 (6)

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

component_event (11)

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

component_event (12)

Other blocks:

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

component_method (3)

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)

To check if billing client is ready or not. It will return boolean.

component_set_get

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

component_set_get (2)

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)

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:

46 Likes

Dope Work as you always do :relaxed:

5 Likes

Awesome extension :blush: :+1:

4 Likes

Epic extension @oseamiya :heart_eyes:

4 Likes

Very detailed guide on app billing… glad to see your work… congrats.

5 Likes

Never knew that someone will make InAppBilling for free and OS :heart_eyes:

6 Likes

Nicccccccccccce extension :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:

4 Likes

@UnknownBeast @Shreyaa @Yashsehgal022 @Still-learning @Akshat_Rana @Edu_boy

Thankyou :heavy_heart_exclamation: .

4 Likes

Great extension, and for free. Good work.

5 Likes

wow awesome extension. really needed it, thanks

2 Likes

Thankyou @deanart2012 & @hades !

Also, Now you can download the extension from GetAix too.
Check it out :

5 Likes

Is It Possible to create multiple products id

for ex : Like Deephost payment option "Google Play " it sells its Aia And Aix through google play payment option So it is possible to create same like that means sell aia and aix through it

Thanks In Advance
Eagerly Waiting for someone reply

1 Like

Yes you can sell

Use this event block when you got the purchase and make your aix/aia download

3 Likes

Thanks For the Help :+1: :+1:

1 Like

@oseamiya

Is product Id should be in the form androids.myproduct ID.Purchased? or it can be only ProductID that defined in my app?
your test aia works for me in companion and works as apk, but in my app
Launch Purchase Flow block doesn’t work although when trigger Getting Purchase Details block it returns a true subscription details …why ??? :thinking:
thanks for your great effort

1 Like

android.test.purchased is test product id. You should publish your app and add your own product id in playconsole. Testing in-app purchases

You can get further guide to how product can be created from here :


Can you show the blocks?

1 Like

What Is skuDetailsToken ??

Can Someone Tell Me ??

1 Like

It represents an in-app product’s or subscription’s listing details.

2 Likes

Can you share the related blocks ? Also, if possible can you share your AppLink?

If you are unable to share here in public, you can DM me !

2 Likes

Its Has Been Fixed

1 Like