Skip to content

Commit

Permalink
Merge pull request #37 from yandex-money/release/v1.3.0
Browse files Browse the repository at this point in the history
Добавлен способ оплаты через виджет
  • Loading branch information
pavel52rus authored Apr 24, 2020
2 parents 0315ea1 + e07bd33 commit 1a318a7
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 78 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v1.3.0 от 24.04.2020
* Добавлен способ оплаты через виджет

### v1.2.0 от 23.10.2019
* Добавлена поддержка отправки второго чека

Expand Down
Binary file modified src/components/com_jshopping/images/yandex_money/ac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @copyright Copyright (C) 2012-2017 YandexMoney. All rights reserved.
*/

use YandexCheckout\Model\PaymentMethodType;

defined('_JEXEC') or die('Restricted access');

echo JHtml::_('bootstrap.addTab', 'yamTab', 'kassa-tab', _JSHOP_YM_TAB_KASSA);
Expand Down Expand Up @@ -109,21 +111,19 @@ class=""><?php echo _JSHOP_YM_KASSA_PASSWORD_LABEL; ?></label></div>
<p><?php echo _JSHOP_YM_KASSA_SELECT_TEXT; ?></p>
</div>
</div>
<?php foreach (\YandexCheckout\Model\PaymentMethodType::getEnabledValues() as $value) : ?>
<?php if (!in_array($value, $offPaymentMethods)): ?>
<div class="row with-select">
<div class="span11 offset1">
<div class="span8 offset2">
<input type="checkbox" class="form-control input-kassa"
name="pm_params[method_<?php echo $value; ?>]" value="1"
<?php if ($params['method_'.$value] == '1') {
echo "checked";
} ?> />
<?php echo constant('_JSHOP_YM_METHOD_'.strtoupper($value).'_DESCRIPTION'); ?>
</div>
<?php foreach ($params['paymentMethods'] as $value) : ?>
<div class="row with-select">
<div class="span11 offset1">
<div class="span8 offset2">
<input type="checkbox" class="form-control input-kassa"
name="pm_params[method_<?php echo $value; ?>]" value="1"
<?php if ($params['method_'.$value] == '1') {
echo "checked";
} ?> />
<?php echo constant('_JSHOP_YM_METHOD_'.strtoupper($value).'_DESCRIPTION'); ?>
</div>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<div class="row">
<div class="span11 offset1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,25 @@
define('_JSHOP_YM_METHOD_QIWI_DESCRIPTION', 'QIWI Wallet');
define('_JSHOP_YM_METHOD_TINKOFF_BANK_DESCRIPTION', 'Tinkoff online banking');
define('_JSHOP_YM_METHOD_MP_DESCRIPTION', 'Mobile payment kiosk');
define('_JSHOP_YM_METHOD_WIDGET_DESCRIPTION', 'Payment widget from Yandex.Checkout (cards, Apple Pay and Google Play)');
define('_JSHOP_YM_METHOD_INSTALLMENTS_DESCRIPTION', 'Installments');

define('_JSHOP_YM_METHOD_YANDEX_MONEY_DESCRIPTION_PUBLIC', 'Yandex.Money');
define('_JSHOP_YM_METHOD_CARDS_DESCRIPTION_PUBLIC', 'Bank cards');
define('_JSHOP_YM_METHOD_BANK_CARD_DESCRIPTION_PUBLIC', 'Bank cards');
define('_JSHOP_YM_METHOD_CASH_DESCRIPTION_PUBLIC', 'Cash via payment kiosks');
define('_JSHOP_YM_METHOD_MOBILE_BALANCE_DESCRIPTION_PUBLIC', 'Direct carrier billing');
define('_JSHOP_YM_METHOD_WEBMONEY_DESCRIPTION_PUBLIC', 'Webmoney');
define('_JSHOP_YM_METHOD_ALFABANK_DESCRIPTION_PUBLIC', 'Alfa-Click');
define('_JSHOP_YM_METHOD_SBERBANK_DESCRIPTION_PUBLIC', 'Sberbank Online');
define('_JSHOP_YM_METHOD_MA_DESCRIPTION_PUBLIC', 'MasterPass');
define('_JSHOP_YM_METHOD_PB_DESCRIPTION_PUBLIC', 'Promsvyazbank');
define('_JSHOP_YM_METHOD_QIWI_DESCRIPTION_PUBLIC', 'QIWI Wallet');
define('_JSHOP_YM_METHOD_TINKOFF_BANK_DESCRIPTION_PUBLIC', 'Tinkoff online banking');
define('_JSHOP_YM_METHOD_MP_DESCRIPTION_PUBLIC', 'Mobile payment kiosk');
define('_JSHOP_YM_METHOD_WIDGET_DESCRIPTION_PUBLIC', 'Bank cards, Apple Pay, Google Play');
define('_JSHOP_YM_METHOD_INSTALLMENTS_DESCRIPTION_PUBLIC', 'Installments');

define('_JSHOP_YM_METHOD_INSTALLMENTS_AMOUNT', ' (%s ₽ per month)');

define('_JSHOP_YM_KASSA_MPOS_LABEL', 'Success page for the Payment by Card on Delivery method');
Expand All @@ -84,8 +102,8 @@

define('_JSHOP_YM_MONEY_SELECT_HEAD', 'Check the preferable scenario of selecting the payment method');
define('_JSHOP_YM_MONEY_SELECT_LABEL', 'Select payment method');
define('_JSHOP_YM_METHOD_YM2_DESCRIPTION', 'Yandex.Money');
define('_JSHOP_YM_METHOD_CARDS2_DESCRIPTION', 'Bank cards');
define('_JSHOP_YM_METHOD_YM2_DESCRIPTION_PUBLIC', 'Yandex.Money');
define('_JSHOP_YM_METHOD_CARDS2_DESCRIPTION_PUBLIC', 'Bank cards');

define('_JSHOP_YM_COMMON_HEAD', 'Additional settings for administrator');
define('_JSHOP_YM_COMMON_STATUS', 'Order status after the payment');
Expand Down Expand Up @@ -206,3 +224,5 @@

define('_JSHOP_YM_TAB_UPDATE', 'Module update');

define('_JSHOP_YM_BTN_BACK', 'Back');

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
define('_JSHOP_YM_KASSA_SELECT_TEXT', 'Отметьте способы оплаты, которые указаны в вашем договоре с Яндекс.Деньгами');
define('_JSHOP_YM_KASSA_CREDENTIALS_ERROR', 'Проверьте shopId и Секретный ключ — где-то есть ошибка. А лучше скопируйте их прямо из <a href="https://kassa.yandex.ru/my" target="_blank">личного кабинета Яндекс.Кассы</a>');
define('_JSHOP_YM_KASSA_TEST_WARNING', 'Вы включили тестовый режим приема платежей. Проверьте, как проходит оплата, и напишите менеджеру Кассы. Он выдаст рабочие shopId и Секретный ключ. <a href="https://yandex.ru/support/checkout/payments/api.html#api__04" target="_blank">Инструкция</a>');

define('_JSHOP_YM_METHOD_YANDEX_MONEY_DESCRIPTION', 'Яндекс.Деньги');
define('_JSHOP_YM_METHOD_CARDS_DESCRIPTION', 'Банковские карты');
define('_JSHOP_YM_METHOD_BANK_CARD_DESCRIPTION', 'Банковские карты');
Expand All @@ -76,7 +77,26 @@
define('_JSHOP_YM_METHOD_QIWI_DESCRIPTION', 'QIWI Wallet');
define('_JSHOP_YM_METHOD_QP_DESCRIPTION', 'Доверительный платеж (Куппи.ру)');
define('_JSHOP_YM_METHOD_MP_DESCRIPTION', 'Мобильный терминал');
define('_JSHOP_YM_METHOD_WIDGET_DESCRIPTION', 'Платёжный виджет Кассы (карты, Apple Pay и Google Pay)');
define('_JSHOP_YM_METHOD_INSTALLMENTS_DESCRIPTION', 'Заплатить по частям');

define('_JSHOP_YM_METHOD_YANDEX_MONEY_DESCRIPTION_PUBLIC', 'Яндекс.Деньги');
define('_JSHOP_YM_METHOD_CARDS_DESCRIPTION_PUBLIC', 'Банковские карты');
define('_JSHOP_YM_METHOD_BANK_CARD_DESCRIPTION_PUBLIC', 'Банковские карты');
define('_JSHOP_YM_METHOD_CASH_DESCRIPTION_PUBLIC', 'Наличные через терминалы');
define('_JSHOP_YM_METHOD_MOBILE_BALANCE_DESCRIPTION_PUBLIC', 'Баланс мобильного');
define('_JSHOP_YM_METHOD_WEBMONEY_DESCRIPTION_PUBLIC', 'Кошелек WebMoney');
define('_JSHOP_YM_METHOD_ALFABANK_DESCRIPTION_PUBLIC', 'Альфа-Клик');
define('_JSHOP_YM_METHOD_SBERBANK_DESCRIPTION_PUBLIC', 'Сбербанк Онлайн');
define('_JSHOP_YM_METHOD_TINKOFF_BANK_DESCRIPTION_PUBLIC', 'Интернет-банк Тинькофф');
define('_JSHOP_YM_METHOD_MA_DESCRIPTION_PUBLIC', 'MasterPass');
define('_JSHOP_YM_METHOD_PB_DESCRIPTION_PUBLIC', 'Интернет-банк Промсвязьбанка');
define('_JSHOP_YM_METHOD_QIWI_DESCRIPTION_PUBLIC', 'QIWI Wallet');
define('_JSHOP_YM_METHOD_QP_DESCRIPTION_PUBLIC', 'Доверительный платеж (Куппи.ру)');
define('_JSHOP_YM_METHOD_MP_DESCRIPTION_PUBLIC', 'Мобильный терминал');
define('_JSHOP_YM_METHOD_WIDGET_DESCRIPTION_PUBLIC', 'Банковские карты, Apple Pay, Google Pay');
define('_JSHOP_YM_METHOD_INSTALLMENTS_DESCRIPTION_PUBLIC', 'Заплатить по частям');

define('_JSHOP_YM_METHOD_INSTALLMENTS_AMOUNT', ' (%s ₽ в месяц)');
define('_JSHOP_YM_KASSA_MPOS_LABEL', 'Страница успеха для способа «Оплата картой при доставке»');
define('_JSHOP_YM_KASSA_MPOS_HELP', 'Это страница с информацией о доставке. Укажите на ней, когда привезут товар и как его можно будет оплатить');
Expand All @@ -95,6 +115,9 @@
define('_JSHOP_YM_METHOD_YM2_DESCRIPTION', 'Кошелек Яндекс.Деньги');
define('_JSHOP_YM_METHOD_CARDS2_DESCRIPTION', 'Банковская карта');

define('_JSHOP_YM_METHOD_YM2_DESCRIPTION_PUBLIC', 'Кошелек Яндекс.Деньги');
define('_JSHOP_YM_METHOD_CARDS2_DESCRIPTION_PUBLIC', 'Банковская карта');

define('_JSHOP_YM_COMMON_HEAD', 'Дополнительные настройки для администратора');
define('_JSHOP_YM_COMMON_STATUS', 'Статус заказа после оплаты');

Expand Down Expand Up @@ -216,3 +239,4 @@

define('_JSHOP_YM_TAB_UPDATE', 'Обновления');

define('_JSHOP_YM_BTN_BACK', 'Назад');
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
require_once JPATH_ROOT.'/components/com_jshopping/payments/pm_yandex_money_sbbol/SbbolException.php';

if (!defined(_JSHOP_YM_VERSION)) {
define('_JSHOP_YM_VERSION', '1.2.0');
define('_JSHOP_YM_VERSION', '1.3.0');
}


class KassaPaymentMethod
{
const PAYMENT_METHOD_WIDGET = 'widget';

private $module;
private $client;
private $defaultTaxRateId;
Expand Down Expand Up @@ -135,9 +137,15 @@ public function createPayment($order, $cart, $returnUrl)
'type' => $paymentType,
'phone' => preg_replace('/[^\d]+/', '', $params['qiwiPhone']),
);
} elseif ($paymentType === self::PAYMENT_METHOD_WIDGET) {
$confirmation = ConfirmationType::EMBEDDED;
}

if ($paymentType !== self::PAYMENT_METHOD_WIDGET) {
$builder->setPaymentMethodData($paymentType);
}
$builder->setPaymentMethodData($paymentType);
}

$builder->setConfirmation($confirmation);

$receipt = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Client extends BaseClient
/**
* Текущая версия библиотеки
*/
const SDK_VERSION = '1.5.2';
const SDK_VERSION = '1.5.8';

/**
* Получить список платежей магазина.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function call($path, $method, $queryParams, $httpBody = null, $headers =

$url = $this->prepareUrl($path, $queryParams);

$this->prepareCurl($method, $httpBody, $headers, $url);
$this->prepareCurl($method, $httpBody, $this->implodeHeaders($headers), $url);

list($httpHeaders, $httpBody, $responseInfo) = $this->sendRequest();

Expand Down Expand Up @@ -410,14 +410,18 @@ private function prepareHeaders($headers)
throw new AuthorizeException('Authorization headers not set');
}

$headers = array_map(function ($key, $value) {
return $key . ":" . $value;
}, array_keys($headers), $headers);


return $headers;
}

/**
* @param array $headers
* @return array
*/
private function implodeHeaders($headers)
{
return array_map(function ($key, $value) { return $key . ':' . $value; }, array_keys($headers), $headers);
}

/**
* @param $path
* @param $method
Expand All @@ -429,16 +433,21 @@ private function logRequestParams($path, $method, $queryParams, $httpBody, $head
{
if ($this->logger !== null) {
$message = 'Send request: ' . $method . ' ' . $path;
$context = array();
if (!empty($queryParams)) {
$message .= ' with query params: ' . json_encode($queryParams);
$context['_params'] = $queryParams;
}
if (!empty($httpBody)) {
$message .= ' with body: ' . $httpBody;
$data = json_decode($httpBody, true);
if (JSON_ERROR_NONE !== json_last_error()) {
$data = $httpBody;
}
$context['_body'] = $data;
}
if (!empty($headers)) {
$message .= ' with headers: ' . json_encode($headers);
$context['_headers'] = $headers;
}
$this->logger->info($message);
$this->logger->info($message, $context);
}
}

Expand Down Expand Up @@ -467,12 +476,19 @@ private function prepareUrl($path, $queryParams)
private function logResponse($httpBody, $responseInfo, $httpHeaders)
{
if ($this->logger !== null) {
$message = 'Response with code ' . $responseInfo['http_code'] . ' received with headers: '
. json_encode($httpHeaders);
$message = 'Response with code ' . $responseInfo['http_code'] . ' received.';
$context = array();
if (!empty($httpBody)) {
$message .= ' and body: ' . $httpBody;
$data = json_decode($httpBody, true);
if (JSON_ERROR_NONE !== json_last_error()) {
$data = $httpBody;
}
$context['_body'] = $data;
}
if (!empty($httpHeaders)) {
$context['_headers'] = $httpHeaders;
}
$this->logger->info($message);
$this->logger->info($message, $context);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ private function parseSmartLinuxRelease()
foreach ($files as $file) {
if (is_file($file)) {
$lines = array_filter(array_map(array($this, 'callbackSmartLinux'), file($file)));
foreach ($lines as $line) {
$vars[strtoupper($line[0])] = trim($line[1]);
if (is_array($lines)) {
foreach ($lines as $line) {
$vars[strtoupper($line[0])] = trim($line[1]);
}
}
}
}
Expand Down Expand Up @@ -260,7 +262,12 @@ private function parseSimpleLinuxRelease()
foreach ($files as $file) {
if (is_file($file)) {
$data = array_map(array($this, 'callbackSimpleLinux'), file($file));
$vars = array_merge($vars, array_shift($data));
if (!empty($data)) {
$array = array_shift($data);
if (!empty($array) && is_array($array)) {
$vars = array_merge($vars, $array);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,7 @@ public function setCardType($value)
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty cardType value', 0, 'PaymentMethodBankCard.cardType');
} elseif (TypeCast::canCastToString($value)) {
$castedValue = (string)$value;
if (PaymentMethodCardType::valueExists($castedValue)) {
$this->_cardType = $castedValue;
} else {
throw new InvalidPropertyValueException(
'Invalid cardType value', 0, 'PaymentMethodBankCard.cardType', $value
);
}
$this->_cardType = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid cardType value type', 0, 'PaymentMethodBankCard.cardType', $value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

use YandexCheckout\Common\AbstractEnum;

/**
* @deprecated Класс будет удалён в одной из будущих версий.
*/
class PaymentMethodCardType extends AbstractEnum
{
const MASTER_CARD = 'MasterCard';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ public function build(array $options = null)
{
if (!empty($options)) {
$this->setOptions($options);
}

if ($options['type'] === ReceiptType::PAYMENT && !empty($options['payment_id'])) {
$this->setObjectId($options['payment_id']);
}
if ($options['type'] === ReceiptType::REFUND && !empty($options['refund_id'])) {
$this->setObjectId($options['refund_id']);
if ($options['type'] === ReceiptType::PAYMENT && !empty($options['payment_id'])) {
$this->setObjectId($options['payment_id']);
}
if ($options['type'] === ReceiptType::REFUND && !empty($options['refund_id'])) {
$this->setObjectId($options['refund_id']);
}
}

return parent::build($options);
Expand Down
Loading

0 comments on commit 1a318a7

Please sign in to comment.