Search code examples
androidplay-billing-library

Android Billing Client library : How to specify Developer Payload(extra data)


I am trying to use the new Android Billing Client library(1.0)

Previously, while trying to perform a purchase, there was option to add extra data to the intent.

However, when using the new library, things have been simplified to a great degree. But is there way to add the developer payload(extra string) to the purchase flow ?


Solution

  • The new version of the billing library supports the developer payload.

    You can set the developer payload when acknowledging the purchase or consuming it.

    val client: BillingClient = ...
    val listener: AcknowledgePurchaseResponseListener = ...
    
    val acknowledgePurchaseParams =
    AcknowledgePurchaseParams.newBuilder()
        .setPurchaseToken(/* token */)
        .setDeveloperPayload(/* payload */)
        .build()
    
    client.acknowledgePurchase(acknowledgePurchaseParams, listener)
    

    Attach a developer payload in Android Billing Library v2.0