Exemplo n.º 1
0
        /// <summary>
        /// Use the payment system to award this account with this number of coins.
        /// </summary>
        /// <param name="serverStateMachine"></param>
        /// <param name="serverAccount"></param>
        /// <param name="totalCoins"></param>
        private void ProcessCoinPayment(ServerAccount serverAccount, int totalCoins, EscrowType escrowType, Guid sessionId)
        {
            NameValueCollection args = new NameValueCollection();

            args.Add("userId", serverAccount.PaymentItemUserId);
            args.Add("amount", totalCoins.ToString());
            args.Add("ipAddress", serverAccount.IpAddress);

            PaymentItemsProcessClientMessage clientMessage = new PaymentItemsProcessClientMessage();
            PaymentCommand cmd = clientMessage.AddVirtualCoinForUser(args);

            mServerStateMachine.PaymentItemsManager.ProcessPaymentCommand(cmd, delegate(string response)
            {
                XmlDocument xmlResponse = new XmlDocument();
                xmlResponse.LoadXml(response);
                //send message to client
                Message processCoinPaymentMessage           = new Message();
                List <object> processCoinPaymentMessageData = new List <object>();
                processCoinPaymentMessageData.Add(escrowType);
                processCoinPaymentMessageData.Add(totalCoins);
                processCoinPaymentMessage.EscrowMessage(processCoinPaymentMessageData);
                processCoinPaymentMessage.Callback = (int)MessageSubType.ProcessEscrowTransaction;

                SendMessageToClient(processCoinPaymentMessage, sessionId);
            });
        }
Exemplo n.º 2
0
        public static void RequestEscrow(EscrowType escrowType)
        {
            ClientMessageProcessor clientMessageProcessor = GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>();
            Message requestEscrowMessage = new Message();

            requestEscrowMessage.Callback = (int)MessageSubType.ProcessEscrowTransaction;
            List <object> messageData = new List <object>();

            messageData.Add(escrowType);
            requestEscrowMessage.EscrowMessage(messageData);

            clientMessageProcessor.SendMessageToReflector(requestEscrowMessage);
        }
Exemplo n.º 3
0
        private void ProcessEscrowTransaction(Message receivedMessage)
        {
            EscrowType escrowType = CheckType.TryAssignType <EscrowType>(receivedMessage.Data[0]);

            switch (escrowType)
            {
            case EscrowType.FashionCityJobCoins:

                int escrowTransactionCoin = CheckType.TryAssignType <int>(receivedMessage.Data[1]);
                // Popup notification of getting PAAAAAAAAAID
                List <object> args = new List <object>();
                args.Add(Translation.ESCROW_RECEIVED_ITEM);
                args.Add(String.Format(Translation.ESCROW_FASHION_CITY_JOB_COINS_RECEIVED, escrowTransactionCoin));
                Hangout.Shared.Action okcb = delegate() { };
                args.Add(okcb);

                GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args);

                break;
            }
        }
Exemplo n.º 4
0
        private void ProcessEscrowTransaction(Message receivedMessage, Guid sessionId)
        {
            EscrowType escrowType = CheckType.TryAssignType <EscrowType>(receivedMessage.Data[0]);

            ServerAccount serverAccount = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(sessionId);

            EscrowManagerServiceAPI.GetEscrowTransactions(serverAccount.FacebookAccountId, 0, escrowType, "", true,
                                                          delegate(XmlDocument responseXml)
            {
                switch (escrowType)
                {
                case EscrowType.FashionCityJobCoins:
                    AwardMinigameCoins(serverAccount, responseXml, EscrowType.FashionCityJobCoins, sessionId);
                    break;

                default:
                    //TODO: log here about invalid callbacks
                    break;
                }
            });
        }
Exemplo n.º 5
0
        public static void GetEscrowTransactions(long toFacebookAccountId, long fromFacebookAccountId, EscrowType transactionType, string timeStamp, bool clearTransactions,
                                                 System.Action <XmlDocument> callback)
        {
            mLogger.DebugFormat("GetEscrowTransactions called to={0} from={1} type={2} ts={3}", toFacebookAccountId, fromFacebookAccountId, transactionType, timeStamp);
            WebServiceRequest request = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Escrow", "GetEscrowTransactions");

            request.AddParam(kToAccountId, toFacebookAccountId.ToString());
            if (fromFacebookAccountId == 0)
            {
                request.AddParam(kFromAccountId, "");
            }
            else
            {
                request.AddParam(kFromAccountId, fromFacebookAccountId.ToString());
            }
            request.AddParam(kTransactionType, transactionType.ToString());
            request.AddParam(kTransactionTimeStamp, timeStamp);
            // Do we want to immediately clear the transactions after getting them?
            if (clearTransactions)
            {
                request.AddParam(kDeleteTransactions, "1");
            }
            else
            {
                request.AddParam(kDeleteTransactions, "0");
            }
            request.GetWebResponseAsync(callback);
        }
Exemplo n.º 6
0
        /// <summary>
        /// After heading back from the db, now process the xml to add up coins,
        /// then clear the escrow db for this account.
        /// </summary>
        /// <param name="serverStateMachine"></param>
        /// <param name="serverAccount"></param>
        /// <param name="responseXml"></param>
        private void AwardMinigameCoins(ServerAccount serverAccount, XmlDocument responseXml, EscrowType escrowType, Guid sessionId)
        {
            int totalCoins = EscrowXmlUtil.GetTotalCoins(responseXml);

            // Clamp to max coins
            totalCoins = Math.Min(MAX_COINS, totalCoins);
            if (totalCoins <= 0)
            {
                // No coins to award, we are done.
                return;
            }
            // Ok, now process the coins
            ProcessCoinPayment(serverAccount, totalCoins, escrowType, sessionId);
        }