1. Introduction
Description: Extension to integrate Billing Library (v6.0.0) in your app to sell digital products such as Subscriptions and InAppPurchases
Latest Version: 1
Released: 2023-06-05T18:30:00Z
Last Updated: 2023-06-05T18:30:00Z
2. Blocks
3. Documentation
Click to see
PurchaseFailed
Event raised when purchase fails. It provides error code and message.
responseCode | number
errorMessage | text
PurchaseSuccessful
Event raised after product has been successfully purchased
purchase | any
purchaseToken | text
PurchaseCancelled
Event raised when purchase is cancelled by the user
Initialized
Event raised when Billing Client has been initialized successfully and is ready to be used
Disconnected
Event raised when Billing Client has been disconnected and can't be used until initialized again
GotError
Event raised when any error occurs
errorMessage | text
PurchasesQueryFailed
Event raised when purchase query failed
responseCode | number
QueryPurchasesSuccessful
Event raised when got purchase objects. Returns list of Purchase objects.
purchases | list
AcknowledgeFailed
Event raised if acknowledge fails
responseCode | number
purchaseToken | text
AcknowledgeSuccessful
Event raised if acknowledge was successful
purchaseToken | text
ConsumeFailed
Event raised if consume fails
responseCode | number
purchaseToken | text
ConsumeSuccessful
Event raised if consume was successful
purchaseToken | text
GotPurchaseDetails
Event raised after getting purchase details
orderId | text
signature | text
quantity | number
purchasedTime | number
purchaseToken | text
responseJson | text
products | list
purchaseState | number
GotPurchaseHistory
Event raised after getting purchase history. Returns a list of Purchase Record objects
purchaseRecords | list
QueryPurchaseHistoryFailed
Event raised if purchase history query fails
errorCode | number
errorMsg | text
GotSubscriptionDetails
Event raised after getting subscription details
subscriptionId | text
name | text
description | text
title | text
formattedPrice | text
offerId | text
offerTagsList | list
basePlanId | text
detailsObject | any
GotProductDetails
Event raised after getting Purchase details
productId | text
name | text
description | text
title | text
formattedPrice | text
detailsObject | any
ReceivedMessage
Event raised when any billing related message is received
responseCode | number
purchaseToken | text
BillingFlowLaunched
Event raised if billing flow was launched successfully
BillingFlowFailedToLaunch
Event raised when any error occurred while launching the billing flow
responseCode | number
Initialize
Initializes Billing Client and starts the connection
QueryPurchases
Queries purchases details for currently owned items bought within your app.Only active subscriptions and non-consumed one-time purchases are returned.
productType | text
ParsePurchase
Parses Purchase object and returns its content as JSON
purchaseObj | any
Return type : text
ParsePurchaseRecord
Parses PurchaseRecord object and returns its content as JSON
recordObj | any
Return type : text
AcknowledgePurchase
Acknowledges in-app purchases.All purchases require acknowledgement. Failure to acknowledge a purchase will result in that purchase being refunded.
purchaseToken | text
Consume
Consumes a given in-app product. Consuming can only be done on an item that's owned, and as a result of consumption, the user will no longer own it.
purchaseToken | text
GetPurchaseDetails
Get details from the given Purchase object
purchase | any
Disconnect
Disconnects from Billing Client
IsReady
Returns whether Billing Client is ready to be used or not
Return type : boolean
IsSubscriptionSupported
Returns whether Subscription purchase is supported or this device or not
Return type : boolean
QueryPurchaseHistory
Queries the most recent purchase made by the user for each product, even if that purchase is expired, canceled, or consumed.
productType | text
GetSubscriptionDetails
Tries to get details of Subscription from given id.If any error occurs then GotError event will be raised.
subscriptionId | text
GetProductDetails
Tries to get details of InAppPurchase from given id.If any error occurs then GotError event will be raised.
productId | text
ReceiveInAppMessages
Allows user to receive billing related messages on top of the calling app.
Subscribe
Subscribe to provided Subscription object
detailsObj | any
offerToken | text
isOfferPersonalized | boolean
Purchase
Purchase the provided InAppPurchase object
detailsObj | any
4. Usage
(1) Initialize the billing client
(2) Get Product/Subscription details to obtain Purchase object
(3) Purchase a product and get Purchase object
If purchase was successful and it is an InAppPurchase then consume it.
Otherwise, acknowledge it.
(4) Gets details from Purchase object
5. Purchase the Extension
PayPal:
UPI:
Created using Rush, thanks to Shreyash
Hope it helps!