Completed
Push — master ( 83ab12...b898e2 )
by Dmitry
09:44
created

CompletePurchaseResponse::getCurrency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * ePayService driver for the Omnipay PHP payment processing library.
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-epayservice
6
 * @package   omnipay-epayservice
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\ePayService\Message;
12
13
use Omnipay\Common\Exception\InvalidResponseException;
14
use Omnipay\Common\Message\AbstractResponse;
15
use Omnipay\Common\Message\RequestInterface;
16
17
/**
18
 * ePayService Complete Purchase Response.
19
 */
20
class CompletePurchaseResponse extends AbstractResponse
21
{
22 3
    public function __construct(RequestInterface $request, $data)
23
    {
24 3
        $this->request = $request;
25 3
        $this->data    = $data;
26
27 3
        if ($this->getHash() !== $this->calculateHash()) {
28 1
            throw new InvalidResponseException('Invalid hash');
29
        }
30 2
    }
31
32 3
    public function getHash()
33
    {
34 3
        return strtolower($this->data['check_key']);
35
    }
36
37 3
    public function calculateHash()
38
    {
39 3
        return md5($this->data['EPS_AMOUNT'] . $this->data['EPS_GUID'] . $this->data['secret']);
40
    }
41
42 1
    public function isSuccessful()
43
    {
44 1
        return $this->data['EPS_RESULT'] === 'done';
45
    }
46
47 1
    public function getTransactionId()
48
    {
49 1
        return $this->data['EPS_TRID'];
50
    }
51
52 1
    public function getTransactionReference()
53
    {
54 1
        return $this->data['EPS_ACCNUM'];
55
    }
56
57 1
    public function getAmount()
58
    {
59 1
        return $this->data['EPS_AMOUNT'];
60
    }
61
62
    public function getTestMode()
63
    {
64
        return (bool) $this->data['testMode'];
65
    }
66
67 1
    public function getCurrency()
68
    {
69 1
        return $this->data['EPS_CURRENCY'];
70
    }
71
}
72