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.
앱의 결제 클라이언트를 만들 때 보상형 광고 요청을 아동 대상 서비스로 취급해야 하는지 또는 법정 연령 미만 사용자를 대상으로 하는 서비스로 취급해야 하는지 고려하세요. 광고 요청에 이러한 제한이 있어야 하는 경우 setChildDirected() 및 setUnderAgeOfConsent() 메서드를 호출하여 각 메서드에 적절한 값을 전달합니다.
다음 코드 스니펫에서 동영상 광고가 어린이 또는 동의 연령 미만 사용자에게 적합한 것으로 취급되어야 한다고 선언하는 방법을 확인할 수 있습니다.
리워드 제품을 받기 위해 동영상 광고를 보는 옵션을 사용자에게 표시하려면 먼저 동영상을 로드해야 합니다. 이렇게 하려면 RewardLoadParams 객체를 만들고 리워드 제품을 나타내는 SkuDetails 객체와 연결합니다. 그런 다음 결제 클라이언트의 loadRewardedSku() 메서드를 호출하여 RewardLoadParams 객체와 RewardResponseListener 객체를 전달합니다.
동영상 로드가 완료되면 RewardResponseListener 리스너가 알림을 받습니다. 동영상을 사용할 수 없거나 서버 시간 초과 같은 다른 오류가 발생해도 리스너가 알림을 받습니다.
앱의 리워드 제품과 연관된 동영상을 로드할 때 기기 성능을 유지하려면 다음 권장사항을 염두에 두시기 바랍니다.
리워드 제품 SKU는 한 번에 최대 3개만 로드합니다.
사용자가 앱을 시작할 때마다 동영상 로드를 시도합니다. 이 단계는 동영상이 계속 로드되고 사용 가능한지 확인하는 데 도움이 됩니다.
동영상을 로드할 시기를 결정할 때는 사용 사례에 가장 적합한 대역폭 사용량과 앱 응답성 간의 균형을 선택합니다.
빨라도 관련 리워드 제품에 관한 getSkuDetails()를 호출한 후에 동영상을 로드합니다. 앱 응답 속도는 빠르지만, 사용자가 보지 않는 동영상을 로드하여 네트워크 데이터를 낭비할 수 있습니다.
늦어도 사용자가 동영상이 표시될 페이지로 이동한 시점에는 동영상을 로드합니다. 이 경우 앱에서 대역폭을 거의 낭비하지 않지만, 사용자가 동영상을 보기 위한 버튼을 클릭할 수 있게 되기까지 잠시 기다려야 할 수 있습니다.
다음 코드 스니펫은 사용자가 리워드 제품을 받기 전에 재생되는 동영상 광고를 로드하는 과정을 나타냅니다.
Kotlin
if(skuDetails.isRewarded()){valparams=RewardLoadParams.Builder().setSkuDetails(skuDetails).build()mBillingClient.loadRewardedSku(params.build(),object:RewardResponseListener{overridefunonRewardResponse(@BillingResponseresponseCode:Int){if(responseCode==BillingResponse.OK){// Enable the reward product, or make// any necessary updates to the UI.}}})}
Java
if(skuDetails.isRewarded()){RewardLoadParams.Builderparams=RewardLoadParams.newBuilder();params.setSkuDetails(skuDetails);mBillingClient.loadRewardedSku(params.build(),newRewardResponseListener(){@OverridepublicvoidonRewardResponse(intresponseCode){if(responseCode==BillingResponse.OK){// Enable the reward product, or make// any necessary updates to the UI.}}});}
사용자에게 리워드 구매 제공
Google Play 결제 라이브러리에서 리워드 제품과 연관된 동영상을 로드하면, 즉 RewardResponseListener에서 BillingResponse.OK의 responseCode를 받으면 결제 절차를 시작할 수 있습니다.
다른 모든 인앱 상품 유형에서와 마찬가지로 launchBillingFlow()를 호출하여 리워드 제품의 광고 재생을 시작합니다. 사용자가 리워드 제품을 받기 위해 직접 구매하지 않아도 사용자가 제품을 받아 이용할 수 있도록 결제 절차를 사용 설정해야 합니다.
앱에서 동영상 광고를 로드하고 사용자에게 리워드 제품을 제공하는 방법을 테스트하려면 기본적으로 실제 광고 대신 테스트 광고를 받는 라이선스 테스터를 활용하세요. 이러한 테스터용 계정을 설정하는 방법을 알아보려면 Google Play 결제 앱 사용자 테스트를 참조하세요.
다른 테스트 방법은 android.test.reward 제품 ID를 사용하는 것입니다. 이 특정 제품은 Google Play 결제의 예약된 이름이므로 Play Console의 인앱 상품 목록에 추가할 필요가 없습니다.
주의: 앱의 리워드 제품을 테스트할 때는 실제 제품을 사용하면 안 됩니다. 실제 제품을 테스트하면 계정이 스팸 또는 사기 계정으로 신고될 수 있습니다.
하지만 테스트를 완료하면 프로덕션 앱을 최종 사용자에게 배포하기 전에 android.test.reward를 실제 리워드 제품의 제품 ID로 대체해야 합니다.
리워드 제품 워크플로 다이어그램
다음 시퀀스 다이어그램은 사용자, 앱, Google Play 결제 라이브러리가 함께 작동하여 동영상 광고를 게재하고 사용자에게 리워드 제품 액세스 권한을 부여하는 방식을 나타냅니다.
그림 1. Google 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,["# Add rewarded-product-specific features\n\n| **Warning:** Rewarded products are no longer supported. For more information, see [Create a rewarded product](https://support.google.com/googleplay/android-developer/answer/9155268).\n\nOne method of unlocking in-app products and benefits for your users is to create\n*rewarded products*, or items that users receive after they watch a video\nadvertisement. By providing rewarded products, you allow users to obtain in-app\nrewards and benefits without them having to make direct purchases.\n\nThis document explains how to implement functionality specific to rewarded\nproducts. The [workflow diagram](#workflow-diagram) section of this page\nillustrates the process.\n\nIdentify your app's rewarded products\n-------------------------------------\n\nRewarded products have a\n[`SkuType`](/reference/com/android/billingclient/api/BillingClient.SkuType) of\n[`INAPP`](/reference/com/android/billingclient/api/BillingClient.SkuType#INAPP).\nTo ensure users are able to watch multiple ads and get multiple rewards, the\nproducts need to be consumed.\n\nBefore you can offer a rewarded product to a user, you must obtain the\n[`SkuDetails`](/reference/com/android/billingclient/api/SkuDetails) for the\nproduct. To do this, call\n[`querySkuDetailsAsync()`](/reference/com/android/billingclient/api/BillingClient#queryskudetailsasync)\nwith `SkuType.INAPP` as the product type.\n\nDeclare age-appropriate ads\n---------------------------\n\nTo help facilitate compliance with legal obligations related to children and to\nunderage users, including the [Children's Online Privacy Protection Act\n(COPPA)](http://business.ftc.gov/privacy-and-security/childrens-privacy)\nand the [General Data Protection Regulation\n(GDPR)](http://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32016R0679),\nyour app should declare which ads should be treated as child-directed in the United\nStates and which ads are directed at users who are under [the applicable age of consent in\ntheir country](https://support.google.com/accounts/answer/1350409). The AdMob\nHelp Center explains when you should tag your ad requests for [child-directed\ntreatment](https://support.google.com/admob/answer/6219315) and when you should\ntag them for [under-the-age-of-consent\ntreatment](https://support.google.com/admob/answer/9009425), as well as the\neffects of doing so.\n\nAs you create your app's billing client, consider whether the rewarded ad\nrequests should be treated as child-directed or whether they should be directed\nat users who are under the age of consent. If the ad requests should have these\nrestrictions in place, call the\n[`setChildDirected()`](/reference/com/android/billingclient/api/BillingClient#setchilddirected)\nand\n[`setUnderAgeOfConsent()`](/reference/com/android/billingclient/api/BillingClient#setunderageofconsent)\nmethods, passing appropriate values into each method.\n\nThe following code snippet shows how to declare that video ads should be\nsuitable for children or for users who are under the age of consent: \n\n### Kotlin\n\n```kotlin\nval billingClient = BillingClient.newBuilder(context)\n .setListener(this)\n .setChildDirected(ChildDirected.CHILD_DIRECTED)\n .setUnderAgeOfConsent(UnderAgeOfConsent.UNDER_AGE_OF_CONSENT)\n .build()\n```\n\n### Java\n\n```java\nBillingClient billingClient =\n BillingClient.newBuilder(context)\n .setListener(this)\n .setChildDirected(ChildDirected.CHILD_DIRECTED)\n .setUnderAgeOfConsent(UnderAgeOfConsent.UNDER_AGE_OF_CONSENT)\n .build();\n```\n| **Note:** After you've created a billing client, you cannot change the values for `childDirected` and `underAgeOfConsent`. If you need to use different values, such as when the user switches game accounts, disconnect your current billing client, make a new instance of the client, and connect that new instance to the Google Play Billing Library.\n\nLoad video ads\n--------------\n\nBefore showing your user an option to watch a video ad in order to receive a\nrewarded product, you need to load the video. To do so, create a\n[`RewardLoadParams`](/reference/com/android/billingclient/api/RewardLoadParams) object, associating it with the `SkuDetails` object that\nrepresents the rewarded product. Then, call your billing client's\n[`loadRewardedSku()`](/reference/com/android/billingclient/api/BillingClient#loadrewardedsku)\nmethod, passing in the `RewardLoadParams` object and a\n[`RewardResponseListener`](/reference/com/android/billingclient/api/RewardResponseListener)\nobject.\n| **Note:** Video ads associated with rewarded products aren't always available for loading. Also, depending on the user's bandwidth, available videos could take some time to load.\n\nThe `RewardResponseListener` listener is notified when the video has finished\nloading. The listener is also notified if the video is unavailable or if another\nerror, such as a server timeout, occurs.\n\nTo maintain device performance when loading the videos associated with your\napp's rewarded products, keep the following best practices in mind:\n\n- Load at most three rewarded product SKUs at a time.\n- Attempt to load the videos whenever the user enters your app. This step helps you check whether the videos are still loaded and available.\n- When deciding when to load the videos, choose the balance between bandwidth\n usage and app responsiveness that works best for your use case:\n\n - At the earliest, load the videos after you call `getSkuDetails()` for the associated rewarded product. Your app remains very responsive, but you might waste network data loading a video that the user never watches.\n - At the latest, load the video when the user navigates to the page where the video is to be displayed. Your app rarely wastes bandwidth in this case, but the user might have to wait a few moments before the button for watching the video becomes clickable.\n\nThe following code snippet demonstrates the process for loading a video ad that\nplays before the user receives the rewarded product:\n\n\u003cbr /\u003e\n\n### Kotlin\n\n```kotlin\nif (skuDetails.isRewarded()) {\n val params = RewardLoadParams.Builder()\n .setSkuDetails(skuDetails)\n .build()\n mBillingClient.loadRewardedSku(params.build(),\n object : RewardResponseListener {\n override fun onRewardResponse(@BillingResponse responseCode : Int) {\n if (responseCode == BillingResponse.OK) {\n // Enable the reward product, or make\n // any necessary updates to the UI.\n }\n }\n })\n}\n```\n\n### Java\n\n```java\nif (skuDetails.isRewarded()) {\n RewardLoadParams.Builder params = RewardLoadParams.newBuilder();\n params.setSkuDetails(skuDetails);\n mBillingClient.loadRewardedSku(params.build(),\n new RewardResponseListener() {\n @Override\n public void onRewardResponse(int responseCode) {\n if (responseCode == BillingResponse.OK) {\n // Enable the reward product, or make\n // any necessary updates to the UI.\n }\n }\n });\n}\n```\n\n\u003cbr /\u003e\n\nGive rewarded purchases to users\n--------------------------------\n\nIf the Google Play Billing Library successfully loads the video associated with\na rewarded product---that is, if the `RewardResponseListener` receives a\n`responseCode` of\n[`BillingResponse.OK`](/reference/com/android/billingclient/api/BillingClient.BillingResponse#OK)---you\ncan launch the billing flow.\n| **Caution:** Don't start the billing flow if the `responseCode` isn't `BillingResponse.OK`, which happens if the video ad isn't available. That way, you don't show extra error dialogs, which maintains a good user experience.\n\nYou start playing ads for a rewarded product by calling\n[`launchBillingFlow()`](/reference/com/android/billingclient/api/BillingClient#launchbillingflow),\nas you do for [all other types of in-app\nproducts](/google/play/billing/billing_library_overview#Enable). Even though the\nuser isn't making a direct purchase to receive a rewarded product, you still\nneed to enable the billing flow so that the user is able to obtain and use the\nproduct.\n\nConsume the purchase\n--------------------\n\nTo notify your billing client that a user has received and consumed a rewarded\nproduct, [handle the\npurchase](/google/play/billing/billing_library_overview#HandlePurchase) in your\nbilling client listener's\n[`onPurchasesUpdated()`](/reference/com/android/billingclient/api/PurchasesUpdatedListener#onpurchasesupdated)\nmethod. Note that rewarded purchases [need to be consumed](/google/play/billing/billing_onetime#indicate_a_one-time_product_has_been_consumed).\n\nTest your rewarded products\n---------------------------\n\nTo test how your app loads video ads and provides users with rewarded products,\nmake use of *licensed testers* , who by default get test ads instead of real\nones. To learn how to set up accounts for these testers, see [User-test a Google\nPlay Billing app](/google/play/billing/billing_testing#testing-purchases).\n\nAnother method of testing is for you to use the `android.test.reward` product\nID. This specific product is a reserved name in Google Play Billing, so you\ndon't need to add it to your list of in-app products in the Play Console. \n**Caution:** When testing your app's rewarded products, **don't use\nactual products**; otherwise, your account might be flagged as a spam or\nfraudulent account.\n\nWhen you're done testing, however, make sure you replace\n`android.test.reward` with the product IDs for your actual rewarded\nproducts before you deploy your production app to end users.\n\nDiagram of rewarded product workflow\n------------------------------------\n\nThe following sequence diagram shows how the user, your app, and the\nGoogle Play Billing Library work together to show a video ad and grant the\nuser access to a rewarded product:\n**Figure 1.** Steps for completing a rewarded product purchase using Google Play Billing"]]