Completed
Push — master ( 136808...1b7afa )
by Dmitry
9s
created

AbstractRequest::setSignKey()   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 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * InterKassa driver for the Omnipay PHP payment processing library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-interkassa
7
 * @package   omnipay-interkassa
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\InterKassa\Message;
13
14
/**
15
 * InterKassa Abstract Request.
16
 */
17
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected $zeroAmountAllowed = false;
23
24
    /**
25
     * @var string
26
     */
27
    protected $endpoint = 'https://sci.interkassa.com/';
28
29
    /**
30
     * Get the unified purse.
31
     *
32
     * @return string merchant purse
33
     */
34 2
    public function getPurse()
35
    {
36 2
        return $this->getCheckoutId();
37
    }
38
39
    /**
40
     * Set the unified purse.
41
     *
42
     * @param $value
43
     * @return self
44
     */
45 9
    public function setPurse($value)
46
    {
47 9
        return $this->setCheckoutId($value);
48
    }
49
50
    /**
51
     * Get the merchant purse.
52
     *
53
     * @return string merchant purse
54
     */
55 9
    public function getCheckoutId()
56
    {
57 9
        return $this->getParameter('checkoutId');
58
    }
59
60
    /**
61
     * Set the merchant purse.
62
     *
63
     * @param string $purse merchant purse
64
     *
65
     * @return self
66
     */
67 21
    public function setCheckoutId($purse)
68
    {
69 21
        return $this->setParameter('checkoutId', $purse);
70
    }
71
72
    /**
73
     * Get the sign algorithm.
74
     *
75
     * @return string sign algorithm
76
     */
77 13
    public function getSignAlgorithm()
78
    {
79 13
        return strtolower($this->getParameter('signAlgorithm'));
80
    }
81
82
    /**
83
     * Set the sign algorithm.
84
     *
85
     * @param string $value sign algorithm
86
     *
87
     * @return self
88
     */
89 27
    public function setSignAlgorithm($value)
90
    {
91 27
        return $this->setParameter('signAlgorithm', $value);
92
    }
93
94
    /**
95
     * Get the sign key.
96
     *
97
     * @return string sign key
98
     */
99 15
    public function getSignKey()
100
    {
101 15
        return $this->getParameter('signKey');
102
    }
103
104
    /**
105
     * Set the sign key.
106
     *
107
     * @param string $value sign key
108
     *
109
     * @return self
110
     */
111 27
    public function setSignKey($value)
112
    {
113 27
        return $this->setParameter('signKey', $value);
114
    }
115
116
    /**
117
     * Get the test key.
118
     *
119
     * @return string test key
120
     */
121 4
    public function getTestKey()
122
    {
123 4
        return $this->getParameter('testKey');
124
    }
125
126
    /**
127
     * Set the test key.
128
     *
129
     * @param string $value test key
130
     *
131
     * @return self
132
     */
133 17
    public function setTestKey($value)
134
    {
135 17
        return $this->setParameter('testKey', $value);
136
    }
137
138
    /**
139
     * Get the method for success return.
140
     *
141
     * @return mixed
142
     */
143 3
    public function getReturnMethod()
144
    {
145 3
        return $this->getParameter('returnMethod');
146
    }
147
148
    /**
149
     * Sets the method for success return.
150
     *
151
     * @param $returnMethod
152
     * @return \Omnipay\Common\Message\AbstractRequest
153
     */
154 1
    public function setReturnMethod($returnMethod)
155
    {
156 1
        return $this->setParameter('returnMethod', $returnMethod);
157
    }
158
159
    /**
160
     * Get the method for canceled payment return.
161
     *
162
     * @return mixed
163
     */
164 3
    public function getCancelMethod()
165
    {
166 3
        return $this->getParameter('returnMethod');
167
    }
168
169
    /**
170
     * Sets the method for canceled payment return.
171
     *
172
     * @param $cancelMethod
173
     * @return \Omnipay\Common\Message\AbstractRequest
174
     */
175 1
    public function setCancelMethod($cancelMethod)
176
    {
177 1
        return $this->setParameter('cancelMethod', $cancelMethod);
178
    }
179
180
    /**
181
     * Get the method for request notify.
182
     *
183
     * @return mixed
184
     */
185 3
    public function getNotifyMethod()
186
    {
187 3
        return $this->getParameter('notifyMethod');
188
    }
189
190
    /**
191
     * Sets the method for request notify.
192
     *
193
     * @param $notifyMethod
194
     * @return \Omnipay\Common\Message\AbstractRequest
195
     */
196 1
    public function setNotifyMethod($notifyMethod)
197
    {
198 1
        return $this->setParameter('notifyMethod', $notifyMethod);
199
    }
200
201
    /**
202
     * Calculates sign for the $data.
203
     *
204
     * @param array $data
205
     * @param string $signKey
206
     * @return string
207
     */
208 5 View Code Duplication
    public function calculateSign($data, $signKey)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
209
    {
210 5
        unset($data['ik_sign']);
211 5
        ksort($data, SORT_STRING);
212 5
        array_push($data, $signKey);
213 5
        $signAlgorithm = $this->getSignAlgorithm();
214 5
        $signString = implode(':', $data);
215 5
        return base64_encode(hash($signAlgorithm, $signString, true));
216
    }
217
}
218