public EditorBillingTransaction(string _productID, System.DateTime _timeUTC, string _transactionID, string _receipt, eBillingTransactionState _transactionState, eBillingTransactionVerificationState _verificationState, string _error)
        {
            ProductIdentifier     = _productID;
            TransactionDateUTC    = _timeUTC;
            TransactionDateLocal  = TransactionDateUTC.ToLocalTime();
            TransactionIdentifier = _transactionID;
            TransactionReceipt    = _receipt;
            TransactionState      = _transactionState;
            VerificationState     = _verificationState;
            Error = _error;

            // Create raw data
            RawPurchaseData = ToJSONObject().ToJSON();
        }
		public EditorBillingTransaction (string _productID, System.DateTime _timeUTC, string _transactionID, string _receipt, eBillingTransactionState _transactionState, eBillingTransactionVerificationState _verificationState, string _error)
		{
			ProductIdentifier		= _productID;
			TransactionDateUTC		= _timeUTC;
			TransactionDateLocal	= TransactionDateUTC.ToLocalTime();
			TransactionIdentifier	= _transactionID;
			TransactionReceipt		= _receipt;
			TransactionState		= _transactionState;
			VerificationState		= _verificationState;
			Error					= _error;
			
			// Create raw data
			RawPurchaseData			= ToJSONObject().ToJSON();
		}
Beispiel #3
0
        private static BillingTransaction CreateTransactionObject(string _productID, eBillingTransactionState _transactionState, string _error)
        {
            BillingTransaction _transaction;

            if (_transactionState == eBillingTransactionState.FAILED)
            {
                _transaction = new BillingTransactionEditor(_productID, System.DateTime.UtcNow, null, null, _transactionState, eBillingTransactionVerificationState.SUCCESS, _error);
            }
            else
            {
                _transaction = new BillingTransactionEditor(_productID, System.DateTime.UtcNow, "transactionIdentifier", "receipt", _transactionState, eBillingTransactionVerificationState.SUCCESS, null);
            }

            return(_transaction);
        }
Beispiel #4
0
        private static BillingTransaction GetTransactionDetails(string _productID, eBillingTransactionState _transactionState, string _error)
        {
            BillingTransaction _transaction;

            if (_transactionState == eBillingTransactionState.FAILED)
            {
                _transaction = new EditorBillingTransaction(_productID, System.DateTime.MinValue, null, null, _transactionState, eBillingTransactionVerificationState.NOT_CHECKED, _error);
            }
            else
            {
                _transaction = new EditorBillingTransaction(_productID, System.DateTime.UtcNow, "transactionIdentifier", "receipt", _transactionState, eBillingTransactionVerificationState.SUCCESS, null);
            }

            return(_transaction);
        }
Beispiel #5
0
        private static SKPaymentTransactionState ConvertToSKTransactionState(eBillingTransactionState _billingTransactionState)
        {
            switch (_billingTransactionState)
            {
            case eBillingTransactionState.PURCHASED:
                return(SKPaymentTransactionState.SKPaymentTransactionStatePurchased);

            case eBillingTransactionState.FAILED:
                return(SKPaymentTransactionState.SKPaymentTransactionStateFailed);

            case eBillingTransactionState.RESTORED:
                return(SKPaymentTransactionState.SKPaymentTransactionStateRestored);
            }

            return(SKPaymentTransactionState.SKPaymentTransactionStateFailed);
        }
Beispiel #6
0
        private void TransactionFinishedEvent(IList _finishedTransactions)
        {
            AddNewResult("New Transaction Event Received. Transactions Received = " + _finishedTransactions.Count);

            //Getting the results of each transaction status.
            foreach (BillingTransaction _eachTransaction in _finishedTransactions)
            {
                //Product ID for which this transaction happened
                string _productIdentifier = _eachTransaction.ProductIdentifier;

                //Time of purchase details
                System.DateTime _transactionDateUTC   = _eachTransaction.TransactionDateUTC;
                System.DateTime _transactionDateLocal = _eachTransaction.TransactionDateLocal;

                //Transaction unique identifier
                string _transactionIdentifier = _eachTransaction.TransactionIdentifier;

                //Receipt and original json data - Required for external Transaction validation
                string _transactionReceipt = _eachTransaction.TransactionReceipt;

                //Fetching Transaction State and Verirification States
                eBillingTransactionState             _transactionState  = _eachTransaction.TransactionState;
                eBillingTransactionVerificationState _verificationState = _eachTransaction.VerificationState;

                //Error description if any
                string _error = _eachTransaction.Error;

                // Raw purchase data
                string _rawPurchaseData = _eachTransaction.RawPurchaseData;


                if (!string.IsNullOrEmpty(_error))
                {
                    AppendResult("Error Description = " + _error);
                }

                AppendResult("Product Identifier = " + _productIdentifier);
                AppendResult("Transaction State " + _transactionState);
                AppendResult("Transaction Verification State " + _verificationState);
                AppendResult("Transaction Date[UTC] = " + _transactionDateUTC);
                AppendResult("Transaction Date[Local] = " + _transactionDateLocal);
                AppendResult("Transaction Identifier = " + _transactionIdentifier);
                AppendResult("Transaction Receipt = " + _transactionReceipt);
                AppendResult("Raw Purchase Data = " + _rawPurchaseData);
            }
        }
Beispiel #7
0
        /*
         * The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), or 2 (refunded). - Google doc
         */
        private static eBillingTransactionState GetConvertedPurchaseState(int _stateInt)
        {
            eBillingTransactionState _state = eBillingTransactionState.FAILED;

            if (_stateInt == -1 || _stateInt == 1)
            {
                _state = eBillingTransactionState.FAILED;
            }
            else if (_stateInt == 0)
            {
                _state = eBillingTransactionState.PURCHASED;
            }
            else if (_stateInt == 2)
            {
                _state = eBillingTransactionState.REFUNDED;
            }
            else if (_stateInt == 3)
            {
                _state = eBillingTransactionState.RESTORED;
            }
            return(_state);
        }
        /*
         * The purchase state of the order.
         */
        private static eBillingTransactionState GetTransactionState(string _transactionState)
        {
            eBillingTransactionState _state = eBillingTransactionState.FAILED;

            if (_transactionState.Equals(kPurchaseFailed))
            {
                _state = eBillingTransactionState.FAILED;
            }
            else if (_transactionState.Equals(kPurchaseSuccess))
            {
                _state = eBillingTransactionState.PURCHASED;
            }
            else if (_transactionState.Equals(kPurchaseRefunded))
            {
                _state = eBillingTransactionState.REFUNDED;
            }
            else if (_transactionState.Equals(kPurchaseRestored))
            {
                _state = eBillingTransactionState.RESTORED;
            }
            return(_state);
        }
Beispiel #9
0
        private static int GetConvertedPurchaseState(eBillingTransactionState _state)
        {
            int _stateInt = -1;

            if (_state == eBillingTransactionState.FAILED)
            {
                _stateInt = 1;
            }
            else if (_state == eBillingTransactionState.PURCHASED)
            {
                _stateInt = 0;
            }
            else if (_state == eBillingTransactionState.REFUNDED)
            {
                _stateInt = 2;
            }
            else if (_state == eBillingTransactionState.RESTORED)
            {
                _stateInt = 3;
            }

            return(_stateInt);
        }
        private static string GetTransactionState(eBillingTransactionState _state)
        {
            string _transactionState = kPurchaseFailed;

            if (_state == eBillingTransactionState.FAILED)
            {
                _transactionState = kPurchaseFailed;
            }
            else if (_state == eBillingTransactionState.PURCHASED)
            {
                _transactionState = kPurchaseSuccess;
            }
            else if (_state == eBillingTransactionState.REFUNDED)
            {
                _transactionState = kPurchaseRefunded;
            }
            else if (_state == eBillingTransactionState.RESTORED)
            {
                _transactionState = kPurchaseRestored;
            }

            return(_transactionState);
        }
		private static SKPaymentTransactionState ConvertToSKTransactionState (eBillingTransactionState _billingTransactionState)
		{
			switch (_billingTransactionState)
			{
			case eBillingTransactionState.PURCHASED:
				return SKPaymentTransactionState.SKPaymentTransactionStatePurchased;
				
			case eBillingTransactionState.FAILED:
				return SKPaymentTransactionState.SKPaymentTransactionStateFailed;
				
			case eBillingTransactionState.RESTORED:
				return SKPaymentTransactionState.SKPaymentTransactionStateRestored;
			}
			
			return SKPaymentTransactionState.SKPaymentTransactionStateFailed;
		}
        private static int GetConvertedPurchaseState(eBillingTransactionState _state)
        {
            int  _stateInt = -1;

            if (_state == eBillingTransactionState.FAILED)
            {
                _stateInt = 1;
            }
            else if(_state == eBillingTransactionState.PURCHASED)
            {
                _stateInt = 0;
            }
            else if(_state == eBillingTransactionState.REFUNDED)
            {
                _stateInt = 2;
            }
            else if(_state == eBillingTransactionState.RESTORED)
            {
                _stateInt = 3;
            }

            return _stateInt;
        }
		private static BillingTransaction GetTransactionDetails (string _productID, eBillingTransactionState _transactionState, string _error)
		{
			BillingTransaction _transaction;

			if (_transactionState == eBillingTransactionState.FAILED)
			{
				_transaction = new BillingTransaction(_productID, System.DateTime.MinValue, null, null, _transactionState, eBillingTransactionVerificationState.NOT_CHECKED, _error);
			}
			else
			{
				_transaction = new BillingTransaction(_productID, System.DateTime.UtcNow, "transactionIdentifier", "receipt", _transactionState, eBillingTransactionVerificationState.SUCCESS, null);
			}

			return _transaction;
		}