示例#1
0
        /// <summary>
        /// Invokes the remote PaymentItems ProcessMessage service call
        /// </summary>
        /// <param name="serviceCommand">PaymentItemCommand</param>
        /// <returns>xml string response from the PaymentItems service call</returns>
        protected override string InvokeServiceCommandHandler(ServiceCommand serviceCommand)
        {
            ServiceCommandSerializer serializer = new ServiceCommandSerializer();
            string xmlPaymentItemsMessage       = serializer.SerializeCommandData(serviceCommand, typeof(PaymentCommand));

            return(mPaymentItemProcess.ProcessMessage(xmlPaymentItemsMessage));
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string selectedItem = "";
                Type   cmdType      = null;

                if (radioButton1.Checked)
                {
                    selectedItem = (string)comboBox1.SelectedItem;
                    CreateTwoFishCommand cmd = new CreateTwoFishCommand();
                    cmdType = cmd.GetType();
                }
                else
                {
                    selectedItem = (string)comboBox3.SelectedItem;
                    CreateHangoutCommand cmd = new CreateHangoutCommand();
                    cmdType = cmd.GetType();
                }

                string selectedUser = (string)comboBox2.SelectedItem;

                if (selectedItem != null)
                {
                    ServiceCommandSerializer paymentSerializer = new ServiceCommandSerializer();

                    PaymentCommand command    = CreateCommand(selectedItem, selectedUser, cmdType, GetSelectedXml());
                    string         xmlCommand = paymentSerializer.SerializeCommandData((ServiceCommand)command, typeof(PaymentCommand));

                    StreamWriter swCommand = new StreamWriter("c:\\twofishCommand.xml");
                    swCommand.Write(xmlCommand);
                    swCommand.Close();

                    command = (PaymentCommand)paymentSerializer.DeserializeCommandData(xmlCommand, typeof(PaymentCommand));

                    PaymentCommand commandSecond = HandleSpecialCommand(command, selectedUser, cmdType);
                    if (commandSecond != null)
                    {
                        command = commandSecond;
                    }

                    PaymentItem paymentItem = new PaymentItem();
                    XmlDocument response    = paymentItem.ProcessMessage(command);

                    response = HandleSpecialResponse(response);

                    StreamWriter swResponse = new StreamWriter("c:\\twofishResponse.xml");
                    swResponse.Write(response.InnerXml);
                    swResponse.Close();

                    DisplayResponse(response);
                }
            }
            catch (Exception ex)
            {
                XmlDocument errorResponse = CreateErrorDoc(ex.Message);
                DisplayResponse(errorResponse);
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandName"></param>
        /// <param name=""></param>
        /// <param name="commandArgs"></param>
        /// <returns></returns>
        public string CreatePaymentCommand(string commandName, Dictionary <string, string> commandArgs)
        {
            string command = "";

            PaymentCommand paymentCommand = null;

            switch (commandName)
            {
            case "GetUserBalance":
                paymentCommand = CreateSimpleCommand("GetUserBalance", commandArgs);
                break;

            case "AddVirtualCoinForUser":
                paymentCommand = AddVirtualCoinForUser(commandArgs);
                break;

            case "GetUserInventory":
                paymentCommand = GetUserInventory(commandArgs);
                break;

            case "GetStoreInventory":
                paymentCommand = GetHangoutStoreInventory(commandArgs);
                break;

            case "PurchaseItems":
                paymentCommand = PurchaseItems(commandArgs);
                break;

            case "PurchaseItemsGift":
                paymentCommand = PurchaseItemsGift(commandArgs);
                break;

            case "GameCurrencyOffers":
                paymentCommand = CreateSimpleCommand("PurchaseOffers", commandArgs);
                break;

            case "PurchaseGameCurrencyPayPal":
                paymentCommand = PurchaseGameCurrencyPayPal(commandArgs);
                break;

            case "PurchaseGameCurrencyCreditCard":
                paymentCommand = PurchaseGameCurrencyCreditCard(commandArgs);
                break;

            case "SecurePaymentInfo":
                paymentCommand = CreateCommandWithNoParams("SecurePaymentInfo");
                break;

            default:
                throw (new Exception("Invalid Payment Items Command"));
            }

            ServiceCommandSerializer serializer = new ServiceCommandSerializer();

            command = serializer.SerializeCommandData(paymentCommand, typeof(PaymentCommand));

            return(command);
        }
示例#4
0
        private XmlDocument ProcessAdminPaymentItem(PaymentCommand paymentCommand, string baseServicesRoot)
        {
            ServiceCommandSerializer serializer = new ServiceCommandSerializer();
            string xmlPaymentItemsMessage       = serializer.SerializeCommandData(paymentCommand, typeof(PaymentCommand));

            UTF8Encoding encoding = new UTF8Encoding();

            Byte[] byteArray = encoding.GetBytes(xmlPaymentItemsMessage);

            WebServiceRequest request = new WebServiceRequest(baseServicesRoot, "PaymentItemsService", "ProcessAdminPaymentItemXml");

            request.AddParam("paymentCommand", byteArray);

            XmlDocument xmlResponse = request.GetWebResponse();

            return(xmlResponse);
        }