/// <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;
 }
示例#2
0
        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);
            }
        }
示例#3
0
 /// <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;
 }
        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();
            }
        }