Communitygithub.com

unity-technologies/인앱결제-구현

Unity 인앱 결제(IAP)를 구현, 구성 및 디버깅합니다. (스토어 연결, 상품 카탈로그, 소모성/비소모성/구독형 구매, 2단계 보류-확인 흐름, 영수증 검증, 자격 확인, 복원 트랜잭션, Apple 확장(프로모션 구매, Ask-to-Buy, 코드 사용), Google Play 확장(구독 업그레이드/다운그레이드), D2C 기능, 타사 결제 제공업체(Stripe/Coda) 지원, 네이티브 Android/iOS 결제, RevenueCat/Adapty/Essential Kit/Unipay에서 Unity IAP로 마이그레이션)

인앱결제-구현란 무엇인가요?

이 스킬은 Unity 엔진 기반 게임에 인앱 결제(IAP) 시스템을 도입, 수정, 디버깅하거나 네이티브 결제 라이브러리(Google BillingClient, Apple StoreKit) 또는 서드파티 패키지(RevenueCat, Adapty, Essential Kit, Unipay)에서 Unity IAP v5로 마이그레이션해야 하는 개발자를 위한 종합 가이드입니다. 주요 기능으로는 소모성/비소모성/구독 상품 관리, 2단계 구매 흐름(보류→확인), 영수증 검증(Google Play 로컬, Apple 서버 기반), 자격 확인, 구매 복원, Apple(iOS 프로모션 구매, Ask-to-Buy, 코드 사용) 및 Google Play(구독 업/다운그레이드) 플랫폼 확장, D2C(Direct-to-Customer) 기능(Stripe/Coda 연동)을 지원합니다. 또한 Unity Cloud 및 기타 UGS 서비스와의 공존 방안을 다루며, 프로젝트 사전 점검(`references/pre-check.md`)을 통해 현재 상태를 진단하고 적절한 참조 문서로 라우팅합니다. API 시그니처, 플랫폼 확장, 마이그레이션 경로 등에 대한 상세 참조 문서를 온디맨드로 제공하여 필요한 정보만 효율적으로 찾을 수 있도록 설계되었습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/implement-in-app-purchases

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Unity 인앱 결제(IAP)

네임스페이스: UnityEngine.Purchasing | 보안: UnityEngine.Purchasing.Security 패키지: com.unity.purchasing

Unity IAP는 고유한 초기화 경로를 가집니다: UnityIAPServices.StoreController() → store.Connect(). UnityServices.InitializeAsync()가 필요하지 않지만, 프로젝트에서 다른 UGS 서비스를 사용한다면 함께 공존할 수 있습니다. Analytics가 있고 InitializeAsync()가 호출되면 IAP가 자동으로 트랜잭션 이벤트를 전송합니다.

시작하기 전에

먼저 항상 references/pre-check.md를 읽으십시오. 이 문서는 프로젝트에서 타사 IAP 패키지, 네이티브 Google Billing, 기존 Unity IAP 버전을 스캔한 후 올바른 경로로 안내합니다. 라우팅이 해결될 때까지 다른 참조 파일을 읽거나 변경하지 마십시오.

상세 참조

참조 파일은 필요할 때만 읽으십시오 — 특정 API 시그니처, 플랫폼 확장 세부 정보 또는 마이그레이션 매핑이 필요할 때만 읽습니다.

초기화 흐름

  1. UnityIAPServices.StoreController()를 통해 StoreController를 얻습니다 (또는 DefaultStore(), DefaultProduct(), DefaultPurchase()를 통해 개별 서비스 획득)
  2. Connect() 호출 전에 필요한 모든 이벤트를 구독합니다 (아래 필수 이벤트 구독 참조)
  3. await store.Connect()를 호출하여 플랫폼 스토어에 연결합니다
  4. OnStoreConnected에서 store.FetchProducts(List<ProductDefinition>)를 호출하여 카탈로그를 로드합니다
  5. OnProductsFetched에서 제품이 표시 및 구매 준비가 됩니다

초기화에는 Awake()를 사용하십시오 — 다른 Start() 메서드보다 IAP가 먼저 준비되도록 합니다.

제품 유형: ProductType.Consumable, ProductType.NonConsumable, ProductType.Subscription.

제품 가져오기

제품을 List<ProductDefinition>으로 정의하고 store.FetchProducts()에 전달합니다. 제품 ID가 Apple/Google 스토어마다 다를 때는 StoreSpecificIds를 사용합니다. 복잡한 카탈로그의 경우 CatalogProvider를 사용하여 제품 세트와 스토어별 ID를 관리합니다.

메서드동작
GetProducts()캐시된 제품 목록을 반환합니다 (동기식, FetchProducts가 호출되지 않으면 오래된 데이터)
FetchProducts()스토어에 신선한 가격/가용성을 쿼리하고 캐시를 업데이트합니다
GetProductById(id)ID로 단일 캐시된 제품을 반환합니다

이들은 서로 바꿔 쓸 수 없습니다. GetProducts()에 의존하기 전에 항상 먼저 FetchProducts()를 호출하십시오.

2단계 구매 흐름

IAP v5는 필수 2단계 흐름을 사용합니다: 보류(Pending) → 확인(Confirm).

  1. store.PurchaseProduct(product) — 플랫폼 구매 다이얼로그를 시작합니다
  2. OnPurchasePending이 실행됩니다 — PendingOrder를 수신합니다
  3. 영수증을 검증하고 플레이어에게 콘텐츠를 지급합니다
  4. store.ConfirmPurchase(pendingOrder) — 트랜잭션을 확정합니다
  5. OnPurchaseConfirmed가 실행됩니다 — Order 기본 유형을 수신하며, 패턴 매칭으로 ConfirmedOrder (성공)와 FailedOrder (확인 실패)를 구분합니다

콘텐츠를 지급한 후 반드시 ConfirmPurchase(pendingOrder)를 호출해야 합니다. 확인되지 않은 구매는 앱 재시작 시 재전송되어 구매 손실을 방지합니다.

중복 제거: OnPurchasePending은 동일한 구매에 대해 여러 번 실행될 수 있습니다 (예: 확인 전 앱 재시작). 이미 콘텐츠가 지급되었는지 항상 확인하십시오.

소모품: 확인된 소모품 구매는 FetchPurchases에서 반환되지 않습니다. 소모품 지급은 직접 추적하십시오 (예: Cloud Save 또는 Economy 사용).

지연된 구매: OnPurchaseDeferred는 Ask-to-Buy(iOS) 및 Google Play 지연 구매 시 실행됩니다. 콘텐츠를 지급하지 말고 — 승인 시 OnPurchasePending을 기다리십시오.

트랜잭션 복원

store.RestoreTransactions(callback)은 비소모품 및 구독 구매를 재전송합니다. 복원된 각 구매는 OnPurchasePending을 트리거합니다.

iOS에서 Apple App Store 규정 준수를 위해 필요합니다 — "구매 복원" 버튼을 추가하십시오.

Apple의 갱신되지 않는 구독은 RestoreTransactions를 통해 복원할 수 없습니다. 서버 측에서 추적하십시오.

영수증 검증

플랫폼접근 방식
Google PlayCrossPlatformValidator와 GooglePlayTangle.Data() — 로컬 검증 지원
Apple (StoreKit 2)로컬 검증은 작동하지 않습니다. 서버 측 검증을 위해 order.Info.Apple?.jwsRepresentation을 사용하십시오

Unity 에디터의 Services > In-App Purchasing > Receipt Validation Obfuscator를 사용하여 탱글 데이터를 생성하십시오.

자격 확인

Order가 없고 특정 제품의 상태를 알고 싶을 때 사용합니다 (v4의 product.hasReceipt를 대체). 이미 Order가 있다면 유형을 확인하십시오: PendingOrder는 EntitledUntilConsumed (소모품) 또는 EntitledButNotFinished (비소모품/구독)에 매핑되고, ConfirmedOrder는 FullyEntitled에 매핑됩니다.

store.CheckEntitlement(product)를 호출하고 store.OnCheckEntitlement를 처리합니다. entitlement.Status == EntitlementStatus.FullyEntitled를 확인하십시오.

EntitlementStatus 값: FullyEntitled, EntitledUntilConsumed, EntitledButNotFinished, NotEntitled, Unknown.

기존 구매 가져오기

store.FetchPurchases()는 스토어에서 현재 구매를 모두 검색합니다. 앱 시작 시 유용합니다.

메서드동작
GetPurchases()캐시된 구매 목록을 반환합니다
FetchPurchases()스토어에 현재 구매를 쿼리하고 캐시된 목록을 덮어씁니다

FetchPurchases()는 호출 시마다 전체 캐시 목록을 교체합니다. 비소모품 및 구독만 반환됩니다.

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

unity-technologies/2d-pixel-perfect

Sets up, diagnoses, and fixes pixel perfect 2D rendering in Unity projects. Use when working on any retro-style or pixel art 2D game.

unity-technologies/audio-setup-mixers

Scans the scene and audio assets to appropriately route Audio Sources into existing Audio Mixer Groups, classifying each source by what it plays. Use when the user asks about cleaning up mixer assignments, routing audio through a mixer, or which group a sound belongs in. Creating mixers and groups, and setting volumes, are not automated — the skill inventories what exists and asks the user to add anything missing.

unity-technologies/build-live-game

Build and operate a live game using Unity Services. Use when the user needs to implement, connect, or debug backend-driven features — battle passes, achievements, player progression, cloud saves, leaderboards, matchmaking, virtual economies, server-authoritative logic, anti-cheat, player accounts and authentication, remote configuration, feature flags, A/B testing, analytics, or cloud resource deployment. Triggers on live-ops, live service, backend, server authority, cloud code, cloud save, remote config, player data, retention, monetization loop, season pass, ranking, multiplayer sessions, lobbies, or any Unity Services integration.

unity-technologies/generate-editor-search-query

Generates Unity Search / Quick Search queries and opens the Unity Search window for read-only Unity Editor asset or scene-object lookup requests. Always use when the user asks to find, search, show, locate, filter, look up, query, or list concrete assets or scene objects in the current project or scene, even if Unity Search is not named. Covers materials, textures, prefabs, scenes, scripts, shaders, GameObjects, components, Lights, Cameras, UI objects, labels, paths, references, selected or named assets, and asset types. Also use when the user explicitly mentions Unity Search, Quick Search, Search window, open Search, or asks what Unity Search query to use. Do not use for general project overview, project structure, folder-purpose summaries, gameplay/system explanations, how-to programming questions, web search, repository text search, build logs, package installation, menu or settings search, modifying results, or non-Unity filesystem search unless the user explicitly asks to use Unity Search.

unity-technologies/initialize-ai-navigation

Sets up and configures the Unity AI Navigation system — NavMesh surfaces, NavMesh agents, obstacles, links, modifiers, areas and costs. Use when creating walkable navigation meshes, adding pathfinding agents, setting up patrol routes, configuring obstacle avoidance and carving, connecting separate NavMeshes with links, coupling navigation with animation, or troubleshooting navigation issues.

unity-technologies/levelplay-unity-integration

Integrates the LevelPlay Mediation SDK via the Ads Mediation UPM package. Use when a developer asks about adding ads to a Unity game, implementing rewarded, interstitial, or banner ads, setting up ad mediation, configuring ad networks, installing or updating the Ads Mediation package, troubleshooting LevelPlay namespace errors, resolving Android gradle or iOS CocoaPods dependency issues for ads, configuring ATT or privacy settings for ad compliance, tracking impression-level revenue (ILRD), initializing the LevelPlay SDK, or setting up ad unit IDs. Also use when a developer wants to monetize their Unity game with ads, asks how to get started with LevelPlay, ads, or mediation, or needs help with any part of the LevelPlay integration workflow including platform-specific setup for iOS or Android. Also use when upgrading the LevelPlay or IronSource SDK version, migrating from deprecated IronSource.Agent APIs, or migrating a game from Unity Ads to LevelPlay.

unity-technologies/localization

Sets up and configures Unity Localization, including locales, String/Asset Tables, CJK font support, and Addressables workflows. Use when the user wants to add languages to a project, translate UI text, support Asian (CJK) languages with TMP fonts, or mentions i18n, l10n, multilingual support, or making a game support multiple languages.

unity-technologies/manage-sprite-atlas

Manage SpriteAtlas using prebuild pipeline with IPreprocessBuildWithReport (DEFAULT approach). Use it to configure master atlases, variant atlases, texture settings, packing settings, and platform-specific configurations. Use when the user asks about creating sprite atlases, optimizing sprites, configuring atlas settings, adding sprites to atlases, creating variant atlases, implementing automated atlas generation, or runtime sprite atlas access. Always use prebuild approach unless user explicitly requests manual authoring.

unity-technologies/migrate-birp-to-urp

Plans, executes, and troubleshoots Unity projects moving from the Built-in Render Pipeline (BiRP/BIRP/Built-in RP) to the Universal Render Pipeline (URP). Use when the user asks to upgrade, convert, switch, or migrate a project, scene, material, or shader to URP/Universal Render Pipeline; fix pink or magenta materials after URP; convert Built-in materials/shaders; move a 2D project to URP 2D; review lighting, quality, post-processing, baked lightmaps, or reflection probes after URP; or diagnose visual problems after a render-pipeline migration.

관련 스킬