Skip to content

Commit 5dada97

Browse files
authored
Merge pull request #4 from yandex-money/release/v1.0.6
Добавлен метод ТКС.
2 parents 1b357dc + aee3146 commit 5dada97

File tree

60 files changed

+3198
-1587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3198
-1587
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v1.0.6 от 06.03.2019
2+
* Добавлен метод ТКС.
3+
14
### v1.0.5 от 01.06.2018
25
* Добавлена отправка описания платежа в ЛК Яндекс.Кассы
36

oscommerce-yamoney-module.zip

36.2 KB
Binary file not shown.

src/includes/languages/english/modules/payment/yandex_money.php

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_SBERBANK_LABEL', 'Сбербанк Онлайн');
3434
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_WEBMONEY_LABEL', 'Webmoney');
3535
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_ALFABANK_LABEL', 'Альфа-Клик');
36+
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_TINKOFF_BANK_LABEL', 'Интернет-банк Тинькофф');
3637
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_QIWI_LABEL', 'QIWI Wallet');
3738
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_CASH_LABEL', 'Оплата наличными через терминалы');
3839
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_YANDEX_MONEY_LABEL', 'Яндекс.Деньги');
@@ -42,6 +43,7 @@
4243
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_SBERBANK_TEXT', 'Сбербанк Онлайн');
4344
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_WEBMONEY_TEXT', 'Webmoney');
4445
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_ALFABANK_TEXT', 'Альфа-Клик');
46+
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_TINKOFF_BANK_TEXT', 'Интернет-банк Тинькофф');
4547
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_QIWI_TEXT', 'QIWI Wallet');
4648
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_CASH_TEXT', 'Оплата наличными через терминалы');
4749
define('MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_YANDEX_MONEY_TEXT', 'Яндекс.Деньги');

src/includes/modules/payment/yandex_money.php

+45-41
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Yandex_Money
1818
const MODE_MONEY = 2;
1919
const MODE_BILLING = 3;
2020

21-
const MODULE_VERSION = '1.0.5';
21+
const MODULE_VERSION = '1.0.6';
2222
const INSTALLMENTS_MIN_AMOUNT = 3000;
2323

2424
public $code;
@@ -245,48 +245,50 @@ public function selection()
245245
$additional_fields = array();
246246
$payment_types = array();
247247
foreach (PaymentMethodType::getEnabledValues() as $value) {
248-
$const = 'MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_'.strtoupper($value);
249-
if (defined($const) && constant($const) == MODULE_PAYMENT_YANDEX_MONEY_TRUE) {
250-
$const .= '_TEXT';
251-
if ($value === PaymentMethodType::INSTALLMENTS) {
252-
$shopId = $this->getKassa()->getShopId();
253-
$amount = $order->info['total'];
254-
if (self::INSTALLMENTS_MIN_AMOUNT > $amount) {
255-
continue;
256-
}
257-
258-
$monthlyInstallment = InstallmentsApi::creditPreSchedule($shopId, $amount);
259-
if (!isset($monthlyInstallment['amount'])) {
260-
$errorMessage = InstallmentsApi::getLastError() ?: 'Unknown error. Could not get installment amount';
261-
$this->log('error', $errorMessage);
248+
if ($value !== PaymentMethodType::B2B_SBERBANK) {
249+
$const = 'MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_'.strtoupper($value);
250+
if (defined($const) && constant($const) == MODULE_PAYMENT_YANDEX_MONEY_TRUE) {
251+
$const .= '_TEXT';
252+
if ($value === PaymentMethodType::INSTALLMENTS) {
253+
$shopId = $this->getKassa()->getShopId();
254+
$amount = $order->info['total'];
255+
if (self::INSTALLMENTS_MIN_AMOUNT > $amount) {
256+
continue;
257+
}
258+
259+
$monthlyInstallment = InstallmentsApi::creditPreSchedule($shopId, $amount);
260+
if (!isset($monthlyInstallment['amount'])) {
261+
$errorMessage = InstallmentsApi::getLastError() ?: 'Unknown error. Could not get installment amount';
262+
$this->log('error', $errorMessage);
263+
} else {
264+
$text = defined($const) ? constant($const) : $const;
265+
$installmentLabel = sprintf($text,
266+
$monthlyInstallment['amount']);
267+
$payment_types[] = array('id' => $value, 'text' => $installmentLabel);
268+
269+
}
262270
} else {
263-
$text = defined($const) ? constant($const) : $const;
264-
$installmentLabel = sprintf($text,
265-
$monthlyInstallment['amount']);
266-
$payment_types[] = array('id' => $value, 'text' => $installmentLabel);
267-
271+
$payment_types[] = array(
272+
'id' => $value,
273+
'text' => defined($const) ? constant($const) : $const,
274+
);
268275
}
269-
} else {
270-
$payment_types[] = array(
271-
'id' => $value,
272-
'text' => defined($const) ? constant($const) : $const,
273-
);
274-
}
275276

276-
if ($value === PaymentMethodType::QIWI) {
277-
$additional_fields[] = array(
278-
'title' => '',
279-
'field' => '<label for="ya-qiwi-phone">'.MODULE_PAYMENT_YANDEX_MONEY_QIWI_PHONE_LABEL.'</label>'
280-
.tep_draw_input_field('ym_qiwi_phone', '', 'id="ya-qiwi-phone"')
281-
.'<div id="ya-qiwi-phone-error" style="display: none;">'.MODULE_PAYMENT_YANDEX_MONEY_QIWI_PHONE_DESCRIPTION.'</div>',
282-
);
283-
} elseif ($value === PaymentMethodType::ALFABANK) {
284-
$additional_fields[] = array(
285-
'title' => '',
286-
'field' => '<label for="ya-alfa-login">'.MODULE_PAYMENT_YANDEX_MONEY_ALFA_LOGIN_LABEL.'</label>'
287-
.tep_draw_input_field('ym_alfa_login', '', 'id="ya-alfa-login"')
288-
.'<div id="ya-alfa-login-error" style="display: none;">'.MODULE_PAYMENT_YANDEX_MONEY_ALFA_LOGIN_DESCRIPTION.'</div>',
289-
);
277+
if ($value === PaymentMethodType::QIWI) {
278+
$additional_fields[] = array(
279+
'title' => '',
280+
'field' => '<label for="ya-qiwi-phone">'.MODULE_PAYMENT_YANDEX_MONEY_QIWI_PHONE_LABEL.'</label>'
281+
.tep_draw_input_field('ym_qiwi_phone', '', 'id="ya-qiwi-phone"')
282+
.'<div id="ya-qiwi-phone-error" style="display: none;">'.MODULE_PAYMENT_YANDEX_MONEY_QIWI_PHONE_DESCRIPTION.'</div>',
283+
);
284+
} elseif ($value === PaymentMethodType::ALFABANK) {
285+
$additional_fields[] = array(
286+
'title' => '',
287+
'field' => '<label for="ya-alfa-login">'.MODULE_PAYMENT_YANDEX_MONEY_ALFA_LOGIN_LABEL.'</label>'
288+
.tep_draw_input_field('ym_alfa_login', '', 'id="ya-alfa-login"')
289+
.'<div id="ya-alfa-login-error" style="display: none;">'.MODULE_PAYMENT_YANDEX_MONEY_ALFA_LOGIN_DESCRIPTION.'</div>',
290+
);
291+
}
290292
}
291293
}
292294
}
@@ -655,7 +657,9 @@ public function keys()
655657
'MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_DESCRIPTION',
656658
);
657659
foreach (PaymentMethodType::getEnabledValues() as $value) {
658-
$array[] = 'MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_'.strtoupper($value);
660+
if ($value !== PaymentMethodType::B2B_SBERBANK) {
661+
$array[] = 'MODULE_PAYMENT_YANDEX_MONEY_PAYMENT_METHOD_'.strtoupper($value);
662+
}
659663
}
660664
$array[] = 'MODULE_PAYMENT_YANDEX_MONEY_SORT_ORDER';
661665
$array[] = 'MODULE_PAYMENT_YANDEX_MONEY_ORDER_STATUS';

src/includes/modules/payment/yandex_money/yandex-checkout-sdk/lib/Client.php

+78-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Client
8686
/**
8787
* Текущая версия библиотеки
8888
*/
89-
const SDK_VERSION = '1.0.8';
89+
const SDK_VERSION = '1.1.6';
9090

9191
/**
9292
* Имя HTTP заголовка, используемого для передачи idempotence key
@@ -238,6 +238,14 @@ public function setLogger($value)
238238
* @param PaymentOptionsRequestInterface|array $paymentOptionsRequest
239239
*
240240
* @return PaymentOptionsResponse
241+
* @throws ApiException
242+
* @throws BadApiRequestException
243+
* @throws ForbiddenException
244+
* @throws InternalServerError
245+
* @throws NotFoundException
246+
* @throws ResponseProcessingException
247+
* @throws TooManyRequestsException
248+
* @throws UnauthorizedException
241249
*/
242250
public function getPaymentOptions($paymentOptionsRequest = null)
243251
{
@@ -272,6 +280,14 @@ public function getPaymentOptions($paymentOptionsRequest = null)
272280
* @param PaymentsRequestInterface|array|null $filter
273281
*
274282
* @return PaymentsResponse
283+
* @throws ApiException
284+
* @throws BadApiRequestException
285+
* @throws ForbiddenException
286+
* @throws InternalServerError
287+
* @throws NotFoundException
288+
* @throws ResponseProcessingException
289+
* @throws TooManyRequestsException
290+
* @throws UnauthorizedException
275291
*/
276292
public function getPayments($filter = null)
277293
{
@@ -327,6 +343,15 @@ public function getPayments($filter = null)
327343
* @param string $idempotencyKey {@link https://kassa.yandex.ru/docs/checkout-api/?php#idempotentnost}
328344
*
329345
* @return CreatePaymentResponse
346+
* @throws ApiException
347+
* @throws BadApiRequestException
348+
* @throws ForbiddenException
349+
* @throws InternalServerError
350+
* @throws NotFoundException
351+
* @throws ResponseProcessingException
352+
* @throws TooManyRequestsException
353+
* @throws UnauthorizedException
354+
* @throws \Exception
330355
*/
331356
public function createPayment($payment, $idempotencyKey = null)
332357
{
@@ -368,6 +393,14 @@ public function createPayment($payment, $idempotencyKey = null)
368393
* @param string $paymentId
369394
*
370395
* @return PaymentInterface
396+
* @throws ApiException
397+
* @throws BadApiRequestException
398+
* @throws ForbiddenException
399+
* @throws InternalServerError
400+
* @throws NotFoundException
401+
* @throws ResponseProcessingException
402+
* @throws TooManyRequestsException
403+
* @throws UnauthorizedException
371404
*/
372405
public function getPaymentInfo($paymentId)
373406
{
@@ -410,6 +443,15 @@ public function getPaymentInfo($paymentId)
410443
* @param $idempotencyKey {@link https://kassa.yandex.ru/docs/checkout-api/?php#idempotentnost}
411444
*
412445
* @return CreateCaptureResponse
446+
* @throws ApiException
447+
* @throws BadApiRequestException
448+
* @throws ForbiddenException
449+
* @throws InternalServerError
450+
* @throws NotFoundException
451+
* @throws ResponseProcessingException
452+
* @throws TooManyRequestsException
453+
* @throws UnauthorizedException
454+
* @throws \Exception
413455
*/
414456
public function capturePayment($captureRequest, $paymentId, $idempotencyKey = null)
415457
{
@@ -463,6 +505,15 @@ public function capturePayment($captureRequest, $paymentId, $idempotencyKey = nu
463505
* @param $idempotencyKey {@link https://kassa.yandex.ru/docs/checkout-api/?php#idempotentnost}
464506
*
465507
* @return CancelResponse
508+
* @throws ApiException
509+
* @throws BadApiRequestException
510+
* @throws ForbiddenException
511+
* @throws InternalServerError
512+
* @throws NotFoundException
513+
* @throws ResponseProcessingException
514+
* @throws TooManyRequestsException
515+
* @throws UnauthorizedException
516+
* @throws \Exception
466517
*/
467518
public function cancelPayment($paymentId, $idempotencyKey = null)
468519
{
@@ -501,6 +552,14 @@ public function cancelPayment($paymentId, $idempotencyKey = null)
501552
* @param RefundsRequestInterface|array|null $filter
502553
*
503554
* @return RefundsResponse
555+
* @throws ApiException
556+
* @throws BadApiRequestException
557+
* @throws ForbiddenException
558+
* @throws InternalServerError
559+
* @throws NotFoundException
560+
* @throws ResponseProcessingException
561+
* @throws TooManyRequestsException
562+
* @throws UnauthorizedException
504563
*/
505564
public function getRefunds($filter = null)
506565
{
@@ -540,6 +599,15 @@ public function getRefunds($filter = null)
540599
* @param null $idempotencyKey {@link https://kassa.yandex.ru/docs/checkout-api/?php#idempotentnost}
541600
*
542601
* @return CreateRefundResponse
602+
* @throws ApiException
603+
* @throws BadApiRequestException
604+
* @throws ForbiddenException
605+
* @throws InternalServerError
606+
* @throws NotFoundException
607+
* @throws ResponseProcessingException
608+
* @throws TooManyRequestsException
609+
* @throws UnauthorizedException
610+
* @throws \Exception
543611
*/
544612
public function createRefund($request, $idempotencyKey = null)
545613
{
@@ -579,6 +647,14 @@ public function createRefund($request, $idempotencyKey = null)
579647
* @param $refundId
580648
*
581649
* @return RefundResponse
650+
* @throws ApiException
651+
* @throws BadApiRequestException
652+
* @throws ForbiddenException
653+
* @throws InternalServerError
654+
* @throws NotFoundException
655+
* @throws ResponseProcessingException
656+
* @throws TooManyRequestsException
657+
* @throws UnauthorizedException
582658
*/
583659
public function getRefundInfo($refundId)
584660
{
@@ -759,6 +835,7 @@ protected function delay($response)
759835
* @param array $headers
760836
*
761837
* @return ResponseObject
838+
* @throws Common\Exceptions\AuthorizeException
762839
*/
763840
private function execute($path, $method, $queryParams, $httpBody = null, $headers = array())
764841
{

src/includes/modules/payment/yandex_money/yandex-checkout-sdk/lib/Client/CurlClient.php

+39-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class CurlClient implements ApiClientInterface
6565
*/
6666
private $connectionTimeout = 30;
6767

68+
/**
69+
* @var string
70+
*/
71+
private $proxy;
72+
6873
/**
6974
* @var bool
7075
*/
@@ -98,6 +103,15 @@ public function setLogger($logger)
98103

99104
/**
100105
* @inheritdoc
106+
* @param $path
107+
* @param $method
108+
* @param $queryParams
109+
* @param null $httpBody
110+
* @param array $headers
111+
* @return ResponseObject
112+
* @throws ApiConnectionException
113+
* @throws ApiException
114+
* @throws AuthorizeException
101115
*/
102116
public function call($path, $method, $queryParams, $httpBody = null, $headers = array())
103117
{
@@ -109,7 +123,7 @@ public function call($path, $method, $queryParams, $httpBody = null, $headers =
109123
if (!empty($httpBody)) {
110124
$message .= ' with body: ' . $httpBody;
111125
}
112-
if (!empty($httpBody)) {
126+
if (!empty($headers)) {
113127
$message .= ' with headers: ' . json_encode($headers);
114128
}
115129
$this->logger->info($message);
@@ -139,6 +153,11 @@ public function call($path, $method, $queryParams, $httpBody = null, $headers =
139153
$this->setCurlOption(CURLOPT_USERPWD, "{$this->shopId}:{$this->shopPassword}");
140154
}
141155

156+
if ($this->proxy) {
157+
$this->setCurlOption(CURLOPT_PROXY, $this->proxy);
158+
$this->setCurlOption(CURLOPT_HTTPPROXYTUNNEL, true);
159+
}
160+
142161
$this->setBody($method, $httpBody);
143162

144163
$this->setCurlOption(CURLOPT_HTTPHEADER, $headers);
@@ -204,6 +223,7 @@ public function closeCurlConnection()
204223

205224
/**
206225
* @return array
226+
* @throws ApiConnectionException
207227
*/
208228
public function sendRequest()
209229
{
@@ -312,6 +332,24 @@ public function setConnectionTimeout($connectionTimeout)
312332
$this->connectionTimeout = $connectionTimeout;
313333
}
314334

335+
/**
336+
* @return string
337+
* @since 1.0.14
338+
*/
339+
public function getProxy()
340+
{
341+
return $this->proxy;
342+
}
343+
344+
/**
345+
* @param string $proxy
346+
* @since 1.0.14
347+
*/
348+
public function setProxy($proxy)
349+
{
350+
$this->proxy = $proxy;
351+
}
352+
315353
/**
316354
* @return mixed
317355
*/

src/includes/modules/payment/yandex_money/yandex-checkout-sdk/lib/Common/AbstractObject.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ public function offsetSet($offset, $value)
8787
{
8888
$method = 'set' . ucfirst($offset);
8989
if (method_exists($this, $method)) {
90-
$this->{$method} ($value);
90+
$this->{$method}($value);
9191
} else {
9292
$method = 'set' . self::matchPropertyName($offset);
9393
if (method_exists($this, $method)) {
94-
return $this->{$method} ($value);
94+
$this->{$method}($value);
9595
} else {
9696
$this->unknownProperties[$offset] = $value;
9797
}
@@ -179,6 +179,9 @@ public function jsonSerialize()
179179
if ($method === 'getUnknownProperties') {
180180
continue;
181181
}
182+
if ($method === 'getIterator') {
183+
continue;
184+
}
182185
$property = strtolower(preg_replace('/[A-Z]/', '_\0', lcfirst(substr($method, 3))));
183186
$value = $this->serializeValueToJson($this->{$method} ());
184187
if ($value !== null) {

0 commit comments

Comments
 (0)