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

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