-
Notifications
You must be signed in to change notification settings - Fork 7
/
codegen-payment-method.js
122 lines (114 loc) ยท 3.32 KB
/
codegen-payment-method.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const fs = require('fs');
const path = require('path');
const prettier = require('prettier');
const { parseItems } = require('./utils/parse-items');
// https://developers.portone.io/docs/ko/sdk/javascript-sdk/payrq?v=v1#%EA%B2%B0%EC%A0%9C%EC%9A%94%EC%B2%AD-%ED%8C%8C%EB%9D%BC%EB%AF%B8%ED%84%B0-%EC%A0%95%EC%9D%98
const LATEST_PORTONE = `
card (์ ์ฉ์นด๋)
trans(์ค์๊ฐ๊ณ์ข์ด์ฒด)
vbank(๊ฐ์๊ณ์ข)
phone(ํด๋ํฐ์์ก๊ฒฐ์ )
paypal (ํ์ดํ SPB ์ผ๋ฐ๊ฒฐ์ )
applepay (์ ํํ์ด)
naverpay(๋ค์ด๋ฒํ์ด)
samsungpay(์ผ์ฑํ์ด)
kpay(KPay์ฑ )
kakaopay(์นด์นด์คํ์ด)
payco(ํ์ด์ฝ)
lpay(LPAY)
ssgpay(SSGํ์ด)
tosspay(ํ ์คํ์ด)
cultureland(์ปฌ์ณ๋๋)
smartculture(์ค๋งํธ๋ฌธ์)
culturegift(๋ฌธํ์ํ๊ถ)
happymoney(ํดํผ๋จธ๋)
booknlife(๋์๋ฌธํ์ํ๊ถ)
point(๋ฒ ๋คํผ์ ํฌ์ธํธ ๋ฑ ํฌ์ธํธ ๊ฒฐ์ )
wechat(์์ณํ์ด)
alipay(์๋ฆฌํ์ด)
unionpay(์ ๋์จํ์ด)
tenpay(ํ
ํ์ด)
pinpay(ํํ์ด)
ssgpay_bank(SSG ์ํ๊ณ์ข)
skpay(11Pay (๊ตฌ.SKPay))
naverpay_card(๋ค์ด๋ฒํ์ด - ์นด๋)
naverpay_point(๋ค์ด๋ฒํ์ด - ํฌ์ธํธ)
paypal(ํ์ดํ)
toss_brandpay(ํ ์คํ์ด๋จผ์ธ ๋ธ๋๋ํ์ด)
tosspay_card (ํ ์คํ์ด - ์นด๋)
tosspay_money (ํ ์คํ์ด - ๋จธ๋(๊ณ์ข, ํฌ์ธํธ))
`;
// https://github.com/junhoyeo/iamport-typings/commit/4513989ad19246453c99fdd85c58a9228f314f04#diff-35e5583b6f6f993f1a5c7ec18937b0a843268a4073e5a5facdd6c6dd5bc12082R2
const OLD_IAMPORT = `
| 'card' // ์ ์ฉ์นด๋
| 'trans' // ์ค์๊ฐ๊ณ์ข์ด์ฒด
| 'vbank' // ๊ฐ์๊ณ์ข
| 'phone' // ํด๋ํฐ์์ก๊ฒฐ์
| 'paypal' // ํ์ดํ SPB ์ผ๋ฐ๊ฒฐ์
| 'applepay' // ์ ํํ์ด
| 'naverpay' // ๋ค์ด๋ฒํ์ด
| 'samsung' // ์ผ์ฑํ์ด
| 'kpay' // KPay์ฑ
| 'kakaopay' // ์นด์นด์คํ์ด
| 'payco' // ํ์ด์ฝ
| 'lpay' // LPAY
| 'ssgpay' // SSGํ์ด
| 'tosspay' // ํ ์ค๊ฐํธ๊ฒฐ์
| 'cultureland' // ๋ฌธํ์ํ๊ถ
| 'smartculture' // ์ค๋งํธ๋ฌธ์
| 'happymoney' // ํดํผ๋จธ๋
| 'booknlife' // ๋์๋ฌธํ์ํ๊ถ
| 'point' // ๋ฒ ๋คํผ์ ํฌ์ธํธ ๋ฑ ํฌ์ธํธ ๊ฒฐ์
| 'wechat' // ์์ณํ์ด
| 'alipay' // ์๋ฆฌํ์ด
| 'unionpay' // ์ ๋์จํ์ด
| 'tenpay' // ํ
ํ์ด
`;
const OLD_ITEMS = OLD_IAMPORT.split('\n').flatMap((line) => {
if (!line) {
return [];
}
const key = line.replace("| '", '').split("' //")[0].trim();
const value = line.split('//')[1].trim();
return { key, value };
});
const items = parseItems(LATEST_PORTONE);
for (const old of OLD_ITEMS) {
if (!items.find((item) => item.key === old.key)) {
items.push({ key: old.key, value: `${old.value} (Deprecated)` });
}
}
items.sort((a, b) => a.key.localeCompare(b.key));
const main = async () => {
const options = await prettier.resolveConfig(
path.resolve(__dirname, '../.prettierrc.js'),
);
const content = await prettier.format(
`
/** @see https://developers.portone.io/docs/ko/sdk/javascript-sdk/payrq */
export type PaymentMethod =
| ${items
.map((item) => {
if (item.value) {
return `'${item.key}' // ${item.value}`;
}
return `'${item.key}'`;
})
.join('\n| ')}
;
`,
{ parser: 'typescript', ...options },
);
fs.writeFileSync(
path.resolve(__dirname, '../src/PaymentMethod.ts'),
content,
'utf-8',
);
};
main()
.then(() => {
console.log('Done โจ');
})
.catch((e) => {
console.error(e);
});