/// <summary> /// This will be called when a purchase completes. /// Optional: verify new product receipt. /// </summary> public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { if (IAPManager.GetIAPObject(e.purchasedProduct.definition.id) == null) { return(PurchaseProcessingResult.Complete); } /* * //IN DEVELOPMENT until CloudMoolah comes out of beta * //CloudMoolah payment request * if(Application.platform == RuntimePlatform.Android && StandardPurchasingModule.Instance().androidStore == AndroidStore.CloudMoolah) * { * extensions.GetExtension<IMoolahExtension>().RequestPayOut(e.purchasedProduct.transactionID, (string transactionID, RequestPayOutState state, string message) => * { * Debug.Log("RequestPayOut callback: " + transactionID + ", " + state + ", " + message); * * if (state == RequestPayOutState.RequestPayOutSucceed) * { * controller.ConfirmPendingPurchase(e.purchasedProduct); * PurchaseVerified(e.purchasedProduct.definition.id); * } * }); * * return PurchaseProcessingResult.Pending; * } */ #if UNITY_IOS || UNITY_TVOS if (validator && validator.shouldValidate(VerificationType.onStart)) { DBManager.SaveReceipt("Receipt", e.purchasedProduct.receipt); } #endif //when auto-restoring transactions on first app launch, the time between OnInitialized and //this method will be very short. So check that and do not validate for restored products //also do not validate when using PlayFab and restoring transactions on Apple as there is //currently a Unity IAP bug that causes PlayFab to decline any restore transactions if ((Time.unscaledTime - initializeTime) > 0.1f && !isRestoringTransactions && validator && validator.shouldValidate(VerificationType.onPurchase)) { validator.Validate(e.purchasedProduct); if (!(validator is ReceiptValidatorClient)) { return(PurchaseProcessingResult.Pending); } } else { PurchaseVerified(e.purchasedProduct.definition.id); } // Indicate we have handled this purchase, we will not be informed of it again return(PurchaseProcessingResult.Complete); }