Reminder: By Aug 31, 2025, all new apps and updates to existing apps must use Billing Library version 7 or newer. If you need more time to update your app, you can request an extension until Nov 1, 2025. Learn about Play Billing Library version deprecation.
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Developer payload has historically been used for various purposes, including\nfraud prevention and attributing purchases to the correct user. With versions\n2.2 and higher of the Google Play Billing Library, intended use cases that\npreviously relied on developer payload are now fully supported in other parts\nof the library.\n\nWith this support in place, we have deprecated developer payload, starting with\nversion 2.2 of the Google Play Billing Library. Methods associated with\ndeveloper payload have been deprecated in version 2.2 and were removed in\nversion 3.0. Note that your app can continue to retrieve developer\npayload for purchases made using either previous versions of the library or\nAIDL.\n\nFor a detailed list of changes, see the\n[Google Play Billing Library 2.2 release notes](/google/play/billing/release-notes#2-2).\nand [Google Play Billing Library 3.0 release notes](/google/play/billing/release-notes#3-0).\n\nPurchase verification\n---------------------\n\nTo ensure purchases are authentic and not forged or replayed, Google recommends\nusing the purchase token (obtained from the\n[`getPurchaseToken()`](/reference/com/android/billingclient/api/Purchase#getpurchasetoken)\nmethod in the\n[`Purchase`](/reference/com/android/billingclient/api/Purchase) object) along\nwith the Google Play Developer APIs to verify purchases are authentic.\nFor more information, see\n[Fight fraud and abuse](/google/play/billing/security).\n\nPurchase attribution\n--------------------\n\nMany apps, particularly games, need to ensure that a purchase is correctly\nattributed to the in-game character/avatar or in-app user profile that initiated\nthe purchase. Starting with Google Play Billing Library 2.2,\nyour app can pass obfuscated account and profile identifiers to Google\nwhen launching the purchase dialog and have them returned when retrieving a\npurchase.\n\nUse the\n[`setObfuscatedAccountId()`](/reference/com/android/billingclient/api/BillingFlowParams.Builder#setObfuscatedAccountId(java.lang.String))\nand\n[`setObfuscatedProfileId()`](/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid)\nparameters in\n[`BillingFlowParams`](/reference/com/android/billingclient/api/BillingFlowParams)\nand retrieve them using the\n[`getAccountIdentifiers()`](/reference/com/android/billingclient/api/Purchase#getAccountIdentifiers())\nmethod in the\n[`Purchase`](/reference/com/android/billingclient/api/Purchase) object.\n| **Note:** Purchases made using previous versions of the library using [`setAccountId()`](/reference/com/android/billingclient/api/BillingFlowParams.Builder#setAccountId(java.lang.String)) (renamed to `setObfuscatedAccountId()`) are not returned by `getAccountIdentifiers()`.\n\nAssociate metadata with a purchase\n----------------------------------\n\nGoogle recommends storing metadata about a purchase on a secure backend\nserver that you maintain. This purchase metadata should be associated with the\npurchase token obtained using the\n[`getPurchaseToken`](/reference/com/android/billingclient/api/Purchase#getPurchaseToken())\nmethod in the [`Purchase`](/reference/com/android/billingclient/api/Purchase)\nobject. This data can be persisted by passing the purchase token and metadata\nto your backend when your\n[`PurchasesUpdatedListener`](/reference/com/android/billingclient/api/PurchasesUpdatedListener)\nis called after a successful purchase.\n\nTo ensure metadata is associated in the case of purchase flow interruptions,\nGoogle recommends storing the metadata on your backend server prior to\nlaunching the purchase dialog and associating it with your user's account ID,\nthe SKU being purchased, and the current timestamp.\n\nIf the purchase flow is interrupted before your\n[`PurchasesUpdatedListener`](/reference/com/android/billingclient/api/PurchasesUpdatedListener)\nis called, your app will discover the purchase once your app resumes and calls\n[`BillingClient.queryPurchasesAsync()`](/reference/com/android/billingclient/api/BillingClient#queryPurchasesAsync(java.lang.String,%20com.android.billingclient.api.PurchasesResponseListener)).\nYou can then send the values retrieved from the `Purchase` object's\n[`getPurchaseTime()`](/reference/com/android/billingclient/api/Purchase#getPurchaseTime()),\n[`getSku()`](/reference/com/android/billingclient/api/Purchase#getsku),\nand [`getPurchaseToken()`](/reference/com/android/billingclient/api/Purchase#getpurchasetoken)\nmethods to your backend server to look up metadata, associate the metadata\nwith the purchase token, and continue processing the purchase. Note that the\ntimestamp you initially stored won't exactly match the value from the `Purchase` object's\n[`getPurchaseTime()`](/reference/com/android/billingclient/api/Purchase#getPurchaseTime()),\nso you would need to compare them in an approximate way. For example, you can check\nif the values are within a certain time period of each other."]]