微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Unity IAP 收据验证

如何解决Unity IAP 收据验证

我在我的项目中使用 Unity (2019.4) 创建了一个项目,用户可以通过 In App Purchase 购买产品。

我使用了无代码 IAP 管理器并使用收据验证来验证购买。

在安卓中我没问题。但是在IOS越狱手机可以买到假支付的产品

这是我的代码示例

public void OnPurchaseComplete(Product product)
    {
    var validator = new CrossplatformValidator(GooglePlayTangle.Data(),AppleTangle.Data(),Application.identifier);

    bool ValidPurchase = false;

    try
    {
        // On Google Play,result has a single product ID.
        // On Apple stores,receipts contain multiple products.
        var result = validator.Validate(product.receipt);
        // For informational purposes,we list the receipt(s)
        Debug.Log("Receipt is valid. Contents:");


        
        foreach (IPurchaseReceipt productReceipt in result)
        {
            Debug.Log(productReceipt.productID);
            Debug.Log(productReceipt.purchaseDate);
            Debug.Log(productReceipt.transactionID);
            
            
            GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
            if (null != google)
            {
                // This is Google's Order ID.
                // Note that it is null when testing in the sandBox
                // because Google's sandBox does not provide Order IDs.
                ValidPurchase = true;

                Debug.Log(" google transaction" + google.transactionID);
                Debug.Log(" google transaction" + google.purchaseState);
                Debug.Log(" google transaction" + google.purchasetoken);
            }

            AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
            if (null != apple)
            {
                ValidPurchase = true;
                Debug.Log(" apple transaction1" + apple.originalTransactionIdentifier);
                Debug.Log(" apple transaction2" + apple.subscriptionExpirationDate);
                Debug.Log(" apple transaction3" + apple.cancellationDate);
                Debug.Log(" apple transaction4" + apple.quantity);
            }
        }

        

    }
    catch (IAPSecurityException)
    {
        Debug.Log("Invalid receipt,not unlocking content");
        ValidPurchase = false;
    }
    //product.receipt;
    if (ValidPurchase)
    {
        //successfull
    }
} 

我应该怎么做才能防止 iPhone 越狱。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。