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.
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
بار برنامهنویس در طول تاریخ برای اهداف مختلفی از جمله جلوگیری از تقلب و نسبت دادن خریدها به کاربر صحیح استفاده میشده است. با نسخههای 2.2 و بالاتر کتابخانه صورتحساب Google Play، موارد استفاده مورد نظر که قبلاً به بار برنامهنویس متکی بودند، اکنون در بخشهای دیگر کتابخانه کاملاً پشتیبانی میشوند.
با وجود این پشتیبانی، بار برنامهنویس را منسوخ کردهایم که از نسخه 2.2 کتابخانه صورتحساب Google Play شروع میشود. روشهای مرتبط با بار برنامهنویس در نسخه 2.2 منسوخ شده و در نسخه 3.0 حذف شدهاند. توجه داشته باشید که برنامه شما میتواند به بازیابی بار برنامهنویس برای خریدهایی که با استفاده از نسخههای قبلی کتابخانه یا AIDL انجام شده است، ادامه دهد.
برای اطمینان از اینکه خریدها معتبر هستند و جعلی یا پخش مجدد نمی شوند، Google توصیه می کند از رمز خرید (به دست آمده از روش getPurchaseToken() در شیء Purchase ) به همراه API های برنامه نویس Google Play برای تأیید صحت خریدها استفاده کنید. برای اطلاعات بیشتر، مبارزه با کلاهبرداری و سوء استفاده را ببینید.
انتساب خرید
بسیاری از برنامهها، بهویژه بازیها، باید اطمینان حاصل کنند که خرید به درستی به شخصیت/آواتار درون بازی یا نمایه کاربر درونبرنامهای که خرید را آغاز کرده، نسبت داده میشود. با شروع با Google Play Billing Library نسخه 2.2، برنامه شما میتواند هنگام راهاندازی گفتگوی خرید، شناسههای حساب و نمایه مبهم را به Google ارسال کند و هنگام بازیابی خرید، آنها را بازگرداند.
Google توصیه میکند ابردادههای مربوط به خرید را در یک سرور پشتیبان امنی که نگهداری میکنید ذخیره کنید. این فراداده خرید باید با رمز خرید به دست آمده با استفاده از روش getPurchaseToken در شی Purchase مرتبط باشد. هنگامی که PurchasesUpdatedListener شما پس از خرید موفقیت آمیز فراخوانی می شود، می توان با ارسال رمز خرید و ابرداده به باطن خود، این داده ها را حفظ کرد.
برای اطمینان از مرتبط بودن ابرداده در صورت وقفه در جریان خرید، Google توصیه میکند قبل از راهاندازی گفتگوی خرید، ابرداده را در سرور پشتیبان خود ذخیره کنید و آن را با شناسه حساب کاربری، SKU خریداری شده و مهر زمانی فعلی مرتبط کنید.
اگر جریان خرید قبل از فراخوانی PurchasesUpdatedListener شما قطع شود، برنامه شما پس از از سرگیری برنامه شما خرید را کشف می کند و با BillingClient.queryPurchasesAsync() تماس می گیرد. سپس می توانید مقادیر بازیابی شده از متدهای getPurchaseTime() , getSku() و getPurchaseToken() شی Purchase را به سرور backend خود بفرستید تا متادیتا را جستجو کنید، ابرداده را با نشانه خرید مرتبط کنید و به پردازش خرید ادامه دهید. توجه داشته باشید که مهر زمانی که در ابتدا ذخیره کردید دقیقاً با مقدار getPurchaseTime() شی Purchase مطابقت ندارد، بنابراین باید آنها را به روشی تقریبی با هم مقایسه کنید. به عنوان مثال، می توانید بررسی کنید که آیا مقادیر در یک دوره زمانی مشخص از یکدیگر قرار دارند یا خیر.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]