Skip to content

Commit 391c1f3

Browse files
committed
Merge pull request #33 from mikealmond/patch-1
[AIMRefund] Pass credit card expiration date only when one is present
2 parents ccf3229 + e54383a commit 391c1f3

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Message/AIMRefundRequest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ public function getData()
1717

1818
$data['x_trans_id'] = $this->getTransactionReference();
1919
$data['x_card_num'] = $this->getCard()->getNumber();
20-
$data['x_exp_date'] = $this->getCard()->getExpiryDate('my');
20+
21+
$expiryMonth = $this->getCard()->getExpiryMonth();
22+
if (!empty($expiryMonth)) {
23+
$data['x_exp_date'] = $this->getCard()->getExpiryDate('my');
24+
}
25+
2126
$data['x_amount'] = $this->getAmount();
2227

2328
return $data;

tests/Message/AIMRefundRequestTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,24 @@ public function testGetData()
2929
$this->assertSame('60O2UZ', $data['x_trans_id']);
3030
$this->assertSame($card['number'], $data['x_card_num']);
3131
$this->assertSame('12.00', $data['x_amount']);
32+
33+
$this->assertArrayHasKey('x_exp_date', $data);
34+
}
35+
36+
public function testRefundWithSimplifiedCard()
37+
{
38+
$simplifiedCard = array(
39+
'firstName' => 'Example',
40+
'lastName' => 'User',
41+
'number' => '1111',
42+
);
43+
44+
$this->request->setCard($simplifiedCard);
45+
46+
$data = $this->request->getData();
47+
48+
$this->assertSame($simplifiedCard['number'], $data['x_card_num']);
49+
50+
$this->assertArrayNotHasKey('x_exp_date', $data);
3251
}
3352
}

0 commit comments

Comments
 (0)