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 string $orderId Payment ID in Merchant system |
||
41 | * @param int $amount Payment amount |
||
42 | * @param string $clientIp User IP address |
||
43 | * @param string $url back URL |
||
44 | * @param string $templateTag Used template tag. If empty string - no template tag will be passed |
||
45 | * @param array $extra Payture none requirement extra fields |
||
46 | * |
||
47 | * @throws TransportException |
||
48 | */ |
||
49 | 2 | public function init( |
|
83 | |||
84 | /** |
||
85 | * @see https://payture.com/api#inpay_charge_ |
||
86 | * |
||
87 | * @param string $orderId Payment ID in Merchant system |
||
88 | * @param int $amount Charging amount in kopecks |
||
89 | * |
||
90 | * @throws TransportException |
||
91 | */ |
||
92 | 1 | public function charge(string $orderId, int $amount): TerminalResponse |
|
103 | |||
104 | /** |
||
105 | * Perform partial or full amount unblock for Block session type. |
||
106 | * |
||
107 | * @see https://payture.com/api#inpay_unblock_ |
||
108 | * |
||
109 | * @param string $orderId Payment ID in Merchant system |
||
110 | * @param int $amount Amount in kopecks that is to be returned |
||
111 | * |
||
112 | * @throws TransportException |
||
113 | */ |
||
114 | 1 | public function unblock(string $orderId, int $amount): TerminalResponse |
|
125 | |||
126 | /** |
||
127 | * Create new deal to refund given Amount from the OrderId. |
||
128 | * |
||
129 | * @see https://payture.com/api#inpay_refund_ |
||
130 | * |
||
131 | * @param string $orderId Payment ID in Merchant system |
||
132 | * @param int $amount Amount in kopecks that is to be returned |
||
133 | * |
||
134 | * @throws TransportException |
||
135 | */ |
||
136 | 1 | public function refund(string $orderId, int $amount): TerminalResponse |
|
147 | |||
148 | /** |
||
149 | * @deprecated |
||
150 | * @see PaytureInPayTerminalInterface::getState() |
||
151 | * @see https://payture.com/api#inpay_paystatus_ |
||
152 | * |
||
153 | * @param string $orderId Payment ID in Merchant system |
||
154 | * |
||
155 | * @throws TransportException |
||
156 | */ |
||
157 | 1 | public function payStatus(string $orderId): TerminalResponse |
|
166 | |||
167 | /** |
||
168 | * Returns actual order state. |
||
169 | * |
||
170 | * @see https://payture.com/api/#inpay_getstate_ |
||
171 | * |
||
172 | * @param string $orderId Payment ID in Merchant system |
||
173 | * |
||
174 | * @throws TransportException |
||
175 | */ |
||
176 | 1 | public function getState(string $orderId): TerminalResponse |
|
185 | |||
186 | 1 | public function createPaymentUrl(string $sessionId): string |
|
194 | |||
195 | /** |
||
196 | * @throws TransportException |
||
197 | */ |
||
198 | 7 | private function sendRequest(PaytureOperation $operation, array $parameters): TerminalResponse |
|
204 | } |
||
205 |