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
d654ab8e
Commit
d654ab8e
authored
May 29, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交支付回调
parent
0539f41e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
25 deletions
+36
-25
ResponseHandler.cs
Mall.Common/Pay/WeChatPat/ResponseHandler.cs
+21
-22
PayUtil.cs
Mall.WebApi/App_Code/PayUtil.cs
+2
-2
WeChatNotifyController.cs
...WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
+13
-1
No files found.
Mall.Common/Pay/WeChatPat/ResponseHandler.cs
View file @
d654ab8e
...
@@ -13,11 +13,7 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -13,11 +13,7 @@ namespace Mall.Common.Pay.WeChatPat
{
{
private
IHttpContextAccessor
_accessor
;
public
ResponseHandler
(
IHttpContextAccessor
accessor
)
{
_accessor
=
accessor
;
}
/// <summary>
/// <summary>
/// 密钥
/// 密钥
...
@@ -37,13 +33,15 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -37,13 +33,15 @@ namespace Mall.Common.Pay.WeChatPat
/// <summary>
/// <summary>
/// 获取页面提交的get和post参数
/// 获取页面提交的get和post参数
/// </summary>
/// </summary>
public
ResponseHandler
()
public
ResponseHandler
(
IHttpContextAccessor
_accessor
)
{
{
xmlMap
=
new
Hashtable
();
xmlMap
=
new
Hashtable
();
if
(
_accessor
.
HttpContext
.
Request
.
ContentLength
>
0
)
if
(
_accessor
.
HttpContext
.
Request
.
ContentLength
>
0
)
{
{
var
reader
=
new
System
.
IO
.
StreamReader
(
_accessor
.
HttpContext
.
Request
.
Body
,
Encoding
.
UTF8
);
var
reader
=
new
System
.
IO
.
StreamReader
(
_accessor
.
HttpContext
.
Request
.
Body
,
Encoding
.
UTF8
);
Plugin
.
LogHelper
.
Write
(
null
,
"Notify支付回调:reader-"
+
reader
.
ToString
());
_accessor
.
HttpContext
.
Request
.
Body
.
Position
=
0
;
_accessor
.
HttpContext
.
Request
.
Body
.
Position
=
0
;
var
xmlDoc
=
new
XmlDocument
();
var
xmlDoc
=
new
XmlDocument
();
xmlDoc
.
Load
(
reader
);
xmlDoc
.
Load
(
reader
);
...
@@ -53,6 +51,7 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -53,6 +51,7 @@ namespace Mall.Common.Pay.WeChatPat
{
{
xmlMap
.
Add
(
xnf
.
Name
,
xnf
.
InnerText
);
xmlMap
.
Add
(
xnf
.
Name
,
xnf
.
InnerText
);
}
}
Plugin
.
LogHelper
.
Write
(
null
,
"Notify支付回调:xmlMap-"
+
xmlMap
.
ToString
());
}
}
//if (HttpContext.Current.Request.InputStream.Length > 0)
//if (HttpContext.Current.Request.InputStream.Length > 0)
//{
//{
...
@@ -148,21 +147,21 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -148,21 +147,21 @@ namespace Mall.Common.Pay.WeChatPat
return
sign
.
Equals
(
xmlMap
[
"sign"
]);
return
sign
.
Equals
(
xmlMap
[
"sign"
]);
}
}
/// <summary>
///
//
<summary>
/// 获取编码方式
///
//
获取编码方式
/// </summary>
///
//
</summary>
/// <returns></returns>
///
//
<returns></returns>
protected
virtual
string
GetCharset
()
//
protected virtual string GetCharset()
{
//
{
//return "UTF-8";
//
//return "UTF-8";
try
//
try
{
//
{
return
HttpHelper
.
GetRequestEncoding
(
_accessor
.
HttpContext
.
Request
).
BodyName
;
//
return HttpHelper.GetRequestEncoding(_accessor.HttpContext.Request).BodyName;
}
//
}
catch
(
Exception
)
//
catch (Exception)
{
//
{
return
"UTF-8"
;
//
return "UTF-8";
}
//
}
}
//
}
}
}
}
}
Mall.WebApi/App_Code/PayUtil.cs
View file @
d654ab8e
...
@@ -107,11 +107,11 @@ namespace Mall.WebApi.App_Code
...
@@ -107,11 +107,11 @@ namespace Mall.WebApi.App_Code
/// 支付
/// 支付
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
BaseResult
Notify
()
public
BaseResult
Notify
(
IHttpContextAccessor
accessor
)
{
{
try
try
{
{
var
res
=
new
ResponseHandler
();
var
res
=
new
ResponseHandler
(
accessor
);
var
tradeType
=
res
.
GetParameter
(
"trade_type"
);
var
tradeType
=
res
.
GetParameter
(
"trade_type"
);
LogHelper
.
Write
(
null
,
"Notify支付回调:res-"
+
res
.
ToString
());
LogHelper
.
Write
(
null
,
"Notify支付回调:res-"
+
res
.
ToString
());
...
...
Mall.WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
View file @
d654ab8e
...
@@ -10,6 +10,7 @@ using Mall.Common.Plugin;
...
@@ -10,6 +10,7 @@ using Mall.Common.Plugin;
using
Mall.Module.User
;
using
Mall.Module.User
;
using
Mall.WebApi.Filter
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
using
Newtonsoft.Json.Linq
;
...
@@ -26,6 +27,17 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -26,6 +27,17 @@ namespace Mall.WebApi.Controllers.AppletWeChat
UserCommonModule
userCommonModule
=
new
UserCommonModule
();
UserCommonModule
userCommonModule
=
new
UserCommonModule
();
private
IHttpContextAccessor
_accessor
;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="accessor"></param>
public
WeChatNotifyController
(
IHttpContextAccessor
accessor
)
{
_accessor
=
accessor
;
}
/// <summary>
/// <summary>
/// 订单支付回调
/// 订单支付回调
/// </summary>
/// </summary>
...
@@ -36,7 +48,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -36,7 +48,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{
{
var
req
=
new
RequestHandler
();
var
req
=
new
RequestHandler
();
App_Code
.
PayUtil
PayUtil
=
new
App_Code
.
PayUtil
();
App_Code
.
PayUtil
PayUtil
=
new
App_Code
.
PayUtil
();
var
result
=
PayUtil
.
Notify
();
var
result
=
PayUtil
.
Notify
(
_accessor
);
if
(
result
.
IsSuccess
)
if
(
result
.
IsSuccess
)
{
{
var
dic
=
((
Dictionary
<
string
,
string
>)
result
.
Data
);
var
dic
=
((
Dictionary
<
string
,
string
>)
result
.
Data
);
...
...
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