protected void sendPlayerInventoryResponse(List <PurchaseInfo> pil, CommerceError cError = null)
 {
     if (PlayerInventoryResponse != null)
     {
         CommerceLog("sendPlayerInventoryResponse: not null");
         if (cError == null)
         {
             cError = new CommerceError();
         }
         PlayerInventoryResponse(pil, cError);
     }
     else
     {
         CommerceLog("sendPlayerInventoryResponse: is null");
     }
 }
 protected void sendUnexpectedPurchaseResponse(PurchaseInfo pi, SkuInfo si, CommerceError cError = null)
 {
     if (PurchaseResponse != null)
     {
         CommerceLog("sendUnexpectedPurchaseResponse: not null");
         if (cError == null)
         {
             cError = new CommerceError();
         }
         UnexpectedPurchaseResponse(pi, si, cError);
     }
     else
     {
         CommerceLog("sendUnexpectedPurchaseResponse: listner is null and not pointing to anything");
     }
 }
 protected void sendInventoryResponse(List <SkuInfo> sil, CommerceError cError = null)
 {
     if (SkuInventoryResponse != null)
     {
         CommerceLog("sendInventoryResponse: not null");
         if (cError == null)
         {
             cError = new CommerceError();
         }
         SkuInventoryResponse(sil, cError);
     }
     else
     {
         CommerceLog("sendInventoryResponse: is null");
     }
 }
    public virtual void PurchaseProduct(string product, string payload)
    {
        CommerceError commerceError = null;

        CommerceLog("PurchaseProduct: Purchasing product " + product + ", with payload " + payload);
        if (!IsBillingSupported())
        {
            commerceError = new CommerceError(100, "Billing Not Supported");
            sendPurchaseResponse(commerceError);
            return;
        }
        Product productByKey = GetProductByKey(product);

        if (productByKey == null)
        {
            commerceError = new CommerceError(306, "Product key' " + product + "' Not Found");
            sendPurchaseResponse(commerceError);
            return;
        }
        if (!productByKey.IsPurchasable())
        {
            commerceError = new CommerceError(307, "Product key' " + product + "' Not Purchasable. No store information retrieved?");
            sendPurchaseResponse(commerceError);
            return;
        }
        if (payload != null && payload != "")
        {
            CommerceLog("PurchaseProduct: Triggering purchase product with payload");
            PurchaseProductFromStore(productByKey.GetStoreSKU(), payload);
        }
        else
        {
            CommerceLog("PurchaseProduct: Triggering purchase product without payload");
            PurchaseProductFromStore(productByKey.GetStoreSKU());
        }
        CommerceLog("PurchaseProduct: Finishing purchasing " + product);
    }
            /// <summary>
            /// Tries to deserialize an JSON string into a retail proxy exception, and suppresses any exceptions, if any.
            /// </summary>
            /// <param name="source">The JSON string.</param>
            /// <param name="exception">The retail proxy exception instance.</param>
            /// <returns>True, if the exception could be deserialized from the input; False, otherwise.</returns>
            internal static bool TryDeserializeFromJsonString(string source, out RetailProxyException exception)
            {
                ThrowIf.Null(source, "source");

                exception = default(RetailProxyException);

                try
                {
                    // Deserializes to a CommerceError object.
                    CommerceError error = JsonConvert.DeserializeObject <CommerceError>(
                        source,
                        DefaultJsonSerializerSettings.Value);

                    // Cannot deserialize the input to a CommerceError.
                    if (error == null ||
                        string.IsNullOrWhiteSpace(error.TypeName) ||
                        error.Exception == null)
                    {
                        return(false);
                    }

                    // Then, based on the type of the exception, deserializes to the actual exception.
                    string typeName = error.TypeName.Replace(CommerceExceptionTypeName, RetailProxyExceptionTypeName);

                    exception = JsonConvert.DeserializeObject(
                        error.Exception,
                        KnownCommerceExceptionTypes.Value[typeName],
                        DefaultJsonSerializerSettings.Value) as RetailProxyException;

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
 public RestoreVerifiedError(CommerceError error)
 {
     Error = error;
 }
 public ProductsLoadedError(CommerceError error)
 {
     Error = error;
 }
 public PurchaseVerifiedError(CommerceError error)
 {
     Error = error;
 }
    protected void sendBillingEnabledResponse(bool success)
    {
        CommerceError cError = new CommerceError();

        sendBillingEnabledResponse(success, cError);
    }
 protected void sendBillingEnabledResponse(CommerceError cError)
 {
     sendBillingEnabledResponse(success: false, cError);
 }
 protected void sendPurchaseVerifiedResponse(CommerceError cError)
 {
     sendPurchaseVerifiedResponse(success: false, cError);
 }
 protected void sendPurchaseRestoreResponse(List <PurchaseInfo> pil, List <SkuInfo> sil, CommerceError cError = null)
 {
     if (PurchaseRestoreResponse != null)
     {
         CommerceLog("sendPurchaseRestoreResponse: not null");
         if (cError == null)
         {
             cError = new CommerceError();
         }
         PurchaseRestoreResponse(pil, sil, cError);
     }
     else
     {
         CommerceLog("sendPurchaseRestoreResponse: is null");
     }
 }
 protected void sendPurchaseRestoreResponse(CommerceError cError)
 {
     sendPurchaseRestoreResponse(null, null, cError);
 }
 protected void sendPlayerInventoryResponse(CommerceError cError)
 {
     sendPlayerInventoryResponse(null, cError);
 }
 public BillingEnabledError(CommerceError error)
 {
     Error = error;
 }
    protected void sendPurchaseVerifiedResponse(bool success)
    {
        CommerceError cError = new CommerceError();

        sendPurchaseVerifiedResponse(success, cError);
    }
 protected void sendUnexpctedPurchaseResponse(CommerceError cError)
 {
     sendUnexpectedPurchaseResponse(null, null, cError);
 }