1 | <?php |
||
7 | final class PaytureInPayTerminal implements PaytureInPayTerminalInterface |
||
8 | { |
||
9 | private const API_PREFIX = 'apim'; |
||
10 | |||
11 | /** @var TerminalConfiguration */ |
||
12 | private $config; |
||
13 | |||
14 | /** @var TransportInterface */ |
||
15 | private $transport; |
||
16 | |||
17 | 8 | public function __construct(TerminalConfiguration $config, TransportInterface $transport) |
|
22 | |||
23 | 2 | private static function mapSessionType(SessionType $sessionType): string |
|
36 | |||
37 | /** |
||
38 | * @see https://payture.com/api#inpay_init_ |
||
39 | * |
||
40 | * @param SessionType $sessionType |
||
41 | * @param string $orderId Payment ID in Merchant system |
||
42 | * @param string $product |
||
43 | * @param int $amount Payment amount |
||
44 | * @param string $clientIp User IP address |
||
45 | * @param string $url back URL |
||
46 | * @param string $templateTag Used template tag. If empty string - no template tag will be passed |
||
47 | * @param array $extra Payture none requirement extra fields |
||
48 | * |
||
49 | * @return TerminalResponse |
||
50 | * |
||
51 | * @throws TransportException |
||
52 | */ |
||
53 | 2 | public function init( |
|
87 | |||
88 | /** |
||
89 | * @see https://payture.com/api#inpay_charge_ |
||
90 | * |
||
91 | * @param string $orderId Payment ID in Merchant system |
||
92 | * @param int $amount Charging amount in kopecks |
||
93 | * |
||
94 | * @return TerminalResponse |
||
95 | * |
||
96 | * @throws TransportException |
||
97 | */ |
||
98 | 1 | public function charge(string $orderId, int $amount): TerminalResponse |
|
109 | |||
110 | /** |
||
111 | * Perform partial or full amount unblock for Block session type. |
||
112 | * |
||
113 | * @see https://payture.com/api#inpay_unblock_ |
||
114 | * |
||
115 | * @param string $orderId Payment ID in Merchant system |
||
116 | * @param int $amount Amount in kopecks that is to be returned |
||
117 | * |
||
118 | * @return TerminalResponse |
||
119 | * |
||
120 | * @throws TransportException |
||
121 | */ |
||
122 | 1 | public function unblock(string $orderId, int $amount): TerminalResponse |
|
133 | |||
134 | /** |
||
135 | * Create new deal to refund given Amount from the OrderId. |
||
136 | * |
||
137 | * @see https://payture.com/api#inpay_refund_ |
||
138 | * |
||
139 | * @param string $orderId Payment ID in Merchant system |
||
140 | * @param int $amount Amount in kopecks that is to be returned |
||
141 | * |
||
142 | * @return TerminalResponse |
||
143 | * |
||
144 | * @throws TransportException |
||
145 | */ |
||
146 | 1 | public function refund(string $orderId, int $amount): TerminalResponse |
|
157 | |||
158 | /** |
||
159 | * @deprecated |
||
160 | * @see PaytureInPayTerminalInterface::getState() |
||
161 | * |
||
162 | * @see https://payture.com/api#inpay_paystatus_ |
||
163 | * |
||
164 | * @param string $orderId Payment ID in Merchant system |
||
165 | * |
||
166 | * @return TerminalResponse |
||
167 | * |
||
168 | * @throws TransportException |
||
169 | */ |
||
170 | 1 | public function payStatus(string $orderId): TerminalResponse |
|
179 | |||
180 | /** |
||
181 | * Returns actual order state |
||
182 | * |
||
183 | * @see https://payture.com/api/#inpay_getstate_ |
||
184 | * |
||
185 | * @param string $orderId Payment ID in Merchant system |
||
186 | * |
||
187 | * @return TerminalResponse |
||
188 | * |
||
189 | * @throws TransportException |
||
190 | */ |
||
191 | 1 | public function getState(string $orderId): TerminalResponse |
|
200 | |||
201 | 1 | public function createPaymentUrl(string $sessionId): string |
|
209 | |||
210 | /** |
||
211 | * @param PaytureOperation $operation |
||
212 | * @param array $parameters |
||
213 | * |
||
214 | * @return TerminalResponse |
||
215 | * |
||
216 | * @throws TransportException |
||
217 | */ |
||
218 | 7 | private function sendRequest(PaytureOperation $operation, array $parameters): TerminalResponse |
|
224 | } |
||
225 |