Skip to content

Commit 77d295e

Browse files
authored
Merge pull request #1 from getsolaris/2022-11-16
2022-11-16
2 parents f32b46c + db2e2cc commit 77d295e

10 files changed

+564
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
토스페이먼츠 (Toss Payments) 라라벨 API 입니다.
1010

11-
### API 버전: 2022-07-27
11+
### API 버전: 2022-11-16
1212
[API 버전 정책](https://docs.tosspayments.com/reference/versioning#%EB%82%B4-%EC%83%81%EC%A0%90%EC%9D%98-api-%EB%B2%84%EC%A0%84-%ED%99%95%EC%9D%B8%EB%B3%80%EA%B2%BD%ED%95%98%EA%B8%B0)
1313

1414
---

src/Enums/BankCode.php

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?php
2+
3+
namespace Getsolaris\LaravelTossPayments\Enums;
4+
5+
final class BankCode extends CodeProvider
6+
{
7+
const KYONGNAMBANK = [
8+
'code' => 39,
9+
'kr' => '경남',
10+
];
11+
12+
const GWANGJUBANK = [
13+
'code' => 34,
14+
'kr' => '광주',
15+
];
16+
17+
const LOCALNONGHYEOP = [
18+
'code' => 12,
19+
'kr' => '단위농협',
20+
];
21+
22+
const BUSANBANK = [
23+
'code' => 32,
24+
'kr' => '부산',
25+
];
26+
27+
const SAEMAUL = [
28+
'code' => 45,
29+
'kr' => '새마을',
30+
];
31+
32+
const SANLIM = [
33+
'code' => 64,
34+
'kr' => '산림',
35+
];
36+
37+
const SHINHAN = [
38+
'code' => 88,
39+
'kr' => '신한',
40+
];
41+
42+
const SHINHYEOP = [
43+
'code' => 48,
44+
'kr' => '신협',
45+
];
46+
47+
const CITI = [
48+
'code' => 27,
49+
'kr' => '씨티',
50+
];
51+
52+
const WOORI = [
53+
'code' => 20,
54+
'kr' => '우리',
55+
];
56+
57+
const POST = [
58+
'code' => 71,
59+
'kr' => '우체국',
60+
];
61+
62+
const SAVINGBANK = [
63+
'code' => 50,
64+
'kr' => '저축',
65+
];
66+
67+
const JEONBUKBANK = [
68+
'code' => 37,
69+
'kr' => '전북',
70+
];
71+
72+
const JEJUBANK = [
73+
'code' => 35,
74+
'kr' => '제주',
75+
];
76+
77+
const KAKAOBANK = [
78+
'code' => 90,
79+
'kr' => '카카오',
80+
];
81+
82+
const KBANK = [
83+
'code' => 89,
84+
'kr' => '케이',
85+
];
86+
87+
const TOSSBANK = [
88+
'code' => 92,
89+
'kr' => '토스',
90+
];
91+
92+
const HANA = [
93+
'code' => 81,
94+
'kr' => '하나',
95+
];
96+
97+
const HSBC = [
98+
'code' => 54,
99+
'kr' => null,
100+
];
101+
102+
const DAEGUBANK = [
103+
'code' => 31,
104+
'kr' => '대구',
105+
];
106+
107+
const IBK = [
108+
'code' => 03,
109+
'kr' => '기업',
110+
];
111+
112+
const KDBBANK = [
113+
'code' => 02,
114+
'kr' => '산업',
115+
];
116+
117+
const KOOKMIN = [
118+
'code' => 06,
119+
'kr' => '국민',
120+
];
121+
122+
const NONGHYEOP = [
123+
'code' => 11,
124+
'kr' => '농협',
125+
];
126+
127+
const SC = [
128+
'code' => 23,
129+
'kr' => 'SC제일',
130+
];
131+
132+
const SUHYEOP = [
133+
'code' => 07,
134+
'kr' => '수협',
135+
];
136+
}

src/Enums/CodeProvider.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Getsolaris\LaravelTossPayments\Enums;
4+
5+
use Getsolaris\LaravelTossPayments\Exceptions\InvalidInputTargetCodeException;
6+
use LogicException;
7+
8+
class CodeProvider
9+
{
10+
/**
11+
* @throws \ReflectionException
12+
* @throws InvalidInputTargetCodeException
13+
*/
14+
public static function toCode(int|string $code)
15+
{
16+
$class = get_called_class();
17+
if ($class === self::class) {
18+
throw new LogicException(get_called_class().' 클래스를 직접 호출할 수 없습니다.');
19+
} else {
20+
if (defined($class.'::'.$code)) {
21+
return constant($class.'::'.$code)['code'];
22+
}
23+
24+
$constants = (new \ReflectionClass($class))->getConstants();
25+
foreach ($constants as $constant) {
26+
if ($constant['code'] === $code) {
27+
return $constant['code'];
28+
} elseif ($constant['kr'] === $code) {
29+
return $constant['code'];
30+
}
31+
}
32+
}
33+
34+
throw new InvalidInputTargetCodeException();
35+
}
36+
}

src/Enums/DomesticCardCode.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
3+
namespace Getsolaris\LaravelTossPayments\Enums;
4+
5+
final class DomesticCardCode extends CodeProvider
6+
{
7+
const GWANGJUBANK = [
8+
'code' => 46,
9+
'kr' => '광주',
10+
];
11+
12+
const LOTTE = [
13+
'code' => 71,
14+
'kr' => '롯데',
15+
];
16+
17+
const KDBBANK = [
18+
'code' => 30,
19+
'kr' => '산업',
20+
];
21+
22+
const BC = [
23+
'code' => 31,
24+
'kr' => null,
25+
];
26+
27+
const SAMSUNG = [
28+
'code' => 51,
29+
'kr' => '삼성',
30+
];
31+
32+
const SAEMAUL = [
33+
'code' => 38,
34+
'kr' => '새마을',
35+
];
36+
37+
const SHINHAN = [
38+
'code' => 41,
39+
'kr' => '신한',
40+
];
41+
42+
const SHINHYEOP = [
43+
'code' => 62,
44+
'kr' => '신협',
45+
];
46+
47+
const CITI = [
48+
'code' => 36,
49+
'kr' => '씨티',
50+
];
51+
52+
const WOORI = [
53+
'code' => 33,
54+
'kr' => '우리',
55+
];
56+
57+
const POST = [
58+
'code' => 37,
59+
'kr' => '우체국',
60+
];
61+
62+
const SAVINGBANK = [
63+
'code' => 39,
64+
'kr' => '저축',
65+
];
66+
67+
const JEONBUKBANK = [
68+
'code' => 35,
69+
'kr' => '전북',
70+
];
71+
72+
const JEJUBANK = [
73+
'code' => 42,
74+
'kr' => '제주',
75+
];
76+
77+
const KAKAOBANK = [
78+
'code' => 15,
79+
'kr' => '카카오뱅크',
80+
];
81+
82+
const KBANK = [
83+
'code' => '3A',
84+
'kr' => '케이뱅크',
85+
];
86+
87+
const TOSSBANK = [
88+
'code' => 24,
89+
'kr' => '토스뱅크',
90+
];
91+
92+
const HANA = [
93+
'code' => 21,
94+
'kr' => '하나',
95+
];
96+
97+
const HYUNDAI = [
98+
'code' => 61,
99+
'kr' => '현대',
100+
];
101+
102+
const KOOKMIN = [
103+
'code' => 11,
104+
'kr' => '국민',
105+
];
106+
107+
const NONGHYEOP = [
108+
'code' => 91,
109+
'kr' => '농협',
110+
];
111+
112+
const SUHYEOP = [
113+
'code' => 34,
114+
'kr' => '수협',
115+
];
116+
}

src/Enums/ForeignCardCode.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Getsolaris\LaravelTossPayments\Enums;
4+
5+
final class ForeignCardCode extends CodeProvider
6+
{
7+
const DINERS = [
8+
'code' => '6D',
9+
'kr' => '다이너스',
10+
];
11+
12+
const DISCOVER = [
13+
'code' => '6I',
14+
'kr' => '디스커버',
15+
];
16+
17+
const MASTER = [
18+
'code' => '4M',
19+
'kr' => '마스터',
20+
];
21+
22+
const UNIONPAY = [
23+
'code' => '3C',
24+
'kr' => '유니온페이',
25+
];
26+
27+
const JCB = [
28+
'code' => '4J',
29+
'kr' => null,
30+
];
31+
32+
const VISA = [
33+
'code' => '4V',
34+
'kr' => '비자',
35+
];
36+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Getsolaris\LaravelTossPayments\Exceptions;
4+
5+
class InvalidInputTargetCodeException extends \Exception
6+
{
7+
protected $message = '입력하신 대상 코드가 올바르지 않습니다.';
8+
}

0 commit comments

Comments
 (0)