Skip to content

Commit f8226d2

Browse files
committed
Merge branch 'master' of github.com:superbrave/omnipay-icepay-payments
2 parents c6ea98f + 52937f2 commit f8226d2

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/Message/AbstractRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class AbstractRequest extends OmnipayAbstractRequest
2626
*/
2727
public function getData(): array
2828
{
29-
$this->validate('contractProfileId', 'secretKey', 'timestamp'); // @todo add more keys to validate.
29+
$this->validate('contractProfileId', 'secretKey', 'timestamp', 'currencyCode');
3030

3131
return array();
3232
}

src/Message/RefundRequest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Omnipay\IcepayPayments\Message;
44

5+
use Omnipay\Common\Exception\InvalidRequestException;
56
use Omnipay\Common\Message\ResponseInterface;
67

78
/**
@@ -27,9 +28,15 @@ public function getData(): array
2728

2829
/**
2930
* {@inheritdoc}
31+
*
32+
* @throws InvalidRequestException When transaction reference is not set.
3033
*/
3134
public function sendData($data): ResponseInterface
3235
{
36+
if (empty($this->getTransactionReference())) {
37+
throw new InvalidRequestException('Transaction reference missing for refund request.');
38+
}
39+
3340
$this->sendRequest(
3441
self::METHOD_POST,
3542
sprintf(

tests/Message/RefundRequestTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\IcepayPayments\Message;
44

55
use GuzzleHttp\Psr7\Request;
6+
use Omnipay\Common\Exception\InvalidRequestException;
67
use Omnipay\Common\Http\Client;
78
use Omnipay\IcepayPayments\AbstractTestCase;
89

@@ -34,7 +35,7 @@ protected function setUp(): void
3435
/**
3536
* Test a valid request for a refund.
3637
*/
37-
public function testRefundGetDataWithValidValues()
38+
public function testRefundGetDataWithValidValues(): void
3839
{
3940
$expected = [
4041
'ContractProfileId' => '1-4M-4-B1G-B1G-G1RL',
@@ -54,7 +55,7 @@ public function testRefundGetDataWithValidValues()
5455
/**
5556
* Test actually sending the data to the client.
5657
*/
57-
public function testSendData()
58+
public function testRefundSendDataWithValidRequest(): void
5859
{
5960
$this->request->setTransactionReference('1M-MR-M33533K5-L00K-47-M3');
6061
$response = $this->request->sendData($this->request->getData());
@@ -69,4 +70,15 @@ public function testSendData()
6970
$this->assertEquals($expectedRequest->getMethod(), $this->clientMock->getLastRequest()->getMethod());
7071
$this->assertEquals($expectedRequest->getUri(), $this->clientMock->getLastRequest()->getUri());
7172
}
73+
74+
/**
75+
* Test actually sending the data to the client.
76+
*/
77+
public function testRefundSendDataWithMissingReference(): void
78+
{
79+
$this->expectException(InvalidRequestException::class);
80+
81+
$this->request->setTransactionReference('');
82+
$this->request->sendData($this->request->getData());
83+
}
7284
}

0 commit comments

Comments
 (0)