Completed
Push — master ( 20ad91...e5d1fd )
by Andrii
02:41
created

Gateway::getSecret()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * InterKassa driver for the Omnipay PHP payment processing library
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-interkassa
6
 * @package   omnipay-interkassa
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\InterKassa;
12
13
use Omnipay\Common\AbstractGateway;
14
15
/**
16
 * Gateway for InterKassa Shop Cart Interface.
17
 * http://interkassa.com/.
18
 */
19
class Gateway extends AbstractGateway
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function getName()
25
    {
26 2
        return 'InterKassa';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 58
    public function getDefaultParameters()
33
    {
34
        return [
35 58
            'checkoutId'    => '',
36 58
            'signAlgorithm' => 'md5',
37 58
            'signKey'       => '',
38 58
            'testKey'       => '',
39 58
            'testMode'      => false,
40 58
        ];
41
    }
42
43
    /**
44
     * Get the unified purse.
45
     *
46
     * @return string merchant purse
47
     */
48 14
    public function getPurse()
49
    {
50 14
        return $this->getCheckoutId();
51
    }
52
53
    /**
54
     * Set the unified purse.
55
     *
56
     * @param $value
57
     * @return self
58
     */
59 58
    public function setPurse($value)
60
    {
61 58
        return $this->setCheckoutId($value);
62
    }
63
64
    /**
65
     * Get the unified secret.
66
     * @return string merchant secret - sign key
67
     */
68
    public function getSecret()
69
    {
70
        return $this->getSignKey();
71
    }
72
73
    /**
74
     * Set the unified secret.
75
     * @param string $value merchant secret - sign key
76
     * @return self
77
     */
78
    public function setSecret($value)
79
    {
80
        return $this->setSignKey($value);
81
    }
82
83
    /**
84
     * Get the merchant purse.
85
     *
86
     * @return string merchant purse
87
     */
88 16
    public function getCheckoutId()
89
    {
90 16
        return $this->getParameter('checkoutId');
91
    }
92
93
    /**
94
     * Set the merchant purse.
95
     *
96
     * @param string $value merchant purse
97
     *
98
     * @return self
99
     */
100 58
    public function setCheckoutId($value)
101
    {
102 58
        return $this->setParameter('checkoutId', $value);
103
    }
104
105
    /**
106
     * Get the sign algorithm.
107
     *
108
     * @return string sign algorithm
109
     */
110 2
    public function getSignAlgorithm()
111
    {
112 2
        return $this->getParameter('signAlgorithm');
113
    }
114
115
    /**
116
     * Set the sign algorithm.
117
     *
118
     * @param string $value sign algorithm
119
     *
120
     * @return self
121
     */
122 6
    public function setSignAlgorithm($value)
123
    {
124 6
        return $this->setParameter('signAlgorithm', $value);
125
    }
126
127
    /**
128
     * Get the sign key.
129
     *
130
     * @return string sign key
131
     */
132 4
    public function getSignKey()
133
    {
134 4
        return $this->getParameter('signKey');
135
    }
136
137
    /**
138
     * Set the sign key.
139
     *
140
     * @param string $value sign key
141
     *
142
     * @return self
143
     */
144 58
    public function setSignKey($value)
145
    {
146 58
        return $this->setParameter('signKey', $value);
147
    }
148
149
    /**
150
     * Get the test key.
151
     *
152
     * @return string test key
153
     */
154 4
    public function getTestKey()
155
    {
156 4
        return $this->getParameter('testKey');
157
    }
158
159
    /**
160
     * Set the test key.
161
     *
162
     * @param string $value test key
163
     *
164
     * @return self
165
     */
166 58
    public function setTestKey($value)
167
    {
168 58
        return $this->setParameter('testKey', $value);
169
    }
170
171
    /**
172
     * @param array $parameters
173
     *
174
     * @return \Omnipay\InterKassa\Message\PurchaseRequest|\Omnipay\InterKassa\Message\OldPurchaseRequest
175
     */
176 6
    public function purchase(array $parameters = [])
177
    {
178 6
        if ($this->isOldApi()) {
179 2
            $requestClass = '\Omnipay\InterKassa\Message\OldPurchaseRequest';
180 2
        } else {
181 4
            $requestClass = '\Omnipay\InterKassa\Message\PurchaseRequest';
182
        }
183
184 6
        return $this->createRequest($requestClass, $parameters);
185
    }
186
187
    /**
188
     * @param array $parameters
189
     *
190
     * @return \Omnipay\InterKassa\Message\CompletePurchaseRequest|\Omnipay\InterKassa\Message\OldCompletePurchaseRequest
191
     */
192 6
    public function completePurchase(array $parameters = [])
193
    {
194 6
        if ($this->isOldApi()) {
195 2
            $requestClass = '\Omnipay\InterKassa\Message\OldCompletePurchaseRequest';
196 2
        } else {
197 4
            $requestClass = '\Omnipay\InterKassa\Message\CompletePurchaseRequest';
198
        }
199
200 6
        return $this->createRequest($requestClass, $parameters);
201
    }
202
203
    /**
204
     * Whether the request is designed for API v2.
205
     * @return boolean
206
     */
207 12
    public function isOldApi()
208
    {
209 12
        return strpos($this->getPurse(), '-');
210
    }
211
}
212