public void OnPurchaseSucceeded(IOSStoreKitResult item) { switch (item.State) { case InAppPurchaseState.Deferred: return; case InAppPurchaseState.Restored: ProductDefinition definition = definitions.FirstOrDefault(x => x.storeSpecificId == item.ProductIdentifier); if (definition == null || definition.type == ProductType.Subscription || DBManager.isPurchased(definition.id)) { return; } break; case InAppPurchaseState.Failed: OnPurchaseFailed(item.Error.Message, item.Error.Code); return; } string transactionId = item.TransactionIdentifier; #if UNITY_EDITOR //allow for multiple test purchases with unique transactions transactionId = (System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds.ToString(); #endif callback.OnPurchaseSucceeded(item.ProductIdentifier, item.Receipt, transactionId); }
/// <summary> /// Callback from the billing system when a (real money) purchase completes successfully. /// </summary> public void OnPurchaseSucceeded(ConfirmPurchaseResult result) { orderId = string.Empty; ItemInstance item = result.Items[0]; callback.OnPurchaseSucceeded(item.ItemId, item.PurchaseDate.ToString(), item.ItemInstanceId); }
public void OnPurchaseSucceeded(string productId, string receipt, string tranId) { util.RunOnMainThread(() => { m_CanReceivePurchases = true; callback.OnPurchaseSucceeded(productId, receipt, tranId); }); }
void CallPurchaseSucceededUpdateReceipt(ProductDefinition product, GooglePurchase googlePurchase, string purchaseToken) { m_StoreCallback?.OnPurchaseSucceeded( product.storeSpecificId, googlePurchase.receipt, purchaseToken ); }
public void OnPurchaseSucceeded(string productId, string receipt, string tranId) { util.RunOnMainThread(() => { logger.Log("PURCHASE SUCCEEDED!:{0}", count++); m_CanReceivePurchases = true; callback.OnPurchaseSucceeded(productId, receipt, tranId); }); }
public void RestoreTransactions(Action <bool> callback) { restoreCalled = true; foreach (var product in m_PurchasedProducts) { m_Biller.OnPurchaseSucceeded(product, "{ \"this\" : \"is a fake receipt\" }", "1"); } callback(true); }
public virtual void OnPurchaseSucceeded(string id, string receipt, string transactionID) { if (!eventsDisabled) { SendPurchaseSucceededEvent(id, receipt, transactionID); } unity.OnPurchaseSucceeded(id, receipt, transactionID); Promo.ProvideProductsToAds(this, unity); }
public void OnPurchaseSucceeded(BillingResult item) { if (!item.IsSuccess) { OnPurchaseFailed(item.Message, item.Response); return; } string transactionId = item.Purchase.OrderId; #if UNITY_EDITOR //allow for multiple test purchases with unique transactions transactionId = (System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds.ToString(); #endif callback.OnPurchaseSucceeded(item.Purchase.SKU, item.Purchase.OriginalJson, transactionId); }
/// <summary> /// /// </summary> public void OnPurchaseSucceeded(BillingTransaction item) { if (item == null || !string.IsNullOrEmpty(item.Error)) { OnPurchaseFailed(item == null ? "Unkown Billing Error." : item.Error, 1); return; } string transactionId = item.TransactionIdentifier; #if UNITY_EDITOR //allow for multiple test purchases with unique transactions transactionId = (System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds.ToString(); #endif callback.OnPurchaseSucceeded(item.ProductIdentifier, item.TransactionReceipt, transactionId); }
void PurchaseInitentCreated(PurchaseIntentResult intentResult, ProductDefinition product) { if (intentResult == null) { storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.id, PurchaseFailureReason.Unknown, "IntentIsNull")); return; } var status = intentResult.Status; status.StartResolutionForResult((androidIntent) => { PurchaseResultInfo purchaseResultInfo = iapClient.ParsePurchaseResultInfoFromIntent(androidIntent); switch (purchaseResultInfo.ReturnCode) { case OrderStatusCode.ORDER_STATE_SUCCESS: var data = new InAppPurchaseData(purchaseResultInfo.InAppPurchaseData); this.purchasedData[product.storeSpecificId] = data; this.productsByID.TryGetValue(product.storeSpecificId, out var productInfo); var receipt = EncodeReceipt(purchaseResultInfo.InAppPurchaseData, purchaseResultInfo.InAppDataSignature, ProductToJson(productInfo)); storeEvents.OnPurchaseSucceeded(product.storeSpecificId, receipt, data.OrderID); break; case OrderStatusCode.ORDER_PRODUCT_OWNED: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.DuplicateTransaction, purchaseResultInfo.ErrMsg)); break; case OrderStatusCode.ORDER_STATE_CANCEL: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.UserCancelled, purchaseResultInfo.ErrMsg)); break; default: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.Unknown, purchaseResultInfo.ErrMsg)); break; } }, (exception) => { storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.id, PurchaseFailureReason.Unknown, exception.Message)); }); }
private void ParsePurchaseResult(AndroidJavaObject billingResult, AndroidJavaObject javaPurchasesList) { var responseCode = _jniUtils.GetResponseCodeFromBillingResult(billingResult); var debugMessage = JniUtils.GetDebugMessageFromBillingResult(billingResult); if (responseCode == BillingResponseCode.Ok) { var purchasesList = _jniUtils.ParseJavaPurchaseList(javaPurchasesList); _inventory.UpdatePurchaseInventory(purchasesList); // Unity IAP only supports one purchase at a time. Purchase purchase = purchasesList.First(); if (Google.Play.Billing.Internal.Purchase.State.Pending.Equals(purchase.PurchaseState)) { string unityProductId; _inventory.GetUnityProductId(purchase.ProductId, out unityProductId); _billingUtil.RunOnMainThread(() => _deferredPurchaseListener.Invoke(_callback.products.WithID(unityProductId))); } else { _billingUtil.RunOnMainThread(() => _callback.OnPurchaseSucceeded(purchase.ProductId, purchase.JsonReceipt, purchase.TransactionId)); } } else { _billingUtil.LogWarningFormat("Purchase failed with error code '{0}' and debug message: '{1}'", responseCode, debugMessage); PurchaseFailureReason purchaseFailureReason; switch (responseCode) { case BillingResponseCode.UserCancelled: purchaseFailureReason = PurchaseFailureReason.UserCancelled; break; case BillingResponseCode.ServiceTimeout: case BillingResponseCode.ServiceDisconnected: case BillingResponseCode.ServiceUnavailable: case BillingResponseCode.BillingUnavailable: purchaseFailureReason = PurchaseFailureReason.PurchasingUnavailable; break; case BillingResponseCode.ItemUnavailable: purchaseFailureReason = PurchaseFailureReason.ProductUnavailable; break; case BillingResponseCode.ItemAlreadyOwned: purchaseFailureReason = PurchaseFailureReason.DuplicateTransaction; break; default: purchaseFailureReason = PurchaseFailureReason.Unknown; break; } // Copy _productInPurchaseFlow.id into the delegate as the delegate is called by the main thread and // _productInPurchaseFlow will get cleaned up immediately in this thread. var productId = _productInPurchaseFlow.id; _billingUtil.RunOnMainThread(() => _callback.OnPurchaseFailed( new PurchaseFailureDescription(productId, purchaseFailureReason, debugMessage))); } _productInPurchaseFlow = null; }
public void OnPurchaseSuccessful(string sku, string receipt, string purchaseToken) { m_StoreCallback?.OnPurchaseSucceeded(sku, receipt, purchaseToken); }
public void OnPurchaseSucceeded(string id, string receipt, string transactionID) { m_Util.RunOnMainThread(() => m_ForwardTo.OnPurchaseSucceeded(id, receipt, transactionID)); }
public virtual void OnPurchaseSucceeded(string id, string receipt, string transactionID) { unity.OnPurchaseSucceeded(id, receipt, transactionID); }
private void OnSocialProductPurchased(string productId, string transactionId) { _callback.OnPurchaseSucceeded(productId, "", transactionId); }