Skip to content

Commit dd48253

Browse files
esazykinDarkaOnLine
authored andcommitted
Mir Card (#12)
* mir payment system * mir payment system
1 parent a76f54d commit dd48253

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

src/Cards/Mir.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace LVR\CreditCard\Cards;
4+
5+
use LVR\CreditCard\Contracts\CreditCard;
6+
7+
/**
8+
* Class Mir.
9+
* @link https://nspk.com/
10+
11+
*/
12+
class Mir extends Card implements CreditCard
13+
{
14+
/**
15+
* Regular expression for card number recognition.
16+
*
17+
* @var string
18+
*/
19+
public static $pattern = '/^220/';
20+
21+
/**
22+
* Credit card type.
23+
*
24+
* @var string
25+
*/
26+
protected $type = 'credit';
27+
28+
/**
29+
* Credit card name.
30+
*
31+
* @var string
32+
*/
33+
protected $name = 'mir';
34+
35+
/**
36+
* Brand name.
37+
*
38+
* @var string
39+
*/
40+
protected $brand = 'Mir';
41+
42+
/**
43+
* Card number length's.
44+
*
45+
* @var array
46+
*/
47+
protected $number_length = [16];
48+
49+
/**
50+
* CVC code length's.
51+
*
52+
* @var array
53+
*/
54+
protected $cvc_length = [3];
55+
56+
/**
57+
* Test cvc code checksum against Luhn algorithm.
58+
*
59+
* @var bool
60+
*/
61+
protected $checksum_test = true;
62+
}

src/Factory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace LVR\CreditCard;
44

55
use LVR\CreditCard\Cards\Jcb;
6+
use LVR\CreditCard\Cards\Mir;
67
use LVR\CreditCard\Cards\Visa;
78
use LVR\CreditCard\Cards\Dankort;
89
use LVR\CreditCard\Cards\Maestro;
@@ -31,6 +32,7 @@ class Factory
3132
Mastercard::class,
3233
UnionPay::class,
3334
Visa::class,
35+
Mir::class,
3436
];
3537

3638
/**

tests/Unit/Cards/BaseCardTests.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ abstract class BaseCardTests extends TestCase
3131
MastercardTest::class,
3232
UnionPayTest::class,
3333
VisaTest::class,
34+
MirTest::class,
3435
];
3536

3637
/** @test **/

tests/Unit/Cards/MirTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace LVR\CreditCard\Tests\Unit\Cards;
4+
5+
use LVR\CreditCard\Cards\Mir;
6+
use Illuminate\Support\Collection;
7+
8+
class MirTest extends BaseCardTests
9+
{
10+
public $instance = Mir::class;
11+
12+
/**
13+
* @return \Illuminate\Support\Collection
14+
*/
15+
public function validNumbers(): Collection
16+
{
17+
return collect([
18+
'2200654321000000',
19+
'2200420152000000',
20+
]);
21+
}
22+
23+
/**
24+
* @return \Illuminate\Support\Collection
25+
*/
26+
public function numbersWithInvalidLength(): Collection
27+
{
28+
return collect([
29+
'2200',
30+
'220065',
31+
'220065432',
32+
'220065432100000',
33+
]);
34+
}
35+
36+
/**
37+
* @return \Illuminate\Support\Collection
38+
*/
39+
public function numbersWithInvalidCheckSum(): Collection
40+
{
41+
return collect([
42+
'2200123456789010',
43+
'2200010400000000',
44+
]);
45+
}
46+
}

0 commit comments

Comments
 (0)