-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from getsolaris/2022-11-16
2022-11-16
- Loading branch information
Showing
10 changed files
with
564 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
namespace Getsolaris\LaravelTossPayments\Enums; | ||
|
||
final class BankCode extends CodeProvider | ||
{ | ||
const KYONGNAMBANK = [ | ||
'code' => 39, | ||
'kr' => '경남', | ||
]; | ||
|
||
const GWANGJUBANK = [ | ||
'code' => 34, | ||
'kr' => '광주', | ||
]; | ||
|
||
const LOCALNONGHYEOP = [ | ||
'code' => 12, | ||
'kr' => '단위농협', | ||
]; | ||
|
||
const BUSANBANK = [ | ||
'code' => 32, | ||
'kr' => '부산', | ||
]; | ||
|
||
const SAEMAUL = [ | ||
'code' => 45, | ||
'kr' => '새마을', | ||
]; | ||
|
||
const SANLIM = [ | ||
'code' => 64, | ||
'kr' => '산림', | ||
]; | ||
|
||
const SHINHAN = [ | ||
'code' => 88, | ||
'kr' => '신한', | ||
]; | ||
|
||
const SHINHYEOP = [ | ||
'code' => 48, | ||
'kr' => '신협', | ||
]; | ||
|
||
const CITI = [ | ||
'code' => 27, | ||
'kr' => '씨티', | ||
]; | ||
|
||
const WOORI = [ | ||
'code' => 20, | ||
'kr' => '우리', | ||
]; | ||
|
||
const POST = [ | ||
'code' => 71, | ||
'kr' => '우체국', | ||
]; | ||
|
||
const SAVINGBANK = [ | ||
'code' => 50, | ||
'kr' => '저축', | ||
]; | ||
|
||
const JEONBUKBANK = [ | ||
'code' => 37, | ||
'kr' => '전북', | ||
]; | ||
|
||
const JEJUBANK = [ | ||
'code' => 35, | ||
'kr' => '제주', | ||
]; | ||
|
||
const KAKAOBANK = [ | ||
'code' => 90, | ||
'kr' => '카카오', | ||
]; | ||
|
||
const KBANK = [ | ||
'code' => 89, | ||
'kr' => '케이', | ||
]; | ||
|
||
const TOSSBANK = [ | ||
'code' => 92, | ||
'kr' => '토스', | ||
]; | ||
|
||
const HANA = [ | ||
'code' => 81, | ||
'kr' => '하나', | ||
]; | ||
|
||
const HSBC = [ | ||
'code' => 54, | ||
'kr' => null, | ||
]; | ||
|
||
const DAEGUBANK = [ | ||
'code' => 31, | ||
'kr' => '대구', | ||
]; | ||
|
||
const IBK = [ | ||
'code' => 03, | ||
'kr' => '기업', | ||
]; | ||
|
||
const KDBBANK = [ | ||
'code' => 02, | ||
'kr' => '산업', | ||
]; | ||
|
||
const KOOKMIN = [ | ||
'code' => 06, | ||
'kr' => '국민', | ||
]; | ||
|
||
const NONGHYEOP = [ | ||
'code' => 11, | ||
'kr' => '농협', | ||
]; | ||
|
||
const SC = [ | ||
'code' => 23, | ||
'kr' => 'SC제일', | ||
]; | ||
|
||
const SUHYEOP = [ | ||
'code' => 07, | ||
'kr' => '수협', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Getsolaris\LaravelTossPayments\Enums; | ||
|
||
use Getsolaris\LaravelTossPayments\Exceptions\InvalidInputTargetCodeException; | ||
use LogicException; | ||
|
||
class CodeProvider | ||
{ | ||
/** | ||
* @throws \ReflectionException | ||
* @throws InvalidInputTargetCodeException | ||
*/ | ||
public static function toCode(int|string $code) | ||
{ | ||
$class = get_called_class(); | ||
if ($class === self::class) { | ||
throw new LogicException(get_called_class().' 클래스를 직접 호출할 수 없습니다.'); | ||
} else { | ||
if (defined($class.'::'.$code)) { | ||
return constant($class.'::'.$code)['code']; | ||
} | ||
|
||
$constants = (new \ReflectionClass($class))->getConstants(); | ||
foreach ($constants as $constant) { | ||
if ($constant['code'] === $code) { | ||
return $constant['code']; | ||
} elseif ($constant['kr'] === $code) { | ||
return $constant['code']; | ||
} | ||
} | ||
} | ||
|
||
throw new InvalidInputTargetCodeException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
namespace Getsolaris\LaravelTossPayments\Enums; | ||
|
||
final class DomesticCardCode extends CodeProvider | ||
{ | ||
const GWANGJUBANK = [ | ||
'code' => 46, | ||
'kr' => '광주', | ||
]; | ||
|
||
const LOTTE = [ | ||
'code' => 71, | ||
'kr' => '롯데', | ||
]; | ||
|
||
const KDBBANK = [ | ||
'code' => 30, | ||
'kr' => '산업', | ||
]; | ||
|
||
const BC = [ | ||
'code' => 31, | ||
'kr' => null, | ||
]; | ||
|
||
const SAMSUNG = [ | ||
'code' => 51, | ||
'kr' => '삼성', | ||
]; | ||
|
||
const SAEMAUL = [ | ||
'code' => 38, | ||
'kr' => '새마을', | ||
]; | ||
|
||
const SHINHAN = [ | ||
'code' => 41, | ||
'kr' => '신한', | ||
]; | ||
|
||
const SHINHYEOP = [ | ||
'code' => 62, | ||
'kr' => '신협', | ||
]; | ||
|
||
const CITI = [ | ||
'code' => 36, | ||
'kr' => '씨티', | ||
]; | ||
|
||
const WOORI = [ | ||
'code' => 33, | ||
'kr' => '우리', | ||
]; | ||
|
||
const POST = [ | ||
'code' => 37, | ||
'kr' => '우체국', | ||
]; | ||
|
||
const SAVINGBANK = [ | ||
'code' => 39, | ||
'kr' => '저축', | ||
]; | ||
|
||
const JEONBUKBANK = [ | ||
'code' => 35, | ||
'kr' => '전북', | ||
]; | ||
|
||
const JEJUBANK = [ | ||
'code' => 42, | ||
'kr' => '제주', | ||
]; | ||
|
||
const KAKAOBANK = [ | ||
'code' => 15, | ||
'kr' => '카카오뱅크', | ||
]; | ||
|
||
const KBANK = [ | ||
'code' => '3A', | ||
'kr' => '케이뱅크', | ||
]; | ||
|
||
const TOSSBANK = [ | ||
'code' => 24, | ||
'kr' => '토스뱅크', | ||
]; | ||
|
||
const HANA = [ | ||
'code' => 21, | ||
'kr' => '하나', | ||
]; | ||
|
||
const HYUNDAI = [ | ||
'code' => 61, | ||
'kr' => '현대', | ||
]; | ||
|
||
const KOOKMIN = [ | ||
'code' => 11, | ||
'kr' => '국민', | ||
]; | ||
|
||
const NONGHYEOP = [ | ||
'code' => 91, | ||
'kr' => '농협', | ||
]; | ||
|
||
const SUHYEOP = [ | ||
'code' => 34, | ||
'kr' => '수협', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Getsolaris\LaravelTossPayments\Enums; | ||
|
||
final class ForeignCardCode extends CodeProvider | ||
{ | ||
const DINERS = [ | ||
'code' => '6D', | ||
'kr' => '다이너스', | ||
]; | ||
|
||
const DISCOVER = [ | ||
'code' => '6I', | ||
'kr' => '디스커버', | ||
]; | ||
|
||
const MASTER = [ | ||
'code' => '4M', | ||
'kr' => '마스터', | ||
]; | ||
|
||
const UNIONPAY = [ | ||
'code' => '3C', | ||
'kr' => '유니온페이', | ||
]; | ||
|
||
const JCB = [ | ||
'code' => '4J', | ||
'kr' => null, | ||
]; | ||
|
||
const VISA = [ | ||
'code' => '4V', | ||
'kr' => '비자', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Getsolaris\LaravelTossPayments\Exceptions; | ||
|
||
class InvalidInputTargetCodeException extends \Exception | ||
{ | ||
protected $message = '입력하신 대상 코드가 올바르지 않습니다.'; | ||
} |
Oops, something went wrong.