1,利用收据验证混淆器
把后台的key填进去,点击自动生成一些文件
2,代码过滤
using UnityEngine.Purchasing.Security;
在IAPManager.cs的
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
增加
#if !UNITY_EDITORbool validPurchase = true; // 假设对没有收据验证的平台有效。var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),AppleTangle.Data(), Application.identifier);try {//在 Google Play 上,结果中仅有一个商品 ID。//在 Apple 商店中,收据包含多个商品。var validateResult = validator.Validate(e.purchasedProduct.receipt);//为便于参考,我们将收据列出Debug.Log("Receipt is valid. Contents:");//validateResult./*foreach (IPurchaseReceipt productReceipt in validateResult) {}*/} catch (IAPSecurityException) {Debug.Log("Invalid receipt, not unlocking content");validPurchase = false;}if (!validPurchase){return PurchaseProcessingResult.Complete;}
#endif