Skip to content

Commit e8cdb1b

Browse files
incarnateamacneil
authored andcommitted
Add title and fax fields to CreditCard. Closes #5
1 parent b35fd89 commit e8cdb1b

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

src/Omnipay/Common/CreditCard.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ public function validate()
142142
}
143143
}
144144

145+
public function getTitle()
146+
{
147+
return $this->getBillingTitle();
148+
}
149+
150+
public function setTitle($value)
151+
{
152+
$this->setBillingTitle($value);
153+
$this->setShippingTitle($value);
154+
155+
return $this;
156+
}
157+
145158
public function getFirstName()
146159
{
147160
return $this->getBillingFirstName();
@@ -310,6 +323,16 @@ public function setIssueNumber($value)
310323
return $this->setParameter('issueNumber', $value);
311324
}
312325

326+
public function getBillingTitle()
327+
{
328+
return $this->getParameter('billingTitle');
329+
}
330+
331+
public function setBillingTitle($value)
332+
{
333+
return $this->setParameter('billingTitle', $value);
334+
}
335+
313336
public function getBillingName()
314337
{
315338
return trim($this->getBillingFirstName() . ' ' . $this->getBillingLastName());
@@ -424,6 +447,26 @@ public function setBillingPhone($value)
424447
return $this->setParameter('billingPhone', $value);
425448
}
426449

450+
public function getBillingFax()
451+
{
452+
return $this->getParameter('billingFax');
453+
}
454+
455+
public function setBillingFax($value)
456+
{
457+
return $this->setParameter('billingFax', $value);
458+
}
459+
460+
public function getShippingTitle()
461+
{
462+
return $this->getParameter('shippingTitle');
463+
}
464+
465+
public function setShippingTitle($value)
466+
{
467+
return $this->setParameter('shippingTitle', $value);
468+
}
469+
427470
public function getShippingName()
428471
{
429472
return trim($this->getShippingFirstName() . ' ' . $this->getShippingLastName());
@@ -538,6 +581,16 @@ public function setShippingPhone($value)
538581
return $this->setParameter('shippingPhone', $value);
539582
}
540583

584+
public function getShippingFax()
585+
{
586+
return $this->getParameter('shippingFax');
587+
}
588+
589+
public function setShippingFax($value)
590+
{
591+
return $this->setParameter('shippingFax', $value);
592+
}
593+
541594
public function getAddress1()
542595
{
543596
return $this->getParameter('billingAddress1');
@@ -629,6 +682,19 @@ public function setPhone($value)
629682
return $this;
630683
}
631684

685+
public function getFax()
686+
{
687+
return $this->getParameter('billingFax');
688+
}
689+
690+
public function setFax($value)
691+
{
692+
$this->setParameter('billingFax', $value);
693+
$this->setParameter('shippingFax', $value);
694+
695+
return $this;
696+
}
697+
632698
public function getCompany()
633699
{
634700
return $this->getParameter('billingCompany');

tests/Omnipay/Common/CreditCardTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ public function testGetSupportedBrands()
109109
$this->assertArrayHasKey(CreditCard::BRAND_VISA, $brands);
110110
}
111111

112+
public function testTitle()
113+
{
114+
$this->card->setTitle('Mr.');
115+
$this->assertEquals('Mr.', $this->card->getTitle());
116+
}
117+
112118
public function testFirstName()
113119
{
114120
$this->card->setFirstName('Bob');
@@ -309,6 +315,13 @@ public function testIssueNumber()
309315
$this->assertSame('12', $this->card->getIssueNumber());
310316
}
311317

318+
public function testBillingTitle()
319+
{
320+
$this->card->setBillingTitle('Mrs.');
321+
$this->assertEquals('Mrs.', $this->card->getBillingTitle());
322+
$this->assertEquals('Mrs.', $this->card->getTitle());
323+
}
324+
312325
public function testBillingFirstName()
313326
{
314327
$this->card->setBillingFirstName('Bob');
@@ -390,6 +403,19 @@ public function testBillingPhone()
390403
$this->assertSame('12345', $this->card->getPhone());
391404
}
392405

406+
public function testBillingFax()
407+
{
408+
$this->card->setBillingFax('54321');
409+
$this->assertSame('54321', $this->card->getBillingFax());
410+
$this->assertSame('54321', $this->card->getFax());
411+
}
412+
413+
public function testShippingTitle()
414+
{
415+
$this->card->setShippingTitle('Dr.');
416+
$this->assertEquals('Dr.', $this->card->getShippingTitle());
417+
}
418+
393419
public function testShippingFirstName()
394420
{
395421
$this->card->setShippingFirstName('James');
@@ -461,6 +487,12 @@ public function testShippingPhone()
461487
$this->assertEquals('12345', $this->card->getShippingPhone());
462488
}
463489

490+
public function testShippingFax()
491+
{
492+
$this->card->setShippingFax('54321');
493+
$this->assertEquals('54321', $this->card->getShippingFax());
494+
}
495+
464496
public function testCompany()
465497
{
466498
$this->card->setCompany('FooBar');
@@ -525,6 +557,14 @@ public function testPhone()
525557
$this->assertEquals('12345', $this->card->getShippingPhone());
526558
}
527559

560+
public function testFax()
561+
{
562+
$this->card->setFax('54321');
563+
$this->assertEquals('54321', $this->card->getFax());
564+
$this->assertEquals('54321', $this->card->getBillingFax());
565+
$this->assertEquals('54321', $this->card->getShippingFax());
566+
}
567+
528568
public function testEmail()
529569
{
530570
$this->card->setEmail('[email protected]');

0 commit comments

Comments
 (0)