@@ -8,6 +8,7 @@ import random from 'lib/random'
8
8
import { sha256 } from 'lib/token'
9
9
import { HttpError } from 'lib/error'
10
10
import { getCard , getProduct } from './get'
11
+ import createTransaction from 'lib/createTransaction'
11
12
12
13
import type { Response } from 'express'
13
14
import type { AxiosPromise } from 'axios'
@@ -29,29 +30,21 @@ export default async (req: PaymentRequest, res: Response) => {
29
30
cardQuota : 0 , // 일시불
30
31
amount : product . price ,
31
32
goodsName : product . name ,
32
- useShopInterest : false // false만 사용가능
33
+ useShopInterest : false , // false만 사용가능
33
34
} ,
34
35
} ) )
35
36
36
37
if ( response . resultCode !== '0000' ) {
37
38
throw new HttpError ( 500 , response . resultMsg , response . resultCode )
38
39
}
39
40
40
- const transaction = await prisma . transaction . create ( {
41
- data : {
42
- tid : response . tid ,
43
- id : response . orderId ,
44
- price : response . amount ,
45
- productName : response . goodsName ,
46
- USER : { connect : { id : req . user . id } } ,
47
- PRODUCT : { connect : { id : productId } } ,
48
- } ,
49
- select : {
50
- id : true ,
51
- price : true ,
52
- createdAt : true ,
53
- productName : true ,
54
- } ,
41
+ const transaction = await createTransaction ( {
42
+ productId,
43
+ tid : response . tid ,
44
+ userId : req . user . id ,
45
+ amount : response . amount ,
46
+ orderId : response . orderId ,
47
+ goodsName : response . goodsName ,
55
48
} )
56
49
57
50
res . json ( transaction )
0 commit comments