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
First of all, you should establish a connection to Google Play. To connect to Google Play, you should use this method:
If billing client is ready and connection is established then it will trigger
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.
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.
This method needs params
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.
To start a purchase request from your app, you should use
LaunchPurchaseFlow method which needs params like
productDetails is same object you get from
offerToken is not compulsory. You can pass an empty string. However, for subscription, you can use
GetOfferToken to get offer token.
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.
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
if the purchase is cancelled by user, then an event
PurchaseCancelled is triggered.
If the purchase is failed by any other reason, then an event
PurchaseFailed is triggered.
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
On Successfull, it will trigger following event
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.
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
purchase is same object that you get from
On successfully handled the purchase, it will trigger
If purchase is failed to handle, then it will trigger
PurchaseFailed event with response code.
You can get all active subscriptions and non-consumed one-time purchases using QueryPurchases block.
If successfull then it will return list of Purchases on
If failed, then it will trigger
OnQueryPurchasesFailed event with response code.
GetPurchasesHistory block will returns the most recent purchase made by the user for each product, even if that purchase is expired, canceled, or consumed.
On successful, it will trigger
GotPurchasesHistory with list of purchases history.
If failed, then it will trigger
FailedToGetPurchasesHistory with an error message.
To check if purchase is acknowledged or not. It will return boolean.
To check if GooglePlay in your device supports subscription or not.
To check if billing client is ready or not.
It returns Subscription skuType
It returns InApp skuType
To check if billing client is ready or not. It will return boolean.
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.
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 :
This extension is open sourced here: