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
b300bb1d
Commit
b300bb1d
authored
May 28, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改支付信息
parent
c281b81f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
PayUtil.cs
Mall.WebApi/App_Code/PayUtil.cs
+11
-14
No files found.
Mall.WebApi/App_Code/PayUtil.cs
View file @
b300bb1d
...
...
@@ -46,13 +46,12 @@ namespace Mall.WebApi.App_Code
/// <returns></returns>
public
static
string
GetMinUnifiedOrder
(
string
sOrderNo
,
string
sProductName
,
decimal
dPrice
,
string
CustomerId
,
string
openid
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
)
{
App_Code
.
PayUtil
payUtil
=
new
App_Code
.
PayUtil
();
var
req
=
new
Common
.
Pay
.
WeChatPat
.
RequestHandler
();
req
.
SetKey
(
model
.
WeChatApiSecret
);
//
req
.
SetParameter
(
"appid"
,
model
.
MiniAppId
);
//微信开放平台审核通过的应用APPID
req
.
SetParameter
(
"mch_id"
,
model
.
WeChatPayMerchants
);
//微信支付分配的商户号
req
.
SetParameter
(
"nonce_str"
,
payUtil
.
GetNoncestr
());
//随机字符串,不长于32位
req
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
//随机字符串,不长于32位
req
.
SetParameter
(
"body"
,
sProductName
);
req
.
SetParameter
(
"attach"
,
CustomerId
);
req
.
SetParameter
(
"out_trade_no"
,
sOrderNo
);
...
...
@@ -209,8 +208,6 @@ namespace Mall.WebApi.App_Code
/// <returns></returns>
public
BaseResult
Refund
(
PayParam
param
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
)
{
App_Code
.
PayUtil
payUtil
=
new
App_Code
.
PayUtil
();
if
(
param
.
TotalFee
==
null
||
param
.
RefundFee
==
null
||
string
.
IsNullOrWhiteSpace
(
param
.
OrderNumber
)
||
string
.
IsNullOrWhiteSpace
(
param
.
RefundNumber
))
{
return
new
BaseResult
()
{
IsSuccess
=
false
,
Message
=
"参数错误!"
};
...
...
@@ -220,7 +217,7 @@ namespace Mall.WebApi.App_Code
packageReq
.
SetKey
(
model
.
WeChatApiSecret
);
packageReq
.
SetParameter
(
"appid"
,
model
.
MiniAppId
);
packageReq
.
SetParameter
(
"mch_id"
,
model
.
WeChatPayMerchants
);
packageReq
.
SetParameter
(
"nonce_str"
,
payUtil
.
GetNoncestr
());
packageReq
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
//packageReq.SetParameter("transaction_id", param.OrderNumber);
packageReq
.
SetParameter
(
"out_trade_no"
,
param
.
OrderNumber
);
packageReq
.
SetParameter
(
"out_refund_no"
,
param
.
RefundNumber
);
...
...
@@ -265,7 +262,7 @@ namespace Mall.WebApi.App_Code
packageReq
.
SetKey
(
model
.
WeChatApiSecret
);
packageReq
.
SetParameter
(
"appid"
,
model
.
MiniAppId
);
packageReq
.
SetParameter
(
"mch_id"
,
model
.
WeChatPayMerchants
);
packageReq
.
SetParameter
(
"nonce_str"
,
payUtil
.
GetNoncestr
());
packageReq
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
packageReq
.
SetParameter
(
"sign"
,
packageReq
.
CreateMd5Sign
(
_accessor
));
packageReq
.
SetParameter
(
"out_refund_no"
,
param
.
RefundNumber
);
...
...
@@ -303,15 +300,15 @@ namespace Mall.WebApi.App_Code
/// <param name="CustomerId"></param>
/// <param name="openid"></param>
/// <returns></returns>
private
string
GetTransfersOrder
(
string
sOrderNo
,
string
sProductName
,
decimal
dPrice
,
string
CustomerId
,
string
openid
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
)
private
st
atic
st
ring
GetTransfersOrder
(
string
sOrderNo
,
string
sProductName
,
decimal
dPrice
,
string
CustomerId
,
string
openid
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
)
{
App_Code
.
PayUtil
payUtil
=
new
App_Code
.
PayUtil
();
var
req
=
new
Common
.
Pay
.
WeChatPat
.
RequestHandler
();
req
.
SetKey
(
model
.
WeChatApiSecret
);
//
req
.
SetParameter
(
"mch_appid"
,
model
.
MiniAppId
);
//微信开放平台审核通过的应用APPID
req
.
SetParameter
(
"mchid"
,
model
.
WeChatPayMerchants
);
//微信支付分配的商户号
req
.
SetParameter
(
"nonce_str"
,
payUtil
.
GetNoncestr
());
//随机字符串,不长于32位
req
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
//随机字符串,不长于32位
req
.
SetParameter
(
"sign"
,
req
.
CreateMd5Sign
(
_accessor
));
req
.
SetParameter
(
"partner_trade_no"
,
sProductName
);
//商户订单号,需保持唯一性(只能是字母或者数字,不能包含有其它字符)
req
.
SetParameter
(
"openid"
,
openid
);
...
...
@@ -340,8 +337,8 @@ namespace Mall.WebApi.App_Code
payReq
.
SetKey
(
model
.
WeChatApiSecret
);
payReq
.
SetParameter
(
"appId"
,
model
.
MiniAppId
);
// req.SetParameter("mch_id", EheMall.WeChat.Common.WeChatConfig.GetOpenMchID());//微信支付分配的商户号
payReq
.
SetParameter
(
"timeStamp"
,
payUtil
.
GetTimestamp
());
payReq
.
SetParameter
(
"nonceStr"
,
payUtil
.
GetNoncestr
());
payReq
.
SetParameter
(
"timeStamp"
,
GetTimestamp
());
payReq
.
SetParameter
(
"nonceStr"
,
GetNoncestr
());
payReq
.
SetParameter
(
"package"
,
"prepay_id="
+
prepayId
);
payReq
.
SetParameter
(
"signType"
,
"MD5"
);
//创建签名
...
...
@@ -364,7 +361,7 @@ namespace Mall.WebApi.App_Code
/// 获取随机字符串
/// </summary>
/// <returns></returns>
public
string
GetNoncestr
()
public
st
atic
st
ring
GetNoncestr
()
{
var
random
=
new
Random
();
return
SecurityHelper
.
MD5EncryptWeChat
(
random
.
Next
(
1000
).
ToString
(
CultureInfo
.
InvariantCulture
),
"GBK"
);
...
...
@@ -374,7 +371,7 @@ namespace Mall.WebApi.App_Code
/// 获取时间戳
/// </summary>
/// <returns></returns>
public
string
GetTimestamp
()
public
st
atic
st
ring
GetTimestamp
()
{
var
ts
=
DateTime
.
UtcNow
-
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
0
);
return
Convert
.
ToInt64
(
ts
.
TotalSeconds
).
ToString
(
CultureInfo
.
InvariantCulture
);
...
...
@@ -386,7 +383,7 @@ namespace Mall.WebApi.App_Code
/// <param name="instr"></param>
/// <param name="charset">默认值:utf-8</param>
/// <returns></returns>
public
string
UrlEncode
(
string
instr
,
string
charset
)
public
st
atic
st
ring
UrlEncode
(
string
instr
,
string
charset
)
{
if
(
instr
==
null
||
instr
.
Trim
()
==
""
)
return
""
;
...
...
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