Example #1
0
        /// <summary>
        /// Get the Store Inventory (Offers)
        /// </summary>
        /// <param name="storeName">The name of store to retreive the offers from</param>
        /// <returns>XMLDocument containing the Store Inventory (Offers)</returns>
        public XmlDocument GetStoreInventory(string storeName, ResultFilter filter)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Store";
                cmd.Verb = "FindStore";

                cmd.Parameters.Add("storeName", storeName);

                cmd.Parameters.Add("itemTypeNames", filter.ItemTypeNames);
                cmd.Parameters.Add("startIndex", filter.StartIndex);
                cmd.Parameters.Add("blockSize", filter.BlockSize);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
            }

            catch (Exception ex)
            {
                logError("GetStoreInventory", ex);
            }

            return(response);
        }
Example #2
0
        private PaymentCommand  CreateCommand(string commandName, string userId, Type cmdType, XmlDocument arg2)
        {
            PaymentCommand paymentCommand = null;

            try
            {
                string command = commandName.Replace(" ", "");

                MethodInfo info = cmdType.GetMethod(command);

                Object invokeParam1 = Activator.CreateInstance(cmdType);

                int numArgs = info.GetParameters().Length;

                object[] args = new object[numArgs];
                args[0] = userId;

                if (numArgs > 1)
                {
                    args[1] = this;
                }
                if (numArgs > 2)
                {
                    args[2] = arg2;
                }

                paymentCommand = (PaymentCommand)info.Invoke(invokeParam1, args);
            }

            catch { }

            return(paymentCommand);
        }
Example #3
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);
            });
        }
Example #4
0
        /// <summary>
        /// Update the users email address at twofish
        /// </summary>
        /// <param name="userInfo">UserInfo containing tne userId, ipAddressm and emailAddress</param>
        /// <returns>The xml results document containing the email address</returns>
        public XmlDocument UpdateUserEmail(UserInfo userInfo)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();

                cmd.Noun = "Users";
                cmd.Verb = "UpdateUser";

                cmd.Parameters.Add("userId", userInfo.UserId);
                cmd.Parameters.Add("ipAddress", userInfo.IPAddress);
                cmd.Parameters.Add("emailAddress", userInfo.EmailAddress);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());

                string userIdReturned = response.SelectSingleNode("/Response/user").Attributes["id"].InnerText;
                string emailAddress   = response.SelectSingleNode("/Response/user").Attributes["emailAddress"].InnerText;

                response.LoadXml(String.Format("<response noun='Users' verb='UserInfo'><user id='{0}' emailAddress='{1}' /></response>", userIdReturned, emailAddress));
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("UpdateUserEmail", ex);
            }

            return(response);
        }
Example #5
0
        async void Payment()
        {
            if (Cash < TotalPrice)
            {
                Application.Current.MainPage.DisplayAlert("Invalid Cash Amount", "Invalid cash amount, Please try again", "Ok");
                return;
            }
            Change = Cash - TotalPrice;
            PaymentCommand payment = new PaymentCommand()
            {
                TotalDiscount = TotalDiscount,
                ItemList      = CurrentTicket.ToList(),
                PaymentType   = Api.ViewModels.Enixer_Enumerations.EP_PaymentTypeEnum.Cash,
                ShiftId       = App.OpenShiftId,
                StoreEmail    = App.Email,
                Total         = TotalPrice
            };

            payment.PaymentType = Api.ViewModels.Enixer_Enumerations.EP_PaymentTypeEnum.Cash;
            ReceiptViewModel resultW = _service.AddPayment(payment);

            if (resultW != null)
            {
                await PopupNavigation.Instance.PushAsync(new ShowChange(this));

                await Application.Current.MainPage.Navigation.PushAsync(new ReceiptPage(this));
            }
            else
            {
                Application.Current.MainPage.DisplayAlert("Payment Error", "Payment not completed please try again.", "Ok");
            }
        }
Example #6
0
        /// <summary>
        /// Get the users secure key
        /// </summary>
        /// <param name="userId">The userId</param>
        /// <returns>The users secure key</returns>
        private string GetUsersSecureKey(string userId, string ipAddress)
        {
            string secureKey = "";

            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Users";
                cmd.Verb = "SecureKey";

                cmd.Parameters.Add("userId", userId);
                cmd.Parameters.Add("ipAddress", ipAddress);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());

                secureKey = response.SelectSingleNode("/Response/user").Attributes["secureKey"].InnerText;
            }

            catch (Exception ex)
            {
                logError("GetUsersSecureKey", ex);
            }

            return(secureKey);
        }
        private PaymentCommand CreatePurchaseGameCurrencyCreditCard(string transactionId, string userId, string offerId, CreditCardInfo creditCardInfo, string ipAddress)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "HangoutPurchase";
            cmd.Verb = "PurchaseGameCurrencyCreditCard";

            cmd.Parameters.Add("userId", userId);
            cmd.Parameters.Add("ipAddress", ipAddress);
            cmd.Parameters.Add("offerId", offerId);
            cmd.Parameters.Add("externalTxnId", transactionId);
            cmd.Parameters.Add("creditCardNumber", creditCardInfo.CreditCardnumber);
            cmd.Parameters.Add("creditCardType", creditCardInfo.CreditCardtype);
            cmd.Parameters.Add("expireDate", creditCardInfo.ExpireDate);
            cmd.Parameters.Add("securityCode", creditCardInfo.SecurityCode);
            cmd.Parameters.Add("firstName", creditCardInfo.FirstName);
            cmd.Parameters.Add("middleName", creditCardInfo.MiddleName);
            cmd.Parameters.Add("lastName", creditCardInfo.LastName);
            cmd.Parameters.Add("address", creditCardInfo.Address);
            cmd.Parameters.Add("city", creditCardInfo.City);
            cmd.Parameters.Add("state", creditCardInfo.StateProvince);
            cmd.Parameters.Add("zipCode", creditCardInfo.ZipCode);
            cmd.Parameters.Add("countryCode", creditCardInfo.CountryCode);
            cmd.Parameters.Add("phoneNumber", creditCardInfo.PhoneNumber);

            return(cmd);
        }
Example #8
0
        /// <summary>
        /// Get the store PaymentItems response and update the store data with a new response
        /// </summary>
        /// <param name="storeName">The name of the store</param>
        private void GetAndUpdateTheStoreInventory(string storeName)
        {
            try
            {
                PaymentItemsProcess      paymentItemProcess = new PaymentItemsProcess();
                ServiceCommandSerializer serializer         = new ServiceCommandSerializer();

                PaymentCommand paymentItemCommand = new PaymentCommand();
                paymentItemCommand.Verb = "GetStoreInventory";

                // Add stage name to storeName in request.   Don't store the stage name in variable, so the code doesn't have to care about stage.
                string stage = System.Configuration.ConfigurationSettings.AppSettings["Stage"];
                paymentItemCommand.Parameters.Add("storeName", storeName + "_" + stage);
                string xmlPaymentItemsMessage = serializer.SerializeCommandData(paymentItemCommand, typeof(PaymentCommand));
                string response = paymentItemProcess.ProcessMessageBlocking(xmlPaymentItemsMessage, null, null);

                XmlDocument xmlResponse = new XmlDocument();
                xmlResponse.LoadXml(response);

                xmlResponse = RemoveItemTypes(xmlResponse);
                xmlResponse = AddAssetsToStoreInventoryItems(xmlResponse, storeName);

                CopyResponseToStoreData(xmlResponse, storeName);
            }

            catch (Exception ex)
            {
                mLogger.Error(String.Format("Error in GetAndUpdateTheStoreInventory for Store {0} Error: {1} ", storeName, ex));
            }
        }
        private string GambitAddMoneyToAccount(XmlDocument xmlInfo, string baseServicesRoot)
        {
            string response = "ERROR:RESEND";

            try
            {
                string userId     = XmlUtil.GetAttributeFromXml(xmlInfo, "/Response/data[@name='paymentItemsUserId']", "value", "");
                string cashAmount = XmlUtil.GetAttributeFromXml(xmlInfo, "/Response/data[@name='amount']", "value", "");
                string ipAddress  = XmlUtil.GetAttributeFromXml(xmlInfo, "/Response/data[@name='ipAddress']", "value", "");

                if (ValidateGambitValues(userId, cashAmount, ipAddress))
                {
                    PaymentCommand paymentCommand = CreatePurchaseGameCurrencyGambit(userId, cashAmount, ipAddress);
                    XmlDocument    xmlResponse    = ProcessPaymentItem(paymentCommand, baseServicesRoot);

                    if (xmlResponse.SelectSingleNode("/Response/user/accounts/account[@currencyName='HOUTS']").Attributes["balance"] != null)
                    {
                        response = "OK";
                    }
                }
                else
                {
                    response = "ERROR:FATAL";
                }
            }

            catch (Exception ex)
            {
                mErrorLogger.Error("AddMoneyToAccount Error", ex);
            }

            return(response);
        }
Example #10
0
        /// <summary>
        /// Converts a PurchaseGameCurrencyCreditCard client command to a PaymentCommmand
        /// </summary>
        /// <param name="commandArgs">The command arguments</param>
        /// <returns>PurchaseGameCurrencyCreditCard PaymentCommand</returns>
        public PaymentCommand PurchaseGameCurrencyCreditCard(NameValueCollection commandArgs)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "HangoutPurchase";
            cmd.Verb = "PurchaseGameCurrencyCreditCard";

            string userId = ConvertSessionIdToUserId(GetStringValueFromArgs(commandArgs, "userSession", ""));

            cmd.Parameters.Add("userId", userId);
            cmd.Parameters.Add("offerId", GetStringValueFromArgs(commandArgs, "offerId", ""));
            cmd.Parameters.Add("ipAddress", GetStringValueFromArgs(commandArgs, "ipAddress", ""));
            cmd.Parameters.Add("secureKey", GetStringValueFromArgs(commandArgs, "secureKey", ""));
            cmd.Parameters.Add("creditCardNumber", GetStringValueFromArgs(commandArgs, "creditCardNumber", ""));
            cmd.Parameters.Add("creditCardType", GetStringValueFromArgs(commandArgs, "creditCardType", ""));
            cmd.Parameters.Add("expireDate", GetStringValueFromArgs(commandArgs, "expireDate", ""));
            cmd.Parameters.Add("securityCode", GetStringValueFromArgs(commandArgs, "securityCode", ""));
            cmd.Parameters.Add("firstName", GetStringValueFromArgs(commandArgs, "firstName", ""));
            cmd.Parameters.Add("lastName", GetStringValueFromArgs(commandArgs, "lastName", ""));
            cmd.Parameters.Add("address", GetStringValueFromArgs(commandArgs, "address", ""));
            cmd.Parameters.Add("city", GetStringValueFromArgs(commandArgs, "city", ""));
            cmd.Parameters.Add("state", GetStringValueFromArgs(commandArgs, "state", ""));
            cmd.Parameters.Add("zipCode", GetStringValueFromArgs(commandArgs, "zipCode", ""));
            cmd.Parameters.Add("countryCode", GetStringValueFromArgs(commandArgs, "countryCode", ""));
            cmd.Parameters.Add("phoneNumber", GetStringValueFromArgs(commandArgs, "phoneNumber", ""));

            cmd.Parameters.Add("externalTxnId", Guid.NewGuid().ToString());

            return(cmd);
        }
Example #11
0
        /// <summary>
        /// Checks if this PaymentCommand is a special command that is a cached command
        /// </summary>
        /// <param name="command">PaymentCommand</param>
        /// <param name="serverStores">The itemObject pointer, to verify that it is not null</param>
        /// <returns>true of it is a cached message, otherwise false</returns>
        public bool IsCachedMessage(PaymentCommand command, object itemObject)
        {
            bool isCachedMessage = false;
            Dictionary <string, string> specialCommands = new Dictionary <string, string>();

            specialCommands.Add("GetStoreInventory", "HangoutStore");
            string value = SpecialCommand(command.Noun, command.Verb, specialCommands);

            switch (value)
            {
            case "GetStoreInventory":
                if (itemObject != null)
                {
                    string       storeName    = GetStringValueFromArgs(command.Parameters, "storeName", "");
                    ServerStores serverStores = (ServerStores)itemObject;
                    if (serverStores.IsCachedStore(storeName))
                    {
                        isCachedMessage = true;
                    }
                }
                break;
            }


            return(isCachedMessage);
        }
Example #12
0
        /// <summary>
        /// Get User Balance for all there accounts.
        /// </summary>
        /// <param name="userId">userId</param>
        /// <returns>XML Document returning users account balances</returns>
        public XmlDocument GetUserBalance(string userId)
        {
            XmlDocument response = null;

            try
            {
                logDebug("GetUserBalance", userId);
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Users";
                cmd.Verb = "UserInfo";

                cmd.Parameters.Add("userId", userId);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());

                response = RemoveResponseNodes(response, "/Response/user", "accounts");
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("GetUserBalance", ex);
            }

            return(response);
        }
Example #13
0
        public void QrPaymentComplete()
        {
            PaymentCommand payment = new PaymentCommand()
            {
                TotalDiscount = TotalDiscount,
                ItemList      = CurrentTicket.ToList(),
                ShiftId       = App.OpenShiftId,
                StoreEmail    = App.Email,
                Total         = TotalPrice
            };

            payment.PaymentType = Api.ViewModels.Enixer_Enumerations.EP_PaymentTypeEnum.Qr;
            ReceiptViewModel resultW = _service.AddPayment(payment);

            if (resultW != null)
            {
                PopupNavigation.PushAsync(new Error(new ErrorViewModel("Payment Completed", 3)));
                Application.Current.MainPage.Navigation.PushAsync(new ReceiptPage(this));
            }
            else
            {
                Application.Current.MainPage.DisplayAlert("Payment Error", "Payment not completed please try again.", "Ok");
            }
            PopupNavigation.PopAllAsync();
        }
Example #14
0
        /// <summary>
        /// Purchase Game Currency using PayPal
        /// </summary>
        /// <param name="userId">UserId and IP address</param>
        /// <param name="purchaseInfo">OfferId and ExternalTxnId</param>
        /// <returns>XML Response document with PayPal url to call to have the user continue the transaction.</returns>
        public XmlDocument PurchaseGameCurrencyPayPal(UserId userId, PurchaseInfo purchaseInfo)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Purchase";
                cmd.Verb = "PayPalCheckout";

                cmd.Parameters.Add("userId", userId.ToString());
                cmd.Parameters.Add("ipAddress", userId.IPAddress);
                cmd.Parameters.Add("offerId", purchaseInfo.OfferId);
                cmd.Parameters.Add("externalTxnId", purchaseInfo.ExternalTxnId);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
            }

            catch (Exception ex)
            {
                logError("PurchaseGameCurrencyPayPal", ex);
                response = new SimpleResponse(MethodBase.GetCurrentMethod(), "purchaseResult", "Error");
            }

            return(response);
        }
Example #15
0
        public PaymentCommand PurchaseGameCurrency(string userId)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "HangoutPurchase";
            cmd.Verb = "PurchaseGameCurrencyCreditCard";

            string secureKey = "";

            cmd.Parameters.Add("userId", GetUserId(userId));
            cmd.Parameters.Add("secureKey", secureKey);
            cmd.Parameters.Add("offerId", "29");
            cmd.Parameters.Add("externalTxnId", Guid.NewGuid().ToString());
            cmd.Parameters.Add("ipAddress", "64.115.150.114");
            cmd.Parameters.Add("creditCardNumber", "4159662533655864");
            cmd.Parameters.Add("creditCardType", "VISA");
            cmd.Parameters.Add("expireDate", "092018");
            cmd.Parameters.Add("securityCode", "000");
            cmd.Parameters.Add("firstName", "Test");
            cmd.Parameters.Add("lastName", "User");
            cmd.Parameters.Add("address", "1 Main St");
            cmd.Parameters.Add("city", "San Jose");
            cmd.Parameters.Add("state", "CA");
            cmd.Parameters.Add("zipCode", "95131");
            cmd.Parameters.Add("countryCode", "US");
            cmd.Parameters.Add("phoneNumber", "1234567890");

            return(cmd);
        }
Example #16
0
        /// <summary>
        /// Call the Twofish service to add funds to the user account
        /// </summary>
        /// <param name="creditAccountId">account to credit</param>
        /// <param name="debitAccountId">account to debit</param>
        /// <param name="amount">amount to transfer from debit to credit account</param>
        /// <param name="userIPAddress">users IP Address</param>
        /// <returns>XML Document with the new balances</returns>
        private XmlDocument TransferFundsForUser(string creditAccountId, string debitAccountId, string amount, string userIPAddress)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();

                cmd.Noun = "Transfer";
                cmd.Verb = "CreateTransfer";

                cmd.Parameters.Add("amount", amount);
                cmd.Parameters.Add("debitAccountId", debitAccountId);
                cmd.Parameters.Add("creditAccountId", creditAccountId);
                cmd.Parameters.Add("transferType", "INITIAL_AMOUNT");
                cmd.Parameters.Add("ipAddress", userIPAddress);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("AddFundsForUser", ex);
            }

            return(response);
        }
        public IActionResult Payment([FromBody] PaymentCommand command)
        {
            string  email         = command.Email;
            string  merchantAccNo = command.MerchantAccountNo;
            decimal pay           = command.Pay;

            if (Int32.Parse(merchantAccNo.Substring(0, 2)) != (int)EW_Enumerations.EW_UserTypeEnum.Merchant)
            {
                return(BadRequest());
            }

            bool isEmail    = _userService.ExistingEmail(email);
            bool isMerchant = _userService.ExistAccountNo(merchantAccNo);

            if (!isEmail || !isMerchant)
            {
                return(BadRequest());
            }

            PaymentDto payment = _transactionService.Payment(email, merchantAccNo, pay);

            if (payment == null)
            {
                return(BadRequest());
            }

            PaymentViewModel result = new PaymentViewModel()
            {
                Reference      = payment.Reference,
                CreateDatetime = payment.CreateDatetime
            };

            return(Ok(result));
        }
        /// <summary>
        /// The Sorting, Filtering and Paging will be done post retrieve data from PaymentItems
        /// Therefore the GetStoreInventory will return all rows.
        /// </summary>
        /// <param name="command">PaymentCommand for the GetStoreInventory</param>
        /// <returns>PaymentCommand without the filtering for the GetStoreInventory</returns>
        public static PaymentCommand RemoveFilterFromCommand(PaymentCommand command)
        {
            PaymentCommand newCommand = new PaymentCommand();

            newCommand.Noun = command.Noun;
            newCommand.Verb = command.Verb;

            foreach (string key in command.Parameters.AllKeys)
            {
                switch (key)
                {
                case "itemTypeNames":
                case "filter":
                case "orderBy":
                case "startIndex":
                case "blockSize":
                    break;

                default:
                    newCommand.Parameters.Add(key, command.Parameters[key]);
                    break;
                }
            }

            return(newCommand);
        }
Example #19
0
        /// <summary>
        /// HealthCheck call to PaymentItems to check if the system is operational
        /// </summary>
        /// <returns>XmlDocument document containing the HealthCheck information</returns>
        public XmlDocument HealthCheck()
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Widget";
                cmd.Verb = "HealthCheck";

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
                AddAttribute(response, "/Response/HealthCheck", "PaymentItems", "OK");

                string buildInfo = GetTwoFishBuildInfo();
                AddAttribute(response, "/Response/HealthCheck", "BuildInfo", buildInfo);
            }

            catch (Exception ex)
            {
                logError("HealthCheck", ex);
                response.Load("<Response noun='HangoutInfo' verb='HealthCheck'><HealthCheck PaymentItems='Error' Twofish='Unknown' /></Response>");
            }

            return(response);
        }
        public PaymentCommand CreateItem(string userId)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "Items";
            cmd.Verb = "CreateItem";

            string itemName       = "Blue Jeans New";
            string itemTypeName   = "Pants";
            string buttonName     = "Blue Jeans New";
            string description    = "Blue Jeans New";
            string smallImageUrl  = "";
            string mediumImageUrl = "";
            string largeImageUrl  = "";
            string available      = "10";

            cmd.Parameters.Add("itemName", itemName);
            cmd.Parameters.Add("itemTypeName", itemTypeName);
            cmd.Parameters.Add("buttonName", buttonName);
            cmd.Parameters.Add("description", description);
            cmd.Parameters.Add("smallImageUrl", smallImageUrl);
            cmd.Parameters.Add("mediumImageUrl", mediumImageUrl);
            cmd.Parameters.Add("largeImageUrl", largeImageUrl);
            cmd.Parameters.Add("available", available);
            cmd.Parameters.Add("ipAddress", GetMyIpAddress());

            return(cmd);
        }
        /// <summary>
        /// Call twoFish to complete the transaction.
        /// </summary>
        /// <param name="xmlResult">The XML response documents from PayPal.</param>
        /// <returns>XmlDocument containing the response after the PayPal transaction is completed.</returns>
        private XmlDocument PayPalPurchase(XmlDocument xmlResult)
        {
            XmlDocument response = null;

            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "Purchase";
            cmd.Verb = "PayPalPurchase";

            string externalTransactionId = GetXMLDocumentParameter(xmlResult, "/Response/data[@name='externalTxnId']", "value", "");

            cmd.Parameters.Add("userId", GetXMLDocumentParameter(xmlResult, "/Response/data[@name='userId']", "value", ""));
            cmd.Parameters.Add("offerId", GetXMLDocumentParameter(xmlResult, "/Response/data[@name='offerId']", "value", ""));
            cmd.Parameters.Add("token", GetXMLDocumentParameter(xmlResult, "/Response/data[@name='token']", "value", ""));
            cmd.Parameters.Add("payerId", GetXMLDocumentParameter(xmlResult, "/Response/data[@name='payerId']", "value", ""));
            cmd.Parameters.Add("externalTxnId", externalTransactionId);
            cmd.Parameters.Add("ipAddress", GetXMLDocumentParameter(xmlResult, "/Response/data[@name='ipAddress']", "value", ""));

            response = CallTwoFishService(cmd);

            if (response.SelectSingleNode("/Response/purchaseResult") == null)
            {
                AddAttribute(response, "/Response", "externalTxnId", externalTransactionId);
            }

            return(response);
        }
        public PaymentCommand CreditCardPurchase(string userId, Form1 form1, XmlDocument oldCommand)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "Purchase";
            cmd.Verb = "PurchaseCreditCard";

            userId = GetUserId(userId, form1.GetUserList);
            string hangoutAccountId = GetHangoutId(userId, form1.GetUserList);
            string secureKey        = GetSecureKey(hangoutAccountId);

            cmd.Parameters.Add("userId", userId);
            cmd.Parameters.Add("secureKey", secureKey);
            cmd.Parameters.Add("offerId", "29");
            cmd.Parameters.Add("externalTxnId", Guid.NewGuid().ToString());
            cmd.Parameters.Add("ipAddress", GetMyIpAddress());
            cmd.Parameters.Add("creditCardNumber", "4108026996140735");
            cmd.Parameters.Add("creditCardType", "VISA");
            cmd.Parameters.Add("expireDate", "072019");
            cmd.Parameters.Add("securityCode", "000");
            cmd.Parameters.Add("firstName", "Test");
            cmd.Parameters.Add("lastName", "User");
            cmd.Parameters.Add("address", "1 Main St");
            cmd.Parameters.Add("city", "San Jose");
            cmd.Parameters.Add("state", "CA");
            cmd.Parameters.Add("zipCode", "95131");
            cmd.Parameters.Add("countryCode", "US");
            cmd.Parameters.Add("phoneNumber", "4086780945");

            return(cmd);
        }
Example #23
0
        /// <summary>
        /// Create and Exexutes Twofish command to Create a New User
        /// </summary>
        /// <param name="userInfo">Name, IPAddress, CountryCode (optional), ExternalKey (optional), Gender (optional),
        ///  DateOfBirth (optional), EmailAddress (optional), Tags (optional)</param>
        /// <returns>XML Response document with user infomation</returns>
        private XmlDocument CreateNewUserCommand(UserInfo userInfo)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();

                cmd.Noun = "Users";
                cmd.Verb = "CreateUser";

                cmd.Parameters.Add("name", userInfo.Name);
                cmd.Parameters.Add("namespaceId", "0");
                cmd.Parameters.Add("countryCode", userInfo.CountryCode);
                cmd.Parameters.Add("externalKey", userInfo.ExternalKey);
                cmd.Parameters.Add("gender", userInfo.Gender);
                cmd.Parameters.Add("dateOfBirth", userInfo.DateOfBirth);
                cmd.Parameters.Add("emailAddress", userInfo.EmailAddress);
                cmd.Parameters.Add("tags", userInfo.Tags);
                cmd.Parameters.Add("ipAddress", userInfo.IPAddress);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("CreateNewUserCommand", ex);
            }

            return(response);
        }
Example #24
0
        private XmlDocument PurchaseOffers(string verb, UserId userId, string currencyId)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Noun = "Users";
            cmd.Verb = "UserWidget";

            cmd.Parameters.Add("userId", userId.ToString());

            cmd.Parameters.Add("virtualCurrencyId", currencyId);
            XmlDocument serviceResponse    = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());
            XmlNodeList offersNodeList     = serviceResponse.SelectNodes("/Response/userWidgetConfig/offers/offer");
            XmlNode     paymentMethodsNode = serviceResponse.SelectSingleNode("/Response/userWidgetConfig/paymentMethods");

            XmlDocument offerDoc = new XmlDocument();

            offerDoc.LoadXml(String.Format("<Response noun='HangoutPurchase' verb='{0}'><offers></offers></Response>", verb));

            foreach (XmlNode offerNode in offersNodeList)
            {
                string  id            = offerNode.Attributes["id"].InnerText;
                string  description   = offerNode.Attributes["description"].InnerText;
                XmlNode offerNodeItem = GetOfferNode(id, description);
                AppendNode(offerDoc, "/Response/offers", offerNodeItem);
            }

            AppendNode(offerDoc, "/Response", paymentMethodsNode);

            return(offerDoc);
        }
Example #25
0
        /// <summary>
        /// Get User Inventory
        /// </summary>
        /// <param name="userId">userId</param>
        /// <returns>XML Document containing the user inventory</returns>
        public XmlDocument GetUserInventory(string userId, ResultFilter filter)
        {
            XmlDocument response = null;

            try
            {
                PaymentCommand cmd = new PaymentCommand();
                cmd.Noun = "Items";
                cmd.Verb = "ItemInstance";

                cmd.Parameters.Add("userId", userId);

                if (String.IsNullOrEmpty(filter.Filter))
                {
                    filter.Filter = "all";
                }
                cmd.Parameters.Add("filter", filter.Filter);

                // cmd.Parameters.Add("itemTypeName", filter.ItemTypeNames);
                // cmd.Parameters.Add("startIndex", filter.StartIndex);
                // cmd.Parameters.Add("blockSize", filter.BlockSize);

                response = CallTwoFishService(cmd, MethodBase.GetCurrentMethod());

                int         totalItems        = 0;
                XmlNodeList itemInstanceNodes = response.SelectNodes("Response/itemInstances/itemInstance");
                if (itemInstanceNodes != null)
                {
                    totalItems = itemInstanceNodes.Count;
                }

                int startIndex = -1;
                int tempOut    = -1;
                if (int.TryParse(filter.StartIndex, out tempOut))
                {
                    startIndex = tempOut;
                }

                int blockSize = -1;
                tempOut = -1;
                if (int.TryParse(filter.BlockSize, out tempOut))
                {
                    blockSize = tempOut;
                }

                AddAttribute(response, "/Response/itemInstances", "startIndex", startIndex.ToString());
                AddAttribute(response, "/Response/itemInstances", "blockSize", blockSize.ToString());
                AddAttribute(response, "/Response/itemInstances", "total", totalItems.ToString());
                AddAttribute(response, "/Response/itemInstances", "itemTypeNames", filter.ItemTypeNames);
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("GetUserInventory", ex);
            }

            return(response);
        }
Example #26
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);
            }
        }
Example #27
0
        private PaymentCommand CreateCommandWithNoParams(string commandName)
        {
            PaymentCommand cmd = new PaymentCommand();

            cmd.Verb = commandName;

            return(cmd);
        }
Example #28
0
        /// <summary>
        /// Converts the client PaymentItems command to a PaymentItems command
        /// </summary>
        /// <param name="xmlClientMessage">xml client PaymentItems command</param>
        /// <returns>PaymentItems command</returns>
        public PaymentCommand ProcessMessage(string xmlClientMessage, getUserIdDelegate getUserIdCall)
        {
            mGetUserIdCall = getUserIdCall;
            ServiceCommandSerializer serializer    = new ServiceCommandSerializer();
            PaymentCommand           clientCommand = (PaymentCommand)serializer.DeserializeCommandData(xmlClientMessage, typeof(PaymentCommand));

            return(ParseClientPaymentCommand(clientCommand));
        }
Example #29
0
        public async Task <IActionResult> Payment([FromBody] PaymentCommand command)
        {
            var result = await _mediator.Send(command);

            return(result.Success
                ? Ok()
                : BadRequest(result.Error));
        }
Example #30
0
        public async Task <IActionResult> Insert(CancellationToken cancellationToken,
                                                 [FromForm] PaymentCreateModel model)
        {
            var command = new PaymentCommand(model);
            var result  = await Mediator.Send(command, cancellationToken).ConfigureAwait(false);

            return(ObjectResult(result, StatusCodes.Status200OK));
        }