Example #1
0
        public async Task <IActionResult> GetPublicKey()
        {
            var request  = new WeChatPayGetPublicKeyRequest();
            var response = await _client.ExecuteAsync(request);

            return(Ok(response.Body));
        }
Example #2
0
        public async Task <IActionResult> GetPublicKey()
        {
            var request  = new WeChatPayGetPublicKeyRequest();
            var response = await _client.ExecuteAsync(request, "wechatpayCertificateName");

            ResponseModel responseModel = new ResponseModel()
            {
                code = HTTPResponseCode.PartialContent,
                data = response.Body
            };

            Dictionary <string, string> result = new Dictionary <string, string>();

            result.Add("return_code", response.ReturnCode);
            result.Add("return_msg", response.ReturnMsg);

            if (response.ReturnCode == "SUCCESS" && response.ResultCode == "SUCCESS")
            {
                responseModel.code = HTTPResponseCode.Successful;
            }
            else
            {
                responseModel.code = HTTPResponseCode.BadRequest;
                result.Add("err_code", response.ErrCode);
                result.Add("err_code_des", response.ErrCodeDes);
            }
            responseModel.message = JsonConvert.SerializeObject(result);
            return(Json(responseModel));
        }
        public async Task <IActionResult> GetPublicKey()
        {
            if (Request.Method == "POST")
            {
                var request  = new WeChatPayGetPublicKeyRequest();
                var response = await _client.ExecuteAsync(request, "wechatpayCertificateName");

                ViewData["response"] = response.Body;
                return(View());
            }

            return(View());
        }