Skip to content

Commit

Permalink
Merge pull request #88 from EasyAbp/handle-empty-return-msg
Browse files Browse the repository at this point in the history
Handle responses with empty `return_msg`
  • Loading branch information
gdlcf88 committed Jun 16, 2023
2 parents eafccf2 + ad4702d commit 6a78923
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ protected WeChatPayServiceBase(AbpWeChatPayOptions options, IAbpLazyServiceProvi
WeChatPayParameters requestParameters, [CanBeNull] string mchId)
{
var result = await ApiRequester.RequestAsync(targetUrl, requestParameters.ToXmlStr(), mchId);
if (result.SelectSingleNode("/xml/return_code")?.InnerText != "SUCCESS" ||
result.SelectSingleNode("/xml/return_msg")?.InnerText != "OK")

var returnCode = result.SelectSingleNode("/xml/return_code")?.InnerText;
var returnMsg = result.SelectSingleNode("/xml/return_msg")?.InnerText;

if (returnCode != "SUCCESS" || (returnMsg != "OK" && !returnMsg.IsNullOrWhiteSpace()))
{
var errMsg =
$"微信支付接口调用失败,具体失败原因:{result.SelectSingleNode("/xml/err_code_des")?.InnerText ?? result.SelectSingleNode("/xml/return_msg")?.InnerText}";
Expand Down

0 comments on commit 6a78923

Please sign in to comment.