/// <summary> /// Initializes a new instance of the <see cref="PurchaseInfo"/> class. /// </summary> public PurchaseInfo(string productId, PurchaseResult purchaseResult, StorePurchaseError?error, Exception e) : base(purchaseResult.Product, purchaseResult.TransactionInfo, purchaseResult.ValidationResult) { ProductId = productId; Error = error; Exception = e; }
private void InvokePurchaseCompleted(PurchaseResult purchaseResult) { Debug.Assert(purchaseResult != null); if (_observers != null) { lock (_observers) { foreach (var item in _observers) { try { item.OnNext(new PurchaseInfo(_purchaseProductId, purchaseResult, null, null)); } catch (Exception e) { _console.TraceData(TraceEventType.Error, _traceEventPurchase, e); } } } } try { PurchaseCompleted?.Invoke(this, new PurchaseCompletedEventArgs(purchaseResult)); } catch (Exception e) { _console.TraceData(TraceEventType.Error, _traceEventPurchase, e); } finally { _console.TraceEvent(TraceEventType.Stop, _traceEventPurchase, GetEventName(_traceEventPurchase) + " completed: " + _purchaseProductId); } }
/// <summary> /// Initializes a new instance of the <see cref="PurchaseFailedEventArgs"/> class. /// </summary> public PurchaseFailedEventArgs(string productId, PurchaseResult result, StorePurchaseError error, Exception e) { ProductId = productId; Result = result; Error = error; Exception = e; }
private void SetPurchaseFailed(IStoreProduct product, StoreTransaction transactionInfo, PurchaseValidationResult validationResult, StorePurchaseError failReason, Exception e = null) { var result = new PurchaseResult(product, transactionInfo, validationResult); if (_purchaseOpCs != null) { if (failReason == StorePurchaseError.UserCanceled) { _purchaseOpCs.SetCanceled(); } else if (e != null) { _purchaseOpCs.SetException(new StorePurchaseException(result, failReason, e)); } else { _purchaseOpCs.SetException(new StorePurchaseException(result, failReason)); } } else { InvokePurchaseFailed(result, failReason, e); ReleaseTransaction(); } }
private void SetPurchaseCompleted(IStoreProduct product, StoreTransaction transactionInfo, PurchaseValidationResult validationResult) { var result = new PurchaseResult(product, transactionInfo, validationResult); if (_purchaseOpCs != null) { _purchaseOpCs.SetResult(result); } else { InvokePurchaseCompleted(result); ReleaseTransaction(); } }
private void InvokePurchaseFailed(PurchaseResult purchaseResult, StorePurchaseError failReason, Exception ex) { var product = purchaseResult.TransactionInfo?.Product; var productId = _purchaseProductId ?? "null"; _console.TraceEvent(TraceEventType.Error, _traceEventPurchase, $"{GetEventName(_traceEventPurchase)} error: {productId}, reason = {failReason}"); if (_observers != null) { lock (_observers) { foreach (var item in _observers) { try { item.OnNext(new PurchaseInfo(productId, purchaseResult, failReason, ex)); } catch (Exception e) { _console.TraceData(TraceEventType.Error, _traceEventPurchase, e); } } } } try { PurchaseFailed?.Invoke(this, new PurchaseFailedEventArgs(productId, purchaseResult, failReason, ex)); } catch (Exception e) { _console.TraceData(TraceEventType.Error, _traceEventPurchase, e); } finally { _console.TraceEvent(TraceEventType.Stop, _traceEventPurchase, GetEventName(_traceEventPurchase) + " failed: " + productId); } }
/// <summary> /// Initializes a new instance of the <see cref="PurchaseCompletedEventArgs"/> class. /// </summary> public PurchaseCompletedEventArgs(PurchaseResult result) { Result = result; }
/// <summary> /// Initializes a new instance of the <see cref="StorePurchaseException"/> class. /// </summary> public StorePurchaseException(PurchaseResult result, StorePurchaseError reason, Exception innerException) : base(reason.ToString(), innerException) { Result = result; Reason = reason; }