Exemplo n.º 1
0
    public void unityProductPurchaseSuccess(PurchaseEventArgs args)
    {
        Product product = args.purchasedProduct;

        string productId      = product.definition.storeSpecificId;
        string productType    = product.definition.type.ToString().ToLower();
        string productReceipt = product.receipt;
        int    quantity       = 1;

        string networkStoreType    = unityNetworkStoreTypeGet();
        string productPurchaseType = unityProductPurchaseTypeGet(productType);

        LogUtil.LogProduct("SCREEN purchased product: " + productId + ", quantity: " + quantity);
        //transaction.base64EncodedTransactionReceipt
        SetContentAccessPermissions(productId);
        Contents.SetContentAccessTransaction(productId, productId, productReceipt, quantity, true);
        purchaseProcessCompleted = true;

        ProductNetworkRecord data =
            ProductNetworkRecord.Create(
                productId,
                "Product Purchase",
                "Product purchased:" + productId,
                true,
                product.ToJson(),
                productReceipt,
                productId,
                quantity,
                ProductNetworkType.typeThirdParty,
                networkStoreType,
                productPurchaseType);

        BroadcastProductNetworksSuccess(data);
    }
Exemplo n.º 2
0
    public void purchaseProduct(string code, int quantity)
    {
#if PURCHASE_USE_APPLE_ITUNES_PRIME31
        StoreKitBinding.purchaseProduct(code, quantity);
#elif PURCHASE_USE_AMAZON_PRIME31
        //AmazonIAP.initiatePurchaseRequest(GamePacks.currentGameBundle + "." + code);
        AmazonIAP.initiatePurchaseRequest(code);
#elif PURCHASE_USE_GOOGLE_PLAY_PRIME31
        GoogleIAB.purchaseProduct(code);
#elif PURCHASE_USE_UNITY
        productManager.PurchaseProduct(code);
#else
        // Web/PC
        purchaseProcessCompleted = true;

        ProductNetworkRecord data =
            ProductNetworkRecord.Create(
                code,
                "Product Purchase",
                "Product purchased:" + code,
                true,
                "TODO",
                "TODO",
                code,
                1,
                ProductNetworkType.typeThirdParty,
                ProductNetworkStoreType.typeAmazon,
                ProductNetworkConsumableType.consumable);

        BroadcastProductNetworksSuccess(data);
#endif
    }
Exemplo n.º 3
0
    public void unityProductPurchaseFailure(Product product, PurchaseFailureReason purchaseFailureReason)
    {
        string productId      = product.definition.storeSpecificId;
        string productType    = product.definition.type.ToString().ToLower();
        string productReceipt = product.receipt;
        int    quantity       = 1;

        string networkStoreType    = unityNetworkStoreTypeGet();
        string productPurchaseType = unityProductPurchaseTypeGet(productType);

        LogUtil.LogProduct("SCREEN purchased product: " + productId + ", quantity: " + quantity);

        purchaseProcessCompleted = true;

        //ProductNetworkRecord data =
        //    ProductNetworkRecord.Create(
        //        productId,
        //        "Product Purchase",
        //        "Product purchased:" + productId,
        //        false,
        //        product.ToJson(),
        //        productReceipt,
        //        productId,
        //        quantity,
        //        ProductNetworkType.typeThirdParty,
        //        networkStoreType,
        //        productPurchaseType);

        ProductNetworkRecord data =
            ProductNetworkRecord.Create(
                productId,
                "Product Purchase FAILED",
                purchaseFailureReason.ToString(),
                false,
                product.ToJson(),
                productReceipt,
                productId,
                quantity,
                ProductNetworkType.typeThirdParty,
                networkStoreType,
                productPurchaseType);

        BroadcastProductNetworksFailed(data);
    }