1 | <?php |
||
33 | final class Client { |
||
34 | /** |
||
35 | * @var string public application key |
||
36 | */ |
||
37 | private $publicKey = ''; |
||
38 | |||
39 | /** |
||
40 | * @var string private application key |
||
41 | */ |
||
42 | private $privateKey = ''; |
||
43 | |||
44 | /** |
||
45 | * @var int request timeout, seconds |
||
46 | */ |
||
47 | private $timeout = 10; |
||
48 | |||
49 | /** |
||
50 | * @param string $publicKey public application key |
||
51 | * @param string $privateKey private application key |
||
52 | */ |
||
53 | 9 | public function __construct($publicKey, $privateKey = '') { |
|
57 | |||
58 | /** |
||
59 | * REST API method user/resolve implementation |
||
60 | * @param string $id user's unique, unchangeable identifier |
||
61 | * @param string $email user's email address |
||
62 | * @param string $ip user's IP address |
||
63 | * @param null|string $displayName user's display name, if present |
||
64 | * @param null|string $locale user's locale as ISO 639-1 |
||
65 | * @param null|string $phone user's phne number if present |
||
66 | * @return Request user/resolved request instance |
||
67 | * @throws ErrorException if there is an API error |
||
68 | */ |
||
69 | 1 | public function userResolve($id, $email, $ip, $displayName = null, $locale = null, $phone = null) { |
|
88 | |||
89 | /** |
||
90 | * REST API method user/changeRecurring implementation |
||
91 | * @param string $userId user's identifier |
||
92 | * @param null|int $interval automatic recurring interval in days (if set 0, then only manual recurring will remain active) |
||
93 | * @param null|float $price recurring price |
||
94 | * @param null|int $currency recurring currency as ISO 4217 |
||
95 | * @return Request user/changeRecurring request instance |
||
96 | * @throws ErrorException if there is an API error |
||
97 | */ |
||
98 | 1 | public function userChangeRecurring($userId, $interval = null, $price = null, $currency = null) { |
|
115 | |||
116 | /** |
||
117 | * REST API method user/cancelRecurring implementation |
||
118 | * @param string $userId user's identifier |
||
119 | * @return Request user/cancelRecurring request instance |
||
120 | * @throws ErrorException if there is an API error |
||
121 | */ |
||
122 | 1 | public function userCancelRecurring($userId) { |
|
129 | |||
130 | /** |
||
131 | * REST API method card/getToken implementation |
||
132 | * @param string $number credit card's number |
||
133 | * @param int $expirationMonth credit card's expiration month, without leading zero |
||
134 | * @param int $expirationYear credit card's expiration year (4 digits) |
||
135 | * @param string $securityCode credit card's security code: CVC, CVV2 |
||
136 | * @param null|string $callback callback function name for JSONP |
||
137 | * @return Request card/getToken request instance |
||
138 | * @throws ErrorException if there is an API error |
||
139 | */ |
||
140 | 1 | public function cardGetToken($number, $expirationMonth, $expirationYear, $securityCode, $callback = null) { |
|
154 | |||
155 | /** |
||
156 | * REST API method card/process implementation |
||
157 | * @param string $userId user's identifier |
||
158 | * @param string $cardToken credit card token (temporary or permanent) |
||
159 | * @param string $orderId merchant's order ID that will be returned back in a callback |
||
160 | * @param float $price price in real currency |
||
161 | * @param string $currency currency code as ISO 4217 |
||
162 | * @param string $description product description |
||
163 | * @param string $ip user's IP address |
||
164 | * @param string $acsReturnUrl URL where 3DSecure service will return user after the authentication |
||
165 | * @param null|bool $remember indicates whether a user wants to remember his credit card in Merchant's service. |
||
166 | * If true , then permanenToken in response will contain token, that will be used for transaction processing, |
||
167 | * instead of temporary token |
||
168 | * @param null|bool $verifyCard if true, then transaction price will be set to 1 EUR, that will be put on hold and |
||
169 | * then instantly returned |
||
170 | * @param null|bool $recurring indicates whether a user wants to subscribe to recurring payments |
||
171 | * @param null|int $recurringInterval automatic recurring interval in days (if not set or set to 0, then only manual |
||
172 | * recurring will be active) |
||
173 | * @param null|int $recurringTrial Recurring trial period in days (first recurring payment will occur after trial). |
||
174 | * Recurring trial will work only if recurring interval is set |
||
175 | * @param array $attributes custom attributes data |
||
176 | * @return Request card/process request instance |
||
177 | * @throws ErrorException if there is an API error |
||
178 | */ |
||
179 | 1 | public function cardProcess($userId, $cardToken, $orderId, $price, $currency, $description, $ip, $acsReturnUrl, |
|
215 | |||
216 | /** |
||
217 | * REST API method card/authenticate implementation |
||
218 | * @param string $payerResponse payer authentication response. Returned from ACS to acs_return_url |
||
219 | * @param string $merchantData merchant data. Returned from ACS to acs_return_url |
||
220 | * @return Request card/authenticate request instance |
||
221 | * @throws ErrorException if there is an API error |
||
222 | */ |
||
223 | 1 | public function cardAuthenticate($payerResponse, $merchantData) { |
|
231 | |||
232 | /** |
||
233 | * REST API method card/processRecurring implementation |
||
234 | * @param string $userId user's identifier |
||
235 | * @param float $price price in real currency |
||
236 | * @param string $currency currency code as ISO 4217 |
||
237 | * @param null|string $orderId merchant's order ID that will be returned back in a callback |
||
238 | * @param null|string $description product description |
||
239 | * @return Request card/processRecurring request instance |
||
240 | * @throws ErrorException if there is an API error |
||
241 | */ |
||
242 | 1 | public function cardProcessRecurring($userId, $price, $currency, $orderId = null, $description = null) { |
|
258 | |||
259 | /** |
||
260 | * Create request instance |
||
261 | * @param string $method API method name |
||
262 | * @param array $parameters method call parameters |
||
263 | * @param Closure $ResponseBuilder function that building response instance |
||
264 | * @return Request request instance for API call |
||
265 | */ |
||
266 | 7 | private function getRequest($method, $parameters, $ResponseBuilder) { |
|
271 | |||
272 | /** |
||
273 | * Set request timeout |
||
274 | * @param int $timeout seconds |
||
275 | * @return $this |
||
276 | */ |
||
277 | 1 | public function setTimeout($timeout) { |
|
281 | } |
||
282 |