Exemple #1
0
    private static void OnTransactionComplete(IOSStoreKitResponse responce)
    {
        Debug.Log("OnTransactionComplete: " + responce.productIdentifier);
        Debug.Log("OnTransactionComplete: state: " + responce.state);

        switch (responce.state)
        {
        case InAppPurchaseState.Purchased:
        case InAppPurchaseState.Restored:
            //Our product been succsesly purchased or restored
            //So we need to provide content to our user depends on productIdentifier
            UnlockProducts(responce.productIdentifier);
            break;

        case InAppPurchaseState.Deferred:
            //iOS 8 introduces Ask to Buy, which lets parents approve any purchases initiated by children
            //You should update your UI to reflect this deferred state, and expect another Transaction Complete  to be called again with a new transaction state
            //reflecting the parent’s decision or after the transaction times out. Avoid blocking your UI or gameplay while waiting for the transaction to be updated.
            break;

        case InAppPurchaseState.Failed:
            //Our purchase flow is failed.
            //We can unlock intrefase and repor user that the purchase is failed.
            Debug.Log("Transaction failed with error, code: " + responce.error.code);
            Debug.Log("Transaction failed with error, description: " + responce.error.description);
            break;
        }

        IOSNativePopUpManager.showMessage("Store Kit Response", "product " + responce.productIdentifier + " state: " + responce.state.ToString());
    }
    private void onProductStateDeferred(string productIdentifier)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = productIdentifier;
        response.state             = InAppPurchaseState.Deferred;

        dispatch(TRANSACTION_COMPLETE, response);
        OnTransactionComplete(response);
    }
Exemple #3
0
    //--------------------------------------
    //  PRIVATE METHODS
    //--------------------------------------

    private void SendTransactionFailEvent(string productIdentifier, string error)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = productIdentifier;
        response.error             = error;


        dispatch(TRANSACTION_FAILED, response);
    }
    private void SendTransactionFailEvent(string productIdentifier, string error)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = productIdentifier;
        response.error             = error;
        response.state             = InAppPurchaseState.Failed;


        dispatch(TRANSACTION_COMPLETE, response);
        OnTransactionComplete(response);
    }
Exemple #5
0
    public void onProductBought(string array)
    {
        string[] data;
        data = array.Split("|" [0]);
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = data [0];
        response.receipt           = data [1];

        lastPurchasedProdcut = response.productIdentifier;
        dispatch(PRODUCT_BOUGHT, response);
    }
Exemple #6
0
    //--------------------------------------
    // IOS Listners
    //--------------------------------------


    private void IOS_OnTransactionComplete(IOSStoreKitResponse responce)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByIOSId(responce.productIdentifier);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.product          = p;
            r.IOS_PurchaseInfo = responce;
            SendPurchaseEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
    private void SendTransactionFailEvent(string productIdentifier, string errorDescribtion, IOSTransactionErrorCode errorCode)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = productIdentifier;
        response.state             = InAppPurchaseState.Failed;


        response.error             = new IOSStoreKitError();
        response.error.description = errorDescribtion;
        response.error.code        = errorCode;



        dispatch(TRANSACTION_COMPLETE, response);
        OnTransactionComplete(response);
    }
    private void FireProductBoughtEvent(string productIdentifier, string receipt, bool IsRestored)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse();

        response.productIdentifier = productIdentifier;
        response.receipt           = receipt;
        if (IsRestored)
        {
            response.state = InAppPurchaseState.Restored;
        }
        else
        {
            response.state = InAppPurchaseState.Purchased;
        }

        lastPurchasedProdcut = response.productIdentifier;
        dispatch(TRANSACTION_COMPLETE, response);
        OnTransactionComplete(response);
    }
Exemple #9
0
    //--------------------------------------
    //  GET/SET
    //--------------------------------------

    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private static void onProductBought(CEvent e)
    {
        IOSStoreKitResponse responce = e.data as IOSStoreKitResponse;

        Debug.Log("STORE KIT GOT BUY: " + responce.productIdentifier);
        Debug.Log("RECIPT: " + responce.receipt);

        switch (responce.productIdentifier)
        {
        case SMALL_PACK:
            //code for adding small game money amount here
            break;

        case NC_PACK:
            //code for unlocking cool item here
            break;
        }


        IOSNativePopUpManager.showMessage("Success", "product " + responce.productIdentifier + " is purchased");
    }
Exemple #10
0
    private static void onTransactionFailed(CEvent e)
    {
        IOSStoreKitResponse responce = e.data as IOSStoreKitResponse;

        IOSNativePopUpManager.showMessage("Fail", responce.error);
    }
	private static void OnTransactionComplete (IOSStoreKitResponse response) {

		Debug.Log("OnTransactionComplete: " + response.productIdentifier);
		Debug.Log("OnTransactionComplete: state: " + response.state);

		switch(response.state) {
		case InAppPurchaseState.Purchased:
		case InAppPurchaseState.Restored:
			//Our product been succsesly purchased or restored
			//So we need to provide content to our user depends on productIdentifier
			UnlockProducts(response.productIdentifier);
			break;
		case InAppPurchaseState.Deferred:
			//iOS 8 introduces Ask to Buy, which lets parents approve any purchases initiated by children
			//You should update your UI to reflect this deferred state, and expect another Transaction Complete  to be called again with a new transaction state 
			//reflecting the parent’s decision or after the transaction times out. Avoid blocking your UI or gameplay while waiting for the transaction to be updated.
			break;
		case InAppPurchaseState.Failed:
			//Our purchase flow is failed.
			//We can unlock intrefase and repor user that the purchase is failed. 
			Debug.Log("Transaction failed with error, code: " + response.error.code);
			Debug.Log("Transaction failed with error, description: " + response.error.description);


			break;
		}

		if(response.state == InAppPurchaseState.Failed) {
			IOSNativePopUpManager.showMessage("Transaction Failed", "Error code: " + response.error.code + "\n" + "Error description:" + response.error.description);
		} else {
			IOSNativePopUpManager.showMessage("Store Kit Response", "product " + response.productIdentifier + " state: " + response.state.ToString());
		}

	}
    //--------------------------------------
    //  PRIVATE METHODS
    //--------------------------------------
    private void SendTransactionFailEvent(string productIdentifier, string error)
    {
        IOSStoreKitResponse response = new IOSStoreKitResponse ();
        response.productIdentifier = productIdentifier;
        response.error =  error;

        dispatch(TRANSACTION_FAILED, response);
    }
    public void onProductBought(string array)
    {
        string[] data;
        data = array.Split("|" [0]);
        IOSStoreKitResponse response = new IOSStoreKitResponse ();
        response.productIdentifier = data [0];
        response.receipt = data [1];

        dispatch(PRODUCT_BOUGHT, response);
    }