Exemple #1
0
        public static AccessToken GetAccessToken(WeChatPayConfig config, string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                throw new Exception("Authentication code must be provided");
            }
            AccessToken            token       = null;
            AuthAccessTokenRequest authRequest = new AuthAccessTokenRequest(config);

            authRequest.code = code;
            BaseResponse res = authRequest.Execute();

            if (res != null)
            {
                token = ((AccessTokenResponse)res).Access_Token;
            }
            return(token);
        }