BillingClient🔗
BillingClient is the main class used to interact with the Google Play Billing service.
It provides functionality for:
- Connecting to Google Play Billing
- Querying product details
- Querying previously owned purchases
- Starting purchase flows
- Consuming purchases
- Acknowledging purchases
- Managing subscriptions
All billing operations should be performed through an instance of this class.
Creating the Client🔗
Create the billing client before performing any billing operations.
var billing_client := BillingClient.new()
The BillingClient internally communicates with the Android plugin through a JNI singleton.
Typical Billing Flow🔗
A typical purchase flow looks like this:
- Create
BillingClient - Connect to signals
- Call
start_connection() - Wait for the
connectedsignal - Query products with
query_product_details() - Start purchase with
purchase() - Handle
on_purchase_updated - Acknowledge or consume the purchase
Example
var billing_client := BillingClient.new()
func _ready():
billing_client.connected.connect(_on_connected)
billing_client.start_connection()
func _on_connected():
var productIds = ["coins_100"]
billing_client.query_product_details(productIds, BillingClient.ProductType.INAPP)