Skip to content

Commit 4274146

Browse files
authored
Merge pull request #422 from PromptPlace/develop
Develop
2 parents 9998670 + d1dcd4c commit 4274146

9 files changed

Lines changed: 10 additions & 67 deletions

File tree

prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ model Payment {
420420
purchase_id Int @unique
421421
status Status
422422
method PaymentMethod
423-
provider PaymentProvider
424423
merchant_uid String @unique
425424
created_at DateTime @default(now())
426425
updated_at DateTime @updatedAt

src/purchases/dtos/purchase.dto.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { PaymentProvider } from "@prisma/client";
21

32
export interface PurchaseHistoryItemDTO {
43
prompt_id: number;
54
title: string;
65
price: number;
76
seller_nickname: string;
8-
pg: PaymentProvider | null;
97
}
108

119
export interface PurchaseHistoryResponseDTO {

src/purchases/repositories/purchase.complete.repository.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Prisma, PaymentMethod, PaymentProvider, Status } from '@prisma/client';
1+
import { Prisma, PaymentMethod, Status } from '@prisma/client';
22

33
type Tx = Prisma.TransactionClient;
44

@@ -17,7 +17,6 @@ export const PurchaseCompleteRepository = {
1717
purchase_id: number;
1818
merchant_uid: string;
1919
method: PaymentMethod;
20-
provider: PaymentProvider;
2120
status: Status;
2221
paymentId: string;
2322
cash_receipt_url?: string | null;
@@ -29,7 +28,6 @@ export const PurchaseCompleteRepository = {
2928
merchant_uid: data.merchant_uid,
3029
imp_uid: data.paymentId,
3130
method: data.method,
32-
provider: data.provider,
3331
status: data.status,
3432
cash_receipt_url: data.cash_receipt_url,
3533
cash_receipt_type: data.cash_receipt_type,

src/purchases/repositories/purchase.repository.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ export const PurchaseRepository = {
1515
user: { select: { nickname: true}},
1616
},
1717
},
18-
payment: {
19-
select: {
20-
provider: true,
21-
},
22-
},
2318
},
2419
orderBy: { created_at: 'desc'},
2520
})

src/purchases/services/purchase.complete.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const PurchaseCompleteService = {
4848
paymentId: paymentId,
4949
status: 'Succeed',
5050
method: verifiedPayment.method,
51-
provider: verifiedPayment.provider,
5251
cash_receipt_url: verifiedPayment.cashReceipt?.url,
5352
cash_receipt_type: verifiedPayment.cashReceipt?.type,
5453
});

src/purchases/services/purchase.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const PurchaseHistoryService = {
1111
price: r.amount,
1212
purchased_at: r.created_at.toISOString(),
1313
seller_nickname: r.prompt.user.nickname,
14-
pg: r.payment?.provider ?? null,
1514
}));
1615

1716
return {

src/purchases/services/purchase.webhook.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export const WebhookService = {
6161
purchase_id: purchase.purchase_id,
6262
merchant_uid: paymentId,
6363
method: verifiedPayment.method,
64-
provider: verifiedPayment.provider,
6564
cash_receipt_url: verifiedPayment.cashReceipt?.url,
6665
cash_receipt_type: verifiedPayment.cashReceipt?.type,
6766
status: 'Succeed',
Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,15 @@
11
import { PaymentMethod, PaymentProvider } from '@prisma/client';
22
import { AppError } from '../../errors/AppError';
33

4-
// 1. 결제 수단 매핑
4+
// 결제 수단 매핑
55
export function normalizePaymentMethod(input: string): PaymentMethod {
66
const code = input.toUpperCase().replace(/\s+/g, '');
77

8-
if (code === 'CARD' || code.includes('카드')) return 'CARD';
9-
if (code === 'VIRTUAL_ACCOUNT' || code.includes('가상계좌')) return 'VIRTUAL_ACCOUNT';
10-
if (code === 'TRANSFER' || code.includes('계좌이체')) return 'TRANSFER';
11-
if (code === 'MOBILE' || code.includes('MOBILE_PHONE') || code.includes('휴대폰')) return 'MOBILE';
12-
if (code === 'EASY_PAY' || code.includes('간편결제')) return 'EASY_PAY';
8+
if (code === 'PaymentMethodCard') return 'CARD';
9+
if (code === 'PaymentMethodVirtualAccount') return 'VIRTUAL_ACCOUNT';
10+
if (code === 'PaymentMethodEasyPay') return 'TRANSFER';
11+
if (code === 'PaymentMethodTransfer') return 'MOBILE';
12+
if (code === 'PaymentMethodMobile') return 'EASY_PAY';
1313

1414
throw new AppError(`지원하지 않는 결제 수단입니다: ${input}`, 400, 'UnsupportedPaymentMethod');
15-
}
16-
17-
// 2. 제공자 (Provider) 매핑
18-
export function normalizePaymentProvider(input: string, method: PaymentMethod): PaymentProvider {
19-
const code = (input || '').toUpperCase().replace(/\s+/g, '');
20-
21-
if (code.includes('KAKAO') || code.includes('카카오')) {
22-
return 'KAKAOPAY';
23-
}
24-
if (code.includes('TOSSPAY') || code.includes('토스')) {
25-
return 'TOSSPAY';
26-
}
27-
if (
28-
code.includes('NAVER') || code.includes('네이버') ||
29-
code.includes('SAMSUNG') || code.includes('삼성') ||
30-
code.includes('APPLE') || code.includes('애플') ||
31-
code.includes('PAYCO') || code.includes('페이코') ||
32-
code.includes('LPAY') || code.includes('엘페이') ||
33-
code.includes('SSG') || code.includes('에스에스지') ||
34-
code.includes('PINPAY') || code.includes('핀페이')
35-
) {
36-
throw new AppError(`현재 지원하지 않는 간편결제사입니다: ${input}`, 400, 'ProviderNotSupported');
37-
}
38-
if (method !== 'EASY_PAY') {
39-
return 'TOSSPAYMENTS';
40-
}
41-
throw new AppError(`식별할 수 없는 결제 제공자입니다: ${input}`, 400, 'UnknownPaymentProvider');
4215
}

src/purchases/utils/portone.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22
import { AppError } from '../../errors/AppError';
3-
import { PaymentMethod, PaymentProvider } from '@prisma/client'
4-
import { normalizePaymentMethod, normalizePaymentProvider } from "./payment.util"
3+
import { PaymentMethod } from '@prisma/client'
4+
import { normalizePaymentMethod } from "./payment.util"
55

66
interface PortOnePaymentResponse {
77
id: string; // paymentId
@@ -43,7 +43,6 @@ export type PortonePaymentVerified = {
4343
amount: number;
4444
status: string;
4545
method: PaymentMethod;
46-
provider: PaymentProvider;
4746
paidAt: Date;
4847
customData: any;
4948
cashReceipt?: {
@@ -101,24 +100,9 @@ export async function fetchAndVerifyPortonePayment(
101100
}
102101
}
103102

104-
// 5. PG Provider 추출
103+
// 5. 결제 수단 추출
105104
const rawMethodType = payment.method?.type || '';
106105
const method = normalizePaymentMethod(rawMethodType);
107-
let rawProvider = '';
108-
109-
if (method === 'EASY_PAY') {
110-
rawProvider = payment.method?.easyPay?.provider || '';
111-
} else if (method === 'CARD') {
112-
rawProvider = payment.method?.card?.publisher || '';
113-
} else if (method === 'TRANSFER') {
114-
rawProvider = payment.method?.transfer?.bank || '';
115-
} else if (method === 'VIRTUAL_ACCOUNT') {
116-
rawProvider = payment.method?.virtualAccount?.bank || '';
117-
} else if (method === 'MOBILE') {
118-
rawProvider = payment.method?.mobile?.carrier || 'MOBILE';
119-
}
120-
121-
const provider = normalizePaymentProvider(rawProvider, method);
122106

123107
// 6. 현금영수증 데이터 추출
124108
let cashReceiptInfo = null;
@@ -134,7 +118,6 @@ export async function fetchAndVerifyPortonePayment(
134118
amount: payment.amount.total,
135119
status: payment.status,
136120
method: method,
137-
provider: provider,
138121
paidAt: payment.paidAt ? new Date(payment.paidAt) : new Date(),
139122
customData: parsedCustomData,
140123
cashReceipt: cashReceiptInfo

0 commit comments

Comments
 (0)