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.
선주문이 처리되고 구매 상태가 PURCHASED로 변경되면 RTDN이 클라이언트로 전송됩니다. RTDN을 수신한 후 백엔드에서 일회성 제품 구매 처리에 설명된 대로 선주문 구매를 처리합니다.
거래 관련 RTDN은 보안 백엔드에서 처리해야 합니다.
완료된 거래 처리
사용자가 일회성 제품 구매를 완료하면 Google Play에서 유형이 ONE_TIME_PRODUCT_PURCHASED인 OneTimeProductNotification 메시지를 전송합니다.
이 RTDN을 수신하면 백엔드에서 일회성 제품 구매 처리에 설명된 대로 구매를 처리합니다.
취소된 거래 처리
일회성 제품 구매가 취소되면 실시간 개발자 알림을 수신하도록 구성한 경우 Google Play에서 유형이 ONE_TIME_PRODUCT_CANCELED인 OneTimeProductNotification 메시지를 전송합니다. 예를 들어 사용자가 필수 기간 내에 결제를 완료하지 않은 경우 또는 개발자나 고객 요청에 의해 구매가 취소된 경우 이러한 상황이 발생할 수 있습니다. 백엔드 서버에서 이 알림을 수신하면 purchases.productsv2.getproductpurchasev2 메서드를 호출하여 최신 구매 상태를 가져온 다음 이에 따라 백엔드에서 사용자 사용 권한을 비롯한 정보를 업데이트합니다.
ONE_TIME_PRODUCT_PURCHASED RTDN을 사용하여 새 구매를 감지했든, 아니면 앱의 onResume() 메서드에서 PurchasesUpdatedListener를 사용하거나 구매를 수동으로 가져와서 앱 내에서 새 구매에 대해 알게 되었든, 새 구매를 처리해야 합니다. 보안을 강화하기 위해 구매 처리를 백엔드에서 처리하는 것이 권장됩니다.
새로운 일회성 구매를 처리하려면 다음 단계를 따르세요.
purchases.productsv2.getproductpurchasev2 엔드포인트를 쿼리하여 최신 일회성 제품 구매 상태를 확인합니다. 구매에 대해 이 메서드를 호출하려면 이에 상응하는 앱 또는 ONE_TIME_PRODUCT_PURCHASED RTDN의 purchaseToken이 필요합니다.
소비성 제품인 경우 사용자가 제품을 소비한 후에 다시 구매할 수 있도록 purchases.products.consume 메서드를 호출하여 제품을 소비됨으로 표시합니다. 이 메서드는 구매도 확인합니다.
Play 결제 라이브러리에는 앱에서 구매를 처리할 수 있게 해 주는 구매 확인 및 소비 메서드도 있긴 하나, 백엔드에 보안 구현을 위한 처리 방법이 있는 경우 백엔드에서 처리를 진행하는 것을 권장합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","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-27(UTC)"],[],[],null,["# One-time purchase lifecycle\n\nOne-time purchase products have a simpler lifecycle than subscription products,\nbut there are still several states and transition events that your backend needs\nto be able to handle properly.\n**Figure 1** Lifecycle states and transition events for one-time purchases.\n\nNew one-time product purchases\n------------------------------\n\nAfter the user completes the billing flow, your app can see information about\nthe new purchase in one of the following ways:\n\n- Setup [`Real-time developer notifications`](/google/play/billing/getting-ready#enable-rtdn \"Real-time developer notifications\") and enable `Get all\n notifications for subscriptions and one-time products` to receive updates on the status of purchases.\n- Implement the [`PurchasesUpdatedListener`](/reference/com/android/billingclient/api/PurchasesUpdatedListener) interface from `BillingClient` to automatically receive purchase updates.\n- Call the [`BillingClient.queryPurchasesAsync()`](/reference/com/android/billingclient/api/BillingClient#queryPurchasesAsync(com.android.billingclient.api.QueryPurchasesParams,%20com.android.billingclient.api.PurchasesResponseListener)) method.\n\nAfter receiving the new purchase, use the\n[`getPurchaseState`](/reference/com/android/billingclient/api/Purchase#getPurchaseState()) method or\n[`purchases.productsv2.getproductpurchasev2 in Play Developer API`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2/getproductpurchasev2 \"purchases.productsv2.getproductpurchasev2 in Play Developer API\")\n\nto determine the payment state of the new purchase.\n\n### Real-time developer notifications\n\n| **Note:** One-time purchase real-time developer notifications are only published if you have [opted into them while configuring real-time developer\n| notifications](/google/play/billing/getting-ready#enable-rtdn \"Real-time developer notifications\").\n\nWhen a user purchases or cancels the purchase of a one-time product, Google Play\nsends a [`OneTimeProductNotification`](/google/play/billing/rtdn-reference#one-time) message.\nTo update your backend purchase state, use the purchase token provided in the\n`OneTimeProductNotification` object to call the\n[`purchases.productsv2.getproductpurchasev2`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2)\nmethod. This method provides the latest purchase and consumption status given a\npurchase token.\n\nWhen a pre-order is fulfilled and its purchase state changes to PURCHASED, an\nRTDN is sent to your client. After receiving the RTDN, process the pre-order\npurchase as described in [Process one-time product purchases in your\nbackend](#process).\n\nYou should handle transaction-related RTDNs in your secure backend.\n\n### Handle completed transactions\n\nWhen a user completes a one-time product purchase, Google Play sends a\n`OneTimeProductNotification` message with the type `ONE_TIME_PRODUCT_PURCHASED`.\nWhen you receive this RTDN, process the purchase as described in [Process\none-time product purchases in your backend](#process).\n\n### Handle canceled transactions\n\nWhen a one-time product purchase is canceled, Google Play sends a\n`OneTimeProductNotification` message with the type `ONE_TIME_PRODUCT_CANCELED`\nif you have configured to receive real-time developer notifications. For\nexample, this can occur if the user doesn't complete payment within the required\ntimeframe, or if the purchase is revoked by the developer or by customer\nrequest. When your backend server receives this notification, call the\n[`purchases.productsv2.getproductpurchasev2`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2)\nmethod to get the latest purchase state, then update your backend accordingly,\nincluding user entitlements.\n\nIf a one-time product purchase in `Purchased` state gets refunded, you will also\nbe made aware using the [Voided Purchases API](https://developers.google.com/android-publisher/voided-purchases).\n\nProcess one-time product purchases in your backend\n--------------------------------------------------\n\nWhether you have detected a new purchase using a `ONE_TIME_PRODUCT_PURCHASED`\nRTDN\nor you have been made aware in-app through\n[`PurchasesUpdatedListener`](/reference/com/android/billingclient/api/PurchasesUpdatedListener) or [manually fetching\npurchases](/google/play/billing/integrate#fetch) in your app's `onResume()` method, you must process\nthe new purchase. We recommend that you handle purchase processing in your\nbackend for better security.\n\nFollow these steps to process a new one-time purchase:\n\n1. Query the [`purchases.productsv2.getproductpurchasev2`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2) endpoint to obtain the latest one-time product purchase status. To call this method for a purchase, you need the corresponding `purchaseToken` either from your app or from the `ONE_TIME_PRODUCT_PURCHASED` RTDN.\n2. Call [`getPurchaseState()`](/reference/com/android/billingclient/api/Purchase#getPurchaseState()) and make sure that the purchase state is `PURCHASED`.\n3. [Verify the purchase](/google/play/billing/security#verify).\n4. Give the user access to the content. The user account associated with the purchase can be identified with the [`obfuscatedExternalAccountId`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2#ProductPurchaseV2) field from `purchases.productsv2.getproductpurchasev2`, if one was set using [`setObfuscatedAccountId()`](/reference/com/android/billingclient/api/BillingFlowParams.Builder#setObfuscatedAccountId(java.lang.String)) when the purchase was made.\n 1. For non-consumable product purchases, acknowledge delivery of the content by calling the [`purchases.products.acknowledge`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge) method. Make sure that the purchase hasn't been previously acknowledged by checking the [`acknowledgementState`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.productsv2) field.\n 2. If the product is consumable, mark the item as consumed by calling the [`purchases.products.consume`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/consume) method so that the user can buy the item again after they have consumed it. This method also acknowledges the purchase.\n\n| **Note:** If you don't acknowledge a purchase within three days, the user automatically receives a refund, and Google Play revokes the purchase.\n\nThere are also purchase acknowledgement and consume methods available in the\nPlay Billing Library that allow you to process purchases from you app, but we\nrecommend that you handle processing in your backend if you have one for a more\nsecure implementation."]]