public static PlatFormController GetInstance()
 {
     if (!_controller)
     {
         _controller = (PlatFormController)GameObject.FindObjectOfType(typeof(PlatFormController));
     }
     if (!_controller)
     {
         Debug.LogError(" no PlatFormController");
     }
     return(_controller);
 }
Beispiel #2
0
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
    {
        try {
            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);

                AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
                if (null != apple)
                {
                    Debug.Log(apple.originalTransactionIdentifier);
                    Debug.Log(apple.subscriptionExpirationDate);
                    Debug.Log(apple.cancellationDate);
                    Debug.Log(apple.quantity);


                    //如果有服务器,服务器用这个receipt去苹果验证。
                    //	var receiptJson = JSONObject.Parse(e.purchasedProduct.receipt);
                    //	var receipt = receiptJson.GetString("Payload");
                }
                GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
                if (null != google)
                {
                    Debug.Log(google.purchaseState);
                    Debug.Log(google.purchaseToken);
                }
                PlatFormController.GetInstance().buyCommand(productReceipt.productID, productReceipt.transactionID, e.purchasedProduct.receipt);
            }
            return(PurchaseProcessingResult.Complete);
        } catch (Exception) {
            Debug.Log("Invalid receipt, not unlocking content");
            return(PurchaseProcessingResult.Complete);
        }
    }