public void FinishTransaction(UM_iTransaction transaction) { if (transaction.State == UM_TransactionState.Failed) { //noting to fninish since it's failed //it will not have product or transaction id return; } var product = AN_Billing.Inventory.GetProductById(transaction.ProductId); if (product != null) { if (product.Type == AN_ProductType.inapp && product.IsConsumable) { var purchase = (transaction as UM_AndroidTransaction).Purchase; if (purchase != null) { AN_Billing.Consume(purchase, (result) => { }); } } } else { Debug.LogError("Transaction is finished, but no product found with such id"); } UM_AndroidInAppTransactions.RegisterCompleteTransaction(transaction.Id); }
protected override void ObserveTransactions() { foreach (var purchase in AN_Billing.Inventory.Purchases) { var transaction = new UM_AndroidTransaction(purchase, isRestored: false); if (!UM_AndroidInAppTransactions.IsTransactionCompleted(transaction.Id)) { UpdateTransaction(transaction); } } }
public void FinishTransaction(UM_iTransaction transaction) { if (transaction.State == UM_TransactionState.Failed) { //noting to finish since it's failed //it will not have product or transaction id return; } var skuDetails = GetSkuDetails(transaction.ProductId); if (skuDetails != null) { var purchase = (transaction as UM_AndroidTransaction).Purchase; Assert.IsNotNull(purchase); switch (skuDetails.Type) { case AN_BillingClient.SkuType.inapp: if (skuDetails.IsConsumable) { Consume(purchase); } else { Acknowledge(purchase); } break; case AN_BillingClient.SkuType.subs: Acknowledge(purchase); break; } } else { Debug.LogError("Transaction is finished, but no product found for id: " + transaction.ProductId); } UM_AndroidInAppTransactions.RegisterCompleteTransaction(transaction.Id); }