From ded4964d96c2f0e23aee3f0cacde66c524e749e3 Mon Sep 17 00:00:00 2001 From: jagerchief Date: Wed, 16 May 2018 14:55:27 +0200 Subject: [PATCH 1/2] added card type detector --- .../utils/CardTypeDetector.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php diff --git a/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php b/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php new file mode 100644 index 0000000..af74770 --- /dev/null +++ b/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php @@ -0,0 +1,77 @@ + CardType::VISA, + 'methodName' => 'isVisa' + ], + [ + 'code' => CardType::MASTERCARD, + 'methodName' => 'isMasterCard' + ], + [ + 'code' => CardType::AMEX, + 'methodName' => 'isAmex' + ], + [ + 'code' => CardType::CB, + 'methodName' => 'isDiscover' + ], + [ + 'code' => CardType::JCB, + 'methodName' => 'isJCB' + ], + [ + 'code' => CardType::DINERS, + 'methodName' => 'isDinersClub' + ] + ]; + foreach ($cardTypes as $cardType) { + $method = $cardType['methodName']; + if (self::$method($card)) { + return $cardType['code']; + } + } + return 'Invalid Card'; + } + +} \ No newline at end of file From 26ede483880cdec0885e01058b5bf99aa6018f0e Mon Sep 17 00:00:00 2001 From: jagerchief Date: Wed, 16 May 2018 15:49:22 +0200 Subject: [PATCH 2/2] removed default generated comment --- .../utils/CardTypeDetector.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php b/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php index af74770..f8ed949 100644 --- a/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php +++ b/src/main/php/com-realexpayments-remote-sdk/utils/CardTypeDetector.php @@ -1,10 +1,4 @@