BreezeIAP
Unity IAP をラップし、より扱いやすいインターフェースを提供するパッケージです。
ただし、レシート検証ロジックは別途実装する必要があります。
クイックスタート
Section titled “クイックスタート”以下の 2 つの方法のうち 1 つを選んでください。
GitHub URL の
#以降のバージョンは Changelog の最新内容を参照してください。
UPM から使う
Section titled “UPM から使う”- UPM を開き、左上の
+ボタンを押します。 Install package from git URL...を選択します。https://github.com/achieveonepark/BreezeIAP.git#1.0.0を入力してインストールします。
手動で追加する
Section titled “手動で追加する”Unity Project/Packages/manifest.jsonを開きます。dependenciesに"com.achieve.iap": "https://github.com/achieveonepark/BreezeIAP.git#1.0.0"を追加します。
このパッケージは次の機能を提供します。
BreezeIAP.Initialize | Unity IAP の初期化BreezeIAP.Purchase | 購入を試行BreezeIAP.Confirm | 購入成功後の完了処理BreezeIAP.GetPendingList | まだ完了処理されていない商品一覧を取得BreezeIAP.GetRestoreList | Android / iOS ごとの復元対象商品一覧を取得Initialize
Section titled “Initialize”Unity IAP の初期化処理を非同期で実装し、完了タイミングを把握できるようにしています。
初期化前に、ストアへ登録された ProductId がランタイムで取得できるか確認してください。
using Achieve.IAP;
private async void Start(){ // Array, List のどちらでも可能 List<InitializeDto> dtoList = new List<InitializeDto>();
// ストアに登録された Product の Id と商品タイプを DTO に設定して追加します。 dtoList.Add(new InitializeDto { ProductId = "Consumable", ProductType = ProductType.Consumable });
await BreezeIAP.InitializeAsync(dtoList);}Purchase, Confirm
Section titled “Purchase, Confirm”購入の試行から成功・失敗までを明確に判断できるよう、インターフェースとエラーメッセージを提供します。
public async void PurchaseAsync(string productId){ PurchaseResult result = await BreezeIAP.PurchaseAsync(productId);
// 成功時 if(result.IsSuccess) { // サーバー経由でレシート検証を行うならこのタイミングで追加します。
// PurchaseResult, Product のどちらでも可能 BreezeIAP.Confirm(result);
// アイテム付与
return; }
Debug.Log($"[{result.Product.definition.id}] 商品の購入に失敗しました。理由: {result.ErrorMessage}");}Dependencies
Section titled “Dependencies”In App Purchasing (4.12.0)