Skip to content

Commit 923e89d

Browse files
committed
Add Issuer and PaymentMethod classes
1 parent a53454a commit 923e89d

File tree

6 files changed

+179
-0
lines changed

6 files changed

+179
-0
lines changed

src/Omnipay/Common/Issuer.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace Omnipay\Common;
4+
5+
/**
6+
* Issuer
7+
*/
8+
class Issuer
9+
{
10+
protected $id;
11+
protected $name;
12+
protected $paymentMethod;
13+
14+
/**
15+
* Create a new Issuer
16+
*
17+
* @param string $id The identifier of this issuer
18+
* @param string $name The name of this issuer
19+
* @param string|null $paymentMethod The ID of a payment method this issuer belongs to
20+
*/
21+
public function __construct($id, $name, $paymentMethod = null)
22+
{
23+
$this->id = $id;
24+
$this->name = $name;
25+
$this->paymentMethod = $paymentMethod;
26+
}
27+
28+
/**
29+
* The identifier of this issuer
30+
*
31+
* @return string
32+
*/
33+
public function getId()
34+
{
35+
return $this->id;
36+
}
37+
38+
/**
39+
* The name of this issuer
40+
*
41+
* @return string
42+
*/
43+
public function getName()
44+
{
45+
return $this->name;
46+
}
47+
48+
/**
49+
* The ID of a payment method this issuer belongs to
50+
*
51+
* @return string
52+
*/
53+
public function getPaymentMethod()
54+
{
55+
return $this->paymentMethod;
56+
}
57+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Omnipay\Common\Message;
4+
5+
/**
6+
* Fetch Issuers Response interface
7+
*/
8+
interface FetchIssuersResponseInterface extends ResponseInterface
9+
{
10+
/**
11+
* Get the returned list of issuers.
12+
*
13+
* These represent banks which the user must choose between.
14+
*
15+
* @return array An array of \Omnipay\Common\Issuer objects
16+
*/
17+
public function getIssuers();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Omnipay\Common\Message;
4+
5+
/**
6+
* Fetch Payment Methods Response interface
7+
*/
8+
interface FetchPaymentMethodsResponseInterface extends ResponseInterface
9+
{
10+
/**
11+
* Get the returned list of payment methods.
12+
*
13+
* These represent separate payment methods which the user must choose between.
14+
*
15+
* @return array An array of \Omnipay\Common\PaymentMethod objects
16+
*/
17+
public function getPaymentMethods();
18+
}

src/Omnipay/Common/PaymentMethod.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Omnipay\Common;
4+
5+
/**
6+
* Payment Method
7+
*/
8+
class PaymentMethod
9+
{
10+
protected $id;
11+
protected $name;
12+
13+
/**
14+
* Create a new PaymentMethod
15+
*
16+
* @param string $id The identifier of this payment method
17+
* @param string $name The name of this payment method
18+
*/
19+
public function __construct($id, $name)
20+
{
21+
$this->id = $id;
22+
$this->name = $name;
23+
}
24+
25+
/**
26+
* The identifier of this payment method
27+
*
28+
* @return string
29+
*/
30+
public function getId()
31+
{
32+
return $this->id;
33+
}
34+
35+
/**
36+
* The name of this payment method
37+
*
38+
* @return string
39+
*/
40+
public function getName()
41+
{
42+
return $this->name;
43+
}
44+
}

tests/Omnipay/Common/IssuerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Omnipay\Common;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class IssuerTest extends TestCase
8+
{
9+
public function testConstruct()
10+
{
11+
$issuer = new Issuer('99', 'Acme Corp');
12+
13+
$this->assertSame('99', $issuer->getId());
14+
$this->assertSame('Acme Corp', $issuer->getName());
15+
$this->assertNull($issuer->getPaymentMethod());
16+
}
17+
18+
public function testConstructWithPaymentMethod()
19+
{
20+
$issuer = new Issuer('99', 'Acme Corp', 'ideal');
21+
22+
$this->assertSame('99', $issuer->getId());
23+
$this->assertSame('Acme Corp', $issuer->getName());
24+
$this->assertSame('ideal', $issuer->getPaymentMethod());
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Omnipay\Common;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class PaymentMethodTest extends TestCase
8+
{
9+
public function testConstruct()
10+
{
11+
$method = new PaymentMethod('99', 'Acme Corp');
12+
13+
$this->assertSame('99', $method->getId());
14+
$this->assertSame('Acme Corp', $method->getName());
15+
}
16+
}

0 commit comments

Comments
 (0)