2. Unity In-App Purchase (IAP) とは
• Unity Analytics に付属する機
能
• アプリ内課金を簡単に組み込める
• マルチプラットフォーム
• Google Play / iOS App Store / Mac
App Store / Windows Store / その他
• コード共通
• ネイティブプラグインを書かなくてOK
36. レシート検証
public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
{
// Unity IAP's validation logic is only included on these platforms.
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
// Prepare the validator with the secrets we prepared in the Editor
// obfuscation window.
var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
AppleTangle.Data(), Application.bundleIdentifier);
try {
// On Google Play, result will have a single product Id.
// On Apple stores receipts contain multiple products.
var result = validator.Validate(e.purchasedProduct.receipt);
Debug.Log("Receipt is valid. Contents:");
foreach (IPurchaseReceipt productReceipt in result) {
Debug.Log(productReceipt.productID);
Debug.Log(productReceipt.purchaseDate);
Debug.Log(productReceipt.transactionID);
}
// Unlock the appropriate content here.
} catch (IAPSecurityException) {
Debug.Log("Invalid receipt, not unlocking content");
}
#endif
return PurchaseProcessingResult.Complete;
}
マルチプラットフォーム用
確認クラス
レシート確認
問題なければ、ここで
購入したことに
問題があればここで、
買えないことをユーザーに
知らせる必要がある