Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
deb9be41
authored
Jun 26, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: pay error catch
parent
f382b219
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
client/src/pages/api/user/checkPayResult.ts
+1
-1
client/src/service/utils/wxpay.ts
+21
-13
No files found.
client/src/pages/api/user/checkPayResult.ts
View file @
deb9be41
...
...
@@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import
{
jsonRes
}
from
'@/service/response'
;
import
{
connectToDatabase
,
User
,
Pay
,
TrainingData
}
from
'@/service/mongo'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
PaySchema
,
UserModelSchema
}
from
'@/types/mongoSchema'
;
import
{
PaySchema
}
from
'@/types/mongoSchema'
;
import
dayjs
from
'dayjs'
;
import
{
getPayResult
}
from
'@/service/utils/wxpay'
;
import
{
pushPromotionRecord
}
from
'@/service/utils/promotion'
;
...
...
client/src/service/utils/wxpay.ts
View file @
deb9be41
// @ts-ignore
import
Payment
from
'wxpay-v3'
;
export
const
getPayment
=
()
=>
{
return
new
Payment
({
export
const
getPayment
=
()
=>
new
Payment
({
appid
:
process
.
env
.
WX_APPID
,
mchid
:
process
.
env
.
WX_MCHID
,
private_key
:
process
.
env
.
WX_PRIVATE_KEY
?.
replace
(
/
\\
n/g
,
'\n'
),
...
...
@@ -10,22 +10,30 @@ export const getPayment = () => {
apiv3_private_key
:
process
.
env
.
WX_V3_CODE
,
notify_url
:
process
.
env
.
WX_NOTIFY_URL
});
};
export
const
nativePay
=
(
amount
:
number
,
payId
:
string
):
Promise
<
string
>
=>
getPayment
()
.
native
({
export
const
nativePay
=
async
(
amount
:
number
,
payId
:
string
)
=>
{
try
{
const
res
=
await
getPayment
()
.
native
({
description
:
'Fast GPT 余额充值'
,
out_trade_no
:
payId
,
amount
:
{
total
:
amount
}
})
.
then
((
res
:
any
)
=>
JSON
.
parse
(
res
.
data
).
code_url
);
});
return
JSON
.
parse
(
res
.
data
).
code_url
as
string
;
}
catch
(
error
)
{
return
Promise
.
reject
(
error
);
}
};
export
const
getPayResult
=
(
payId
:
string
)
=>
getPayment
()
.
getTransactionsByOutTradeNo
({
export
const
getPayResult
=
async
(
payId
:
string
)
=>
{
try
{
const
res
=
await
getPayment
()
.
getTransactionsByOutTradeNo
({
out_trade_no
:
payId
})
.
then
((
res
:
any
)
=>
JSON
.
parse
(
res
.
data
));
});
return
JSON
.
parse
(
res
.
data
);
}
catch
(
error
)
{
return
Promise
.
reject
(
error
);
}
};
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