File tree Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace LVR \CreditCard \Cards ;
4+
5+ use LVR \CreditCard \Contracts \CreditCard ;
6+
7+ class Troy extends Card implements CreditCard
8+ {
9+ /**
10+ * Regular expression for card number recognition.
11+ *
12+ * @var string
13+ */
14+ public static $ pattern = '/^9(?!(79200|79289))/ ' ; // 979200 and 979289 are starts for Troy
15+
16+ /**
17+ * Credit card type.
18+ *
19+ * @var string
20+ */
21+ protected $ type = 'credit ' ;
22+
23+ /**
24+ * Credit card name.
25+ *
26+ * @var string
27+ */
28+ protected $ name = 'troy ' ;
29+
30+ /**
31+ * Brand name.
32+ *
33+ * @var string
34+ */
35+ protected $ brand = 'Troy ' ;
36+
37+ /**
38+ * Card number length's.
39+ *
40+ * @var array
41+ */
42+ protected $ number_length = [16 ];
43+
44+ /**
45+ * CVC code length's.
46+ *
47+ * @var array
48+ */
49+ protected $ cvc_length = [3 ];
50+
51+ /**
52+ * Test cvc code checksum against Luhn algorithm.
53+ *
54+ * @var bool
55+ */
56+ protected $ checksum_test = true ;
57+ }
Original file line number Diff line number Diff line change 55use LVR \CreditCard \Cards \Jcb ;
66use LVR \CreditCard \Cards \Mir ;
77use LVR \CreditCard \Cards \Visa ;
8+ use LVR \CreditCard \Cards \Troy ;
89use LVR \CreditCard \Cards \Dankort ;
910use LVR \CreditCard \Cards \Maestro ;
1011use LVR \CreditCard \Cards \UnionPay ;
@@ -35,6 +36,7 @@ class Factory
3536 UnionPay::class,
3637 Visa::class,
3738 Mir::class,
39+ Troy::class,
3840 ];
3941
4042 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace LVR \CreditCard \Tests \Unit \Cards ;
4+
5+ use LVR \CreditCard \Cards \Troy ;
6+ use Illuminate \Support \Collection ;
7+
8+ class TroyTest extends BaseCardTests
9+ {
10+ public $ instance = Troy::class;
11+
12+ /**
13+ * @return \Illuminate\Support\Collection
14+ */
15+ public function validNumbers (): Collection
16+ {
17+ return collect ([
18+ '9792112633252339 ' ,
19+ '9792020000000001 ' ,
20+ '9792030000000000 ' ,
21+ '9792122738534192 ' ,
22+ ]);
23+ }
24+
25+ /**
26+ * @return \Illuminate\Support\Collection
27+ */
28+ public function numbersWithInvalidLength (): Collection
29+ {
30+ return collect ([
31+ '9711111 ' ,
32+ '971111111111111 ' ,
33+ '97110009901394241 ' ,
34+ ]);
35+ }
36+
37+ /**
38+ * @return \Illuminate\Support\Collection
39+ */
40+ public function numbersWithInvalidCheckSum (): Collection
41+ {
42+ return collect ([
43+ '9792112633252341 ' ,
44+ '9792112635452339 ' ,
45+ ]);
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments