API
타입 정의
InitializeDto
스토어에 등록할 상품 하나를 정의하는 구조체입니다.
public readonly struct InitializeDto
{
public string ProductId { get; init; }
public ProductType ProductType { get; init; }
}| 필드 | 타입 | 설명 |
|---|---|---|
ProductId | string | App Store Connect / Google Play Console에 등록된 상품 ID와 정확히 일치해야 합니다. |
ProductType | ProductType | Consumable(소모성), NonConsumable(비소모성), Subscription(구독) — UnityEngine.Purchasing에서 제공합니다. |
예시
new InitializeDto { ProductId = "gold_100", ProductType = ProductType.Consumable }
new InitializeDto { ProductId = "no_ads", ProductType = ProductType.NonConsumable }
new InitializeDto { ProductId = "vip_month", ProductType = ProductType.Subscription }PurchaseResult
PurchaseAsync 반환값 또는 GetPendingList의 항목입니다.
public readonly struct PurchaseResult
{
public PurchaseType Type { get; init; }
public Product Product { get; init; }
public PendingOrder Order { get; init; }
public string ErrorMessage { get; init; }
public string Receipt => Order?.Info?.Receipt;
public string TransactionId => Order?.Info?.TransactionID;
public bool IsSuccess => string.IsNullOrEmpty(ErrorMessage);
}| 필드 | 타입 | 설명 |
|---|---|---|
Type | PurchaseType | 구매가 어떤 경로로 도달했는지를 나타냅니다. |
Product | Product | Unity IAP Product 객체. Product.definition.id로 상품 ID를 가져옵니다. |
Order | PendingOrder | Unity IAP v5 주문. Confirm에 전달하여 구매를 확정합니다. 실패/Deferred 결과에서는 null입니다. |
ErrorMessage | string | IsSuccess가 false일 때 실패 이유가 담겨 있습니다. |
Receipt | string | Order.Info.Receipt에서 가져온 영수증 JSON. 서버 검증에 사용합니다. |
TransactionId | string | Order.Info.TransactionID에서 가져온 스토어 트랜잭션 ID. |
IsSuccess | bool | ErrorMessage가 비어있으면 true. |
자주 사용하는 패턴
var result = await BreezeIAP.PurchaseAsync("gold_100");
// 성공 여부 확인
if (!result.IsSuccess)
{
Debug.LogWarning(result.ErrorMessage);
return;
}
// 상품 ID 가져오기
string productId = result.Product.definition.id;
// 서버 검증용 데이터
string receipt = result.Receipt;
string transactionId = result.TransactionId;PurchaseType
PurchaseResult.Type에 설정되는 열거형으로, 구매가 어떤 경로로 도달했는지를 나타냅니다.
public enum PurchaseType
{
Purchase, // 정상 구매 흐름
Pending, // 이전 세션에서 재전달된 미확정 구매
Deferred, // 외부 승인 대기 중 (예: Ask to Buy)
Restore, // iOS 복원을 통해 도달
Error // 구매 실패
}| 값 | 설명 | Confirm 필요 |
|---|---|---|
Purchase | 사용자가 직접 구매 완료 | ✅ |
Pending | 이전 세션의 미확정 구매 (GetPendingList에서 도달) | ✅ |
Deferred | Ask to Buy 등 외부 승인 대기 — 아직 결제되지 않음 | ❌ |
Restore | iOS 복원을 통해 도달 | ✅ |
Error | 구매 실패 | ❌ |
Deferred와 Error는 Order가 null이므로 Confirm을 호출하지 않아야 합니다.