Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
17a4853e
Commit
17a4853e
authored
Dec 18, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
1d3c4937
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
1 deletion
+89
-1
PayUtil.cs
Mall.WebApi/App_Code/PayUtil.cs
+88
-0
WeChatPayController.cs
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
+1
-1
No files found.
Mall.WebApi/App_Code/PayUtil.cs
View file @
17a4853e
...
...
@@ -197,6 +197,94 @@ namespace Mall.WebApi.App_Code
}
/// <summary>
/// 支付
/// </summary>
/// <returns></returns>
public
BaseResult
NotifyZhouTian
(
IHttpContextAccessor
accessor
)
{
try
{
var
res
=
new
ResponseHandler
(
accessor
);
var
tradeType
=
res
.
GetParameter
(
"trade_type"
);
LogHelper
.
WriteInfo
(
"Notify支付回调:res-"
+
res
.
ToString
());
RB_MiniProgram_Extend
model
=
new
RB_MiniProgram_Extend
();
model
=
programModule
.
GetMiniProgramModule
(
new
RB_MiniProgram_Extend
{
MallBaseId
=
6
,
TenantId
=
16
});
res
.
SetKey
(
model
.
WeChatApiSecret
);
//判断签名
if
(
res
.
IsWXsign
(
out
string
error
))
{
#
region
参数
var
returnCode
=
res
.
GetParameter
(
"return_code"
);
//返回信息,如非空,为错误原因签名失败参数格式校验错误
var
returnMsg
=
res
.
GetParameter
(
"return_msg"
);
var
appid
=
res
.
GetParameter
(
"appid"
);
//以下字段在 return_code 为 SUCCESS 的时候有返回--------------------------------
var
mchId
=
res
.
GetParameter
(
"mch_id"
);
var
deviceInfo
=
res
.
GetParameter
(
"device_info"
);
var
nonceStr
=
res
.
GetParameter
(
"nonce_str"
);
var
resultCode
=
res
.
GetParameter
(
"result_code"
);
var
errCode
=
res
.
GetParameter
(
"err_code"
);
var
errCodeDes
=
res
.
GetParameter
(
"err_code_des"
);
//以下字段在 return_code 和 result_code 都为 SUCCESS 的时候有返回---------------
var
openid
=
res
.
GetParameter
(
"openid"
);
//Y-关注,N-未关注,仅在公众账号类型支付有效
var
isSubscribe
=
res
.
GetParameter
(
"is_subscribe"
);
//银行类型,采用字符串类型的银行标识
var
bankType
=
res
.
GetParameter
(
"bank_type"
);
var
totalFee
=
res
.
GetParameter
(
"total_fee"
);
//货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
var
feeType
=
res
.
GetParameter
(
"fee_type"
);
//微信支付订单号
var
transactionId
=
res
.
GetParameter
(
"transaction_id"
);
//商户系统的订单号,与请求一致。
var
outTradeNo
=
res
.
GetParameter
(
"out_trade_no"
);
var
attach
=
res
.
GetParameter
(
"attach"
);
//格 式 为yyyyMMddhhmmss
var
timeEnd
=
res
.
GetParameter
(
"time_end"
);
#
endregion
//支付成功
if
(!
outTradeNo
.
Equals
(
""
)
&&
returnCode
.
Equals
(
"SUCCESS"
)
&&
resultCode
.
Equals
(
"SUCCESS"
))
{
return
new
BaseResult
()
{
IsSuccess
=
true
,
Data
=
new
Dictionary
<
string
,
string
>
{
{
"sOrderNo"
,
outTradeNo
},
{
"sTradeNo"
,
transactionId
},
{
"dPrice"
,
totalFee
},
{
"sPayerOpenID"
,
openid
},
{
"bIsRecharge"
,
attach
},
{
"OrderPayType"
,
tradeType
},
{
"PayDate"
,
timeEnd
}
}
};
}
else
{
LogHelper
.
WriteInfo
(
"Notify支付回调:returnMsg-"
+
returnMsg
);
}
}
else
{
LogHelper
.
Write
(
null
,
"Notify签名验证失败:"
);
}
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"Notify支付错误:"
);
}
return
new
BaseResult
()
{
IsSuccess
=
false
};
}
/// <summary>
/// 退款 传入订单号OrderNumber,RefundNumber,总金额total_fee(分),RefundFee退款金额(分),
/// </summary>
...
...
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
View file @
17a4853e
...
...
@@ -93,7 +93,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
switch
((
int
)
demodel
.
OrderPayType
)
{
case
1
:
//微信支付 _accessor.HttpContext.Connection.RemoteIpAddress.ToString()
sPayInfo
=
App_Code
.
PayUtil
.
GetMinUnifiedOrder
(
sOrderNo
,
demodel
.
GoodsName
,
model
.
Income
.
Value
,
model
.
UserId
.
ToString
(),
demodel
.
OpenId
,
Config
.
sTenpayNotify
,
miniProgram
,
_accessor
,
System
.
Net
.
Dns
.
GetHostEntry
(
System
.
Net
.
Dns
.
GetHostName
()).
AddressList
.
FirstOrDefault
(
address
=>
address
.
AddressFamily
==
System
.
Net
.
Sockets
.
AddressFamily
.
InterNetwork
)?.
ToString
());
sPayInfo
=
App_Code
.
PayUtil
.
GetMinUnifiedOrder
(
sOrderNo
,
demodel
.
GoodsName
,
model
.
Income
.
Value
,
model
.
UserId
.
ToString
(),
demodel
.
OpenId
,
(
model
.
MallBaseId
==
6
&&
model
.
TenantId
==
16
)?
"http://mallapi.oytour.com/api/WeChatNotify/NotifyZhouTian"
:
Config
.
sTenpayNotify
,
miniProgram
,
_accessor
,
System
.
Net
.
Dns
.
GetHostEntry
(
System
.
Net
.
Dns
.
GetHostName
()).
AddressList
.
FirstOrDefault
(
address
=>
address
.
AddressFamily
==
System
.
Net
.
Sockets
.
AddressFamily
.
InterNetwork
)?.
ToString
());
break
;
default
:
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment