Exemplo n.º 1
0
    public async Task <bool> updateStripeAccount(string key, string value)
    {
        bool            success = false;
        WithdrawManager wm      = new WithdrawManager();

        Debug.Log("Key:" + key);
        switch (key)
        {
        case "firstname":
            return(await wm.attachInfoToAccount(token, value, "first_name"));

            break;

        case "lastname":
            return(await wm.attachInfoToAccount(token, value, "last_name"));

            break;

        case "address":
            return(await wm.attachInfoToAccount(token, value, "address", "line1"));

            break;

        case "zipcode":
            return(await wm.attachInfoToAccount(token, value, "address", "postal_code"));

            break;

        case "city":
            return(await wm.attachInfoToAccount(token, value, "address", "city"));

            break;

        case "phone":
            return(await wm.attachInfoToAccount(token, value, "phone"));

            break;

        case "birthdate":
            Debug.Log("case birthdate");
            char[]   spearator = { '-' };
            String[] birth     = value.Split(spearator);
            return(wm.attachDOBToAccount(token, int.Parse(birth[2]), int.Parse(birth[1]), int.Parse(birth[0])));

            break;

        default: return(false);
        }
    }
Exemplo n.º 2
0
    //signup with the new api
    public IEnumerator signingUp(string username, string email, string password, string avatar)
    {
        WithdrawManager wm = new WithdrawManager();

        Debug.Log("username: "******"email: " + email);
        Debug.Log("password: "******"country_code: " + GetGeoLoc());
        Debug.Log("longLat: " + longLat);
        Debug.Log("avatar: " + avatar);
        Debug.Log("game_id: " + GamesManager.GAME_ID);
        WWWForm form = new WWWForm();

        form.AddField("username", username);
        form.AddField("email", email);
        form.AddField("password", password);
        form.AddField("country_code", GetGeoLoc());
        form.AddField("long_lat", longLat);
        form.AddField("game_id", GamesManager.GAME_ID);
        form.AddField("avatar", avatar);
        var download = UnityWebRequest.Post(Endpoint.classesURL + "/users", form);

        download.timeout = 4000;
        yield return(download.Send());

        //Debug.Log (download.downloadHandler.text);
        if (download.isNetworkError)
        {
            print("Error downloading: " + download.error);
            UserService.statusCode = 400;
            try
            {
                SceneManager.UnloadSceneAsync("Loader");
            }
            catch (ArgumentException ex)
            {
            }
            yield return(400);
        }
        else
        {
            if (download.responseCode == 200)
            {
                Debug.Log(download.downloadHandler.text);
                var N = JSON.Parse(download.downloadHandler.text);
                //Attach Info to Stripe Account
                wm.attachBusinessProfileToAccount(N["token"].Value);
                wm.attachInfoToAccount(N["token"].Value, N["data"]["email"].Value, "email");
                UnityThreadHelper.Dispatcher.Dispatch(() =>
                {
                    Debug.Log(download.downloadHandler.text);
                    //Save The current Session ID
                    saveUserId(N["data"]["_id"].Value);
                    //Save Session Token
                    saveSessionToken(N["token"].Value);
                    UserService.statusCode = 0;
                });
                yield return(0);
            }
            else
            {
                UserService.statusCode = 400;
                yield return(400);
            }
        }
    }