private void SendWithdrawRequest() { TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00); Action <string> onSuccess = (string data) => { GeneralResult r = JsonUtility.FromJson <GeneralResult>(data); if (r.success) { TacoManager.CloseMessage(); TacoManager.OpenModalGeneralResultPanel(r.success, TacoConfig.SuccessHeader, "You will receive a confirmation email within\n1 Business day once the withdraw amount has been approved."); TacoManager.UpdateFundsOnly(r.cash); if (wdSaveProfile.isOn) { TacoManager.User.contactProfile.UpdateData(wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text); } ResetWithdrawInputField(); moneyValue.text = TacoManager.FormatCash(TacoManager.User.TotalCash); availableFund.text = TacoManager.FormatCash(TacoManager.User.funds); TournamentManager.Instance.SetMoneytext(); defaultAddress.text = TacoManager.User.contactProfile.FullAddress(); if (switchAddressBtn.transform.GetChild(0).GetComponent <Text>().text == TacoConfig.NoDefaultAddress) { withdrawBtn.onClick.Invoke(); } } else { TacoManager.CloseMessage(); TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, r.msg); } TacoManager.CloseMessage(); }; Action <string, string> onFail = (string data, string error) => { TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, error); TacoManager.CloseMessage(); }; if (newAddress.activeSelf) { StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text, wdSaveProfile.isOn, onSuccess, onFail)); } else { ContactProfile addr = TacoManager.User.contactProfile; StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, addr.address, addr.address2, addr.city, addr.state, addr.zipcode, false, onSuccess, onFail)); } }
public IEnumerator withdrawRequest(string amount, string name, string address1, string address2, string city, string zip, string state) { WWWForm form = new WWWForm(); form.AddField("amount", amount); form.AddField("name", name); form.AddField("address1", address1); form.AddField("address2", address2); form.AddField("city", city); form.AddField("state", state); form.AddField("zip", zip); UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/funds/withdraw", form); www.SetRequestHeader("x-access-token", TacoManager.User.token); yield return(www.Send()); if (www.isError) { WithdrawText.GetComponent <Text>().text = TacoConfig.Error; } else { TacoConfig.print("Withdrawa funds complete - " + www.downloadHandler.text); var r = JsonUtility.FromJson <WithdrawFundsResult>(www.downloadHandler.text); if (r.success) { if (r.funds != null && r.funds != string.Empty) { TacoConfig.print("funds = " + r.funds); var funds = double.Parse(r.funds); TacoManager.UpdateFundsOnly(funds); WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsSuccessMessage; } } else { WithdrawText.GetComponent <Text>().text = TacoConfig.Error + ": " + r.message; } } }
private IEnumerator purchaseFunds(string number, int month, int year, int cvc, int amount) { WWWForm form = new WWWForm(); form.AddField("number", number); form.AddField("month", month); form.AddField("year", year); form.AddField("cvc", cvc); form.AddField("amount", amount); UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/funds", form); www.SetRequestHeader("x-access-token", TacoManager.User.token); //www.SetRequestHeader("Authorization", "Bearer " + stripeToken ); yield return(www.Send()); if (www.isError) { AddStatusText.GetComponent <Text>().text = TacoConfig.Error; } else { TacoConfig.print("Purchase funds complete - " + www.downloadHandler.text); var r = JsonUtility.FromJson <AddFundsResult>(www.downloadHandler.text); if (r.success) { if (r.funds != null && r.funds != string.Empty) { TacoConfig.print("funds = " + r.funds); var funds = double.Parse(r.funds); TacoManager.UpdateFundsOnly(funds); AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsSuccessMessage + " " + funds.ToString("C") + ""; } } else { AddStatusText.GetComponent <Text>().text = TacoConfig.Error + " : " + r.message; } //AddStatusText.GetComponent<Text>().text = "An amount must be selected."; } }
public void AddFunds() { var num = CardNumberInput.GetComponent <InputField>().text; if (num == string.Empty) { AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError00; return; } var month = ExpMonthInput.GetComponent <InputField>().text; if (month == string.Empty) { AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError01; return; } var year = ExpYearInput.GetComponent <InputField>().text; if (year == string.Empty) { AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError02; return; } var cvc = CVCInput.GetComponent <InputField>().text; if (cvc == string.Empty) { AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError03; return; } var group = FundsGroup.GetComponent <ToggleGroup>(); var toggle = group.ActiveToggles().FirstOrDefault(); if (toggle == null) { AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError04; return; } int amount = 0; switch (toggle.name) { case "Toggle5": amount = 5 * 100; break; case "Toggle10": amount = 10 * 100; break; case "Toggle25": amount = 25 * 100; break; case "Toggle50": amount = 50 * 100; break; case "Toggle100": amount = 100 * 100; break; default: break; } AddFundsButton.GetComponent <Button>().interactable = false; AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsAdding; isAdding = true; //StartCoroutine(purchaseFunds(num, Int32.Parse(month), Int32.Parse(year), Int32.Parse(cvc), amount)); //StartCoroutine(GetStripeToken(num, month, year, cvc, amount)); Action <string> success = (string data) => { TacoConfig.print("Purchase funds complete - " + data); var r = JsonUtility.FromJson <AddFundsResult>(data); if (r.success) { if (r.funds != null && r.funds != string.Empty) { TacoConfig.print("funds = " + r.funds); var funds = double.Parse(r.funds); // funds added : return to Tournaments view TacoManager.UpdateFundsOnly(funds); string returnMessage = TacoConfig.AddFundsSuccessMessage + TacoManager.FormatMoney(funds); AddStatusText.GetComponent <Text>().text = ""; Destroy(); // show a dialog to indicate success : then return to tournaments TacoManager.OpenModal(TacoConfig.AddFundsTitleSuccessMessage, returnMessage, null, ModalFunctions.ReturnToTournaments, null, null, false); } } else { AddStatusText.GetComponent <Text>().text = TacoConfig.Error + " : " + r.message; } AddFundsButton.GetComponent <Button>().interactable = true; }; Action <string, string> fail = (string data, string error) => { var msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error); TacoConfig.print("Error adding funds : " + msg); AddStatusText.GetComponent <Text>().text = TacoConfig.Error + " : " + msg; AddFundsButton.GetComponent <Button>().interactable = true; }; StartCoroutine(ApiManager.Instance.AddFunds(num, month, year, cvc, amount, success, fail)); }
private IEnumerator postCreate(string name, string fee, string players, string opponents, string gameInt) { WWWForm form = new WWWForm(); form.AddField("name", name); form.AddField("fee", fee); form.AddField("size", players); //form.AddField("gameId", TacoManager.Instance.GameId); form.AddField("gameId", gameInt); form.AddField("siteId", TacoConfig.SiteId); form.AddField("opponents", opponents); TacoConfig.print("Form Post : Fee =" + fee + " players = " + players + " name =" + name); TacoConfig.print("Create Tournament complete - " + fee); UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/tournament", form); www.SetRequestHeader("x-access-token", TacoManager.User.token); yield return(www.Send()); if (www.isError || www.responseCode == 500) { TacoConfig.print("DL Handler = " + www.downloadHandler.text); TacoConfig.print("URL = " + www.url); TacoConfig.print("Error downloading: " + www.error); if (!string.IsNullOrEmpty(www.downloadHandler.text)) { var r = JsonUtility.FromJson <CreateTournamentResult>(www.downloadHandler.text); if (!string.IsNullOrEmpty(r.message)) { TacoConfig.print("r.message: " + r.message); TournamentSubmitError(r.message); } } } else { // show the highscores TacoConfig.print("Create Tournament complete - " + www.downloadHandler.text); TournamentSubmitResult(TacoConfig.TacoTournamentCreated); var r = JsonUtility.FromJson <CreateTournamentResult>(www.downloadHandler.text); if (r.tournament != null) { TacoConfig.print("New tournament = " + r.tournament.id + " - " + r.tournament.name); } double val = 0; if (double.TryParse(r.userFunds, out val)) { TacoManager.UpdateFundsOnly(val); } TacoManager.SetTarget(r.tournament); } }
public void CreateTournament() { // disable the button during the creation process : it holds the keyboard focus // TODO : find a way to release the focus Button createButton = CreateTournamentButton.GetComponent <Button>(); createButton.interactable = false; int typeCurrency = TacoManager.GetTogglActiveName(typeCurrencyToggle.GetComponent <ToggleGroup> ()); string feeAmount = string.Empty; string currencyIcon = string.Empty; if (typeCurrency == 0) { feeAmount = GetFeeAmount(); currencyIcon = "$"; } else { feeAmount = (GetCurrentGTokenFromToggles() * TacoConfig.gTokenExchange).ToString(); currencyIcon = "G"; } int playersOption = TacoManager.GetTogglActiveName(playersToggle.GetComponent <ToggleGroup> ()); int prizeStructure = TacoManager.GetTogglActiveName(structureToggle.GetComponent <ToggleGroup> ()); Debug.Log("prizeStructure" + prizeStructure); string name = string.Format(TacoManager.GameName + " - " + currencyIcon + "{0} Entry - {1} Players", feeAmount, playersOption); int opponentsOption = TacoManager.GetTogglActiveName(opponentsToggle.GetComponent <ToggleGroup> ()); string opponents = ""; string invitedFriendsString = ""; for (int i = 0; i < invitedFriends.Count; i++) { invitedFriendsString = invitedFriendsString + "," + invitedFriends[i].ToString(); } if (!string.IsNullOrEmpty(invitedFriendsString)) { invitedFriendsString = invitedFriendsString.Substring(1); } switch (opponentsOption) { case 0: opponents = "public"; break; case 1: opponents = "private"; break; } int timeRemaining = 0; timeRemaining = TacoManager.GetTogglActiveName(timeRemainingToggle.GetComponent <ToggleGroup> ()); Action <string> success = (string data) => { TacoConfig.print("Create Tournament complete - " + data); TournamentSubmitResult(TacoConfig.TacoTournamentCreated); var r = JsonUtility.FromJson <CreateTournamentResult>(data); if (r.tournament != null) { TacoConfig.print("New tournament = " + r.tournament.id + " - " + r.tournament.name); double val = 0; if (r.typeCurrency == "real") { if (double.TryParse(r.userFunds, out val)) { TacoManager.UpdateFundsOnly(val); } } else { TacoManager.UpdateTokenOnly(r.userFunds); } TacoManager.SetTarget(r.tournament); } }; Action <string, string> fail = (string data, string error) => { var msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error); TacoConfig.print("Error create tournamet : " + msg); if (!string.IsNullOrEmpty(data)) { var r = JsonUtility.FromJson <CreateTournamentResult>(data); if (!string.IsNullOrEmpty(r.message)) { TacoConfig.print("r.message: " + r.message); TournamentSubmitError(r.message); } } }; StartCoroutine(ApiManager.Instance.CreateTournament(timeRemaining, typeCurrency, prizeStructure, invitedFriendsString, name, feeAmount, playersOption, opponents, TacoManager.GameId, TacoManager.User.token, success, fail)); }
private IEnumerator postJoin(Tournament t) { WWWForm form = new WWWForm(); form.AddField("type", t.typeCurrency); form.AddField("tournamentId", t.id); form.AddField("siteId", TacoConfig.SiteId); form.AddField("gameId", TacoManager.GameId); UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/tournament/join", form); www.SetRequestHeader("x-access-token", TacoManager.User.token); yield return(www.Send()); if (www.isError || www.responseCode == 500) { TacoConfig.print("DL Handler = " + www.downloadHandler.text); TacoConfig.print("URL = " + www.url); TacoConfig.print("Error downloading: " + www.error); var r = JsonUtility.FromJson <CreateTournamentResult>(www.downloadHandler.text); if (!string.IsNullOrEmpty(r.message)) { TacoManager.CloseMessage(); TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, r.message); } } else { // show the highscores TacoConfig.print("Join Tournament complete - " + www.downloadHandler.text); //createResultsText.GetComponent<Text>().text = "Tournament created, click the 'Play' button below to play your round now!"; var r = JsonUtility.FromJson <JoinTournamentResult>(www.downloadHandler.text); TacoConfig.print(r); if (r.success) { TacoManager.SetTarget(t); Decimal prize = decimal.Parse(r.tournament.prize.ToString("F2")); Decimal entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2")); string replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", r.userFunds); replacedString = replacedString.Replace("&entryFee", entryFee.ToString()); replacedString = replacedString.Replace("&prize", prize.ToString()); TacoManager.CloseMessage(); TacoManager.OpenModal(TacoConfig.TacoJoinPublicSuccessHead, replacedString, null, ModalFunctions.JoinPublicSuccess); double val = 0; if (double.TryParse(r.userFunds, out val)) { TacoManager.UpdateFundsOnly(val); } } else { TacoManager.CloseMessage(); TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, TacoConfig.TacoJoinPublicErrorMessage00 + r.message); } } }
public void CreateTournament(Tournament tourament) { // disable the button during the creation process : it holds the keyboard focus // TODO : find a way to release the focus //Button createButton = CreateTournamentButton.GetComponent<Button>(); //createButton.interactable = false; int typeCurrency = tourament.typeCurrency; string feeAmount = tourament.entryFee.ToString(); string currencyIcon = tourament.typeCurrency == 0 ? "$" : "T"; int playersOption = tourament.size; int prizeStructure = tourament.prize_structure; string name = string.Format(TacoManager.GameName + " - " + currencyIcon + "{0} Entry - {1} Players", feeAmount, tourament.size); string accessType = string.Empty; string invitedFriendsString = string.Empty; if (tourament.accessType == "public") { accessType = "public"; } else { //for( int i = 0; i < invitedFriends.Count; i++ ) { for (int i = 0; i < tourament.invitedEmails.Length; i++) { invitedFriendsString = invitedFriendsString + "," + tourament.invitedEmails [i]; } accessType = "private"; } int timeRemaining = tourament.TimeRemaining; Action <string> success = (string data) => { var r = JsonUtility.FromJson <CreateTournamentResult> (data); if (r.tournament != null) { if (r.best) { TacoManager.SetTarget(r.tournament); TournamentDuplicateResult(TacoConfig.TacoTournamentDuplicated, r.tournament); } else { ShowTournamentPanel(CurrentSubPanel); TacoManager.CreatePublicPanel.SetActive(false); TournamentSubmitResult(r.tournament); double val = 0; if (r.typeCurrency == "real") { if (double.TryParse(r.userFunds, out val)) { TacoManager.UpdateFundsOnly(val, r.userBonus); } } else { TacoManager.UpdateTokenOnly(r.userFunds); } TacoManager.SetTarget(r.tournament); SetMoneytext(); } } }; Action <string, string> fail = (string data, string error) => { var msg = data + (string.IsNullOrEmpty(error) ? string.Empty : " : " + error); Debug.Log("Error create tournamet : " + msg); if (!string.IsNullOrEmpty(data)) { var r = JsonUtility.FromJson <CreateTournamentResult> (data); if (!string.IsNullOrEmpty(r.message)) { if (r.forbidden) { TournamentSubmitForbidden(r.message); } else { TournamentSubmitError(r.message); } } } }; StartCoroutine(ApiManager.Instance.CreateTournament(timeRemaining, typeCurrency, prizeStructure, invitedFriendsString, name, feeAmount, playersOption, accessType, TacoManager.GameId, TacoManager.User.token, success, fail)); }
public void RequestWithdraw() { var amount = AmountInput.GetComponent <InputField>().text; if (amount == string.Empty) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError00; return; } double amountDecimal = 0; if (!Double.TryParse(amount, out amountDecimal)) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError01; return; } if (amountDecimal > TacoManager.User.funds) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError02; return; } var name = NameInput.GetComponent <InputField>().text; if (name == string.Empty) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError03; return; } var address1 = AddressLine1Input.GetComponent <InputField>().text; if (address1 == string.Empty) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError04; return; } var address2 = AddressLine2Input.GetComponent <InputField>().text; var city = CityInput.GetComponent <InputField>().text; if (city == string.Empty) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError05; return; } var zip = ZipInput.GetComponent <InputField>().text; if (zip == string.Empty) { WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsError06; return; } //TODO: Check if the state allows real money var stateDropdown = StateInput.GetComponent <Dropdown>(); var state = stateDropdown.options[stateDropdown.value].text; //StartCoroutine(withdrawRequest(amount, name, address1, address2, city, zip, state)); Action <string> success = (string data) => { TacoConfig.print("Withdrawa funds complete - " + data); var r = JsonUtility.FromJson <WithdrawFundsResult>(data); if (r.success) { if (r.funds != null && r.funds != string.Empty) { TacoConfig.print("funds = " + r.funds); var funds = double.Parse(r.funds); TacoManager.UpdateFundsOnly(funds); WithdrawText.GetComponent <Text>().text = TacoConfig.WithdrawFundsSuccessMessage; } } else { WithdrawText.GetComponent <Text>().text = TacoConfig.Error + ": " + r.message; } }; Action <string, string> fail = (string data, string error) => { string msg = data + ((string.IsNullOrEmpty(error)) ? "" : " : " + error); WithdrawText.GetComponent <Text>().text = TacoConfig.Error + ": " + msg; }; StartCoroutine(ApiManager.Instance.WithdrawFunds(amount, name, address1, address2, city, zip, state, success, fail)); }