public NewebpayQueryTradeInfoResult DoPostQueryTradeInfo(NewebpayQueryTradeInfoInfo info) { NewebpayQueryTradeInfoResult result = null; FormUrlEncodedContent formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>(nameof(info.MerchantID), info.MerchantID), new KeyValuePair <string, string>(nameof(info.RespondType), info.RespondType), new KeyValuePair <string, string>(nameof(info.Version), info.Version), new KeyValuePair <string, string>(nameof(info.TimeStamp), info.TimeStamp), new KeyValuePair <string, string>(nameof(info.MerchantOrderNo), info.MerchantOrderNo), new KeyValuePair <string, string>(nameof(info.Amt), info.Amt.ToString()), new KeyValuePair <string, string>(nameof(info.CheckValue), info.CheckValue) }); string responseBody = HttpService.PostForm(_configService.NewebpayQueryTradeInfoApi, formContent); if (!string.IsNullOrWhiteSpace(responseBody)) { var response = JsonConvert.DeserializeObject <NewebpayQueryTradeInfoResponse>(responseBody); if (response.IsSucceed) { result = response.Result; } else { throw new Exception($"查詢失敗"); } } return(result); }
public NewebpayQueryTradeInfoResult QueryTradeInfo(string merchantOrderNo, int amt) { var postData = new NewebpayQueryTradeInfoInfo() { MerchantID = _configService.MerchantId, RespondType = "JSON", Version = _configService.QueryTradeInfoVersion, TimeStamp = UnixDateTimeService.GetUNIX(DateTime.Now).ToString(), MerchantOrderNo = merchantOrderNo, Amt = amt }; postData.CheckValue = GetQueryTradeInfoCheckValue($"{nameof(postData.Amt)}={postData.Amt}&{nameof(postData.MerchantID)}={postData.MerchantID}&{nameof(postData.MerchantOrderNo)}={postData.MerchantOrderNo}", _configService.HashKey, _configService.HashIv); return(DoPostQueryTradeInfo(postData)); }