mirror of
https://github.com/valitydev/rbkmoney-cms-netcat.git
synced 2024-11-06 01:35:18 +00:00
правки
This commit is contained in:
parent
c48b5d1d9c
commit
f0cf235960
13
README.md
13
README.md
@ -1,14 +1,11 @@
|
||||
1. Скачайте и установите NetCat на сервер (https://netcat.ru/democentre).
|
||||
2. Создайте папку rbkmoney в /netcat/modules и переместите туда папку src и следующие файлы: admin.inc.php, admin.php,
|
||||
customers.php, en.lang.php, function.inc.php, index.php, install.php, page_order_waiting.php, page_recurrent.php,
|
||||
page_recurrent_items.php, page_settings.php, page_transactions.php, recurrentCron.php, ru.lang.php, settings.php,
|
||||
settings_table.php, ui_config.php, url_routes.js
|
||||
3. Переместите в папку /netcat/modules/payment/classes/system файл rbkmoney.php
|
||||
4. Зайдите на страницу по адресу http://ваш_сайт/netcat/modules/rbkmoney/install.php
|
||||
5. После установки модуля нужно заполнить необходимые поля для его корректной работы.
|
||||
2. Переместите папку netcat/modules в /netcat/modules с заменой файлов
|
||||
3. Зайдите на страницу по адресу http://ваш_сайт/netcat/modules/rbkmoney/install.php
|
||||
4. После установки модуля нужно заполнить необходимые поля для его корректной работы.
|
||||
Сделать это нужно через админку в настройках модуля (http://ваш_сайт/netcat/admin) Настройки>Управление модулями, знак шестеренки напротив названия модуля
|
||||
После заполнения полей нажмите кнопку сохранить в конце страницы
|
||||
6. Перейдите в настройки модуля Интернет-магазин (Настройки>Интернетмагазин), в меню слева выберите пункт Настройки->Оплата.
|
||||
5. Перейдите в настройки модуля Интернет-магазин (Настройки>Интернетмагазин), в меню слева выберите пункт Настройки->Оплата.
|
||||
Добавьте новый способ оплаты с указанием платежной системы RBKmoney (кнопка "Добавить" внизу страницы).
|
||||
6. Также, для работы модуля необходимо заполнить ставки НДС у товаров в магазине.
|
||||
|
||||
Настройка окончена, теперь при оплате товаров среди способов оплаты будет выводится RBKmoney
|
@ -80,4 +80,6 @@ define('CUSTOMER_UNREADY', 'Unready');
|
||||
define('RECURRENT_SUCCESS', 'Recurrent payment success: ');
|
||||
define('SHADING_CVV', 'Shading card cvv code');
|
||||
define('RECURRENT_PAYMENT', 'Recurrent payment');
|
||||
define('RBKMONEY_RESPONSE_NOT_RECEIVED', 'Response from RBKmoney is not received');
|
||||
define('RBKMONEY_RESPONSE_NOT_RECEIVED', 'Response from RBKmoney is not received');
|
||||
define('REDIRECT_TO_PAYMENT_PAGE', 'Now you will be redirected to the payment page.');
|
||||
define('CLICK_BUTTON_PAY', 'If this does not happen - click on the button "Pay"');
|
@ -1,19 +1,17 @@
|
||||
/netcat/modules/rbkmoney/admin.inc.php
|
||||
/netcat/modules/rbkmoney/admin.php
|
||||
/netcat/modules/rbkmoney/customers.php
|
||||
/netcat/modules/rbkmoney/en.lang.php
|
||||
/netcat/modules/rbkmoney/function.inc.php
|
||||
/netcat/modules/rbkmoney/index.php
|
||||
/netcat/modules/rbkmoney/page_order_waiting.php
|
||||
/netcat/modules/rbkmoney/page_recurrent.php
|
||||
/netcat/modules/rbkmoney/page_recurrent_items.php
|
||||
/netcat/modules/rbkmoney/page_settings.php
|
||||
/netcat/modules/rbkmoney/page_transactions.php
|
||||
/netcat/modules/rbkmoney/recurrentCron.php
|
||||
/netcat/modules/rbkmoney/ru.lang.php
|
||||
/netcat/modules/rbkmoney/settings.php
|
||||
/netcat/modules/rbkmoney/ru.lang.php
|
||||
/netcat/modules/rbkmoney/en.lang.php
|
||||
/netcat/modules/rbkmoney/ui_config.php
|
||||
/netcat/modules/rbkmoney/url_routes.js
|
||||
/netcat/modules/rbkmoney/url_routes.js.php
|
||||
/netcat/modules/payment/classes/system/rbkmoney.php
|
||||
/netcat/modules/rbkmoney/src/Api/ContactInfo.php
|
||||
/netcat/modules/rbkmoney/src/Api/Customers/CreateCustomer/Request/CreateCustomerRequest.php
|
||||
|
9
id.txt
9
id.txt
@ -1,11 +1,8 @@
|
||||
rbkmoney
|
||||
|
||||
6
|
||||
|
||||
5.8
|
||||
0
|
||||
RBK_MONEY
|
||||
|
||||
|
||||
RBKMoney
|
||||
|
||||
|
||||
RBKMoney_DESCRIPTION
|
||||
RBK_MONEY
|
37
install.php
37
install.php
@ -4,30 +4,30 @@ $modulePath = $_SERVER['DOCUMENT_ROOT'] . '/rbkmoney/';
|
||||
|
||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/vars.inc.php');
|
||||
include_once($ROOT_FOLDER . 'connect_io.php');
|
||||
include_once($modulePath . "$lang.lang.php");
|
||||
include_once(__DIR__ . "/$lang.lang.php");
|
||||
|
||||
$db = $nc_core->db;
|
||||
InstallThisModule();
|
||||
|
||||
InstallThisModule($db);
|
||||
|
||||
function InstallThisModule($db)
|
||||
function CheckAbilityOfInstallation()
|
||||
{
|
||||
$db->query("INSERT INTO `Module` (`Module_Name`, `Keyword`, `Description`,
|
||||
`Parameters`, `Example_URL`, `Help_URL`, `Installed`, `Number`, `Inside_Admin`, `Checked`)
|
||||
VALUES ('RBK_MONEY', 'rbkmoney', 'RBK_MONEY', 'ADMIN_SETTINGS_LOCATION=module.rbkmoney.settings', '', '', 1, '', 1, 1)"
|
||||
);
|
||||
return array('Success'=>1);
|
||||
}
|
||||
|
||||
$db->query("INSERT INTO `Classificator_PaymentSystem` (`PaymentSystem_Name`, `PaymentSystem_Priority`, `Value`, `Checked`)
|
||||
function InstallThisModule()
|
||||
{
|
||||
global $nc_core;
|
||||
|
||||
$nc_core->db->query("INSERT INTO `Classificator_PaymentSystem` (`PaymentSystem_Name`, `PaymentSystem_Priority`, `Value`, `Checked`)
|
||||
VALUES ('RBKmoney', '1', 'nc_payment_system_rbkmoney', '1')"
|
||||
);
|
||||
|
||||
$db->query("CREATE TABLE `RBKmoney_Recurrent_Items` (
|
||||
$nc_core->db->query("CREATE TABLE `RBKmoney_Recurrent_Items` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`article` VARCHAR (20) NOT NULL,
|
||||
PRIMARY KEY (`id`))"
|
||||
);
|
||||
|
||||
$db->query("CREATE TABLE `RBKmoney_Recurrent` (
|
||||
$nc_core->db->query("CREATE TABLE `RBKmoney_Recurrent` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`recurrent_customer_id` INT(10) UNSIGNED NOT NULL,
|
||||
`amount` INT(11) NOT NULL,
|
||||
@ -40,7 +40,7 @@ function InstallThisModule($db)
|
||||
KEY `recurrent_customer` (`recurrent_customer_id`))"
|
||||
);
|
||||
|
||||
$db->query("CREATE TABLE `RBKmoney_Recurrent_Customers` (
|
||||
$nc_core->db->query("CREATE TABLE `RBKmoney_Recurrent_Customers` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`customer_id` VARCHAR(20) NOT NULL,
|
||||
@ -50,7 +50,7 @@ function InstallThisModule($db)
|
||||
UNIQUE KEY `customer_id` (`customer_id`))"
|
||||
);
|
||||
|
||||
$db->query("CREATE TABLE `RBKmoney_Invoice` (
|
||||
$nc_core->db->query("CREATE TABLE `RBKmoney_Invoice` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`invoice_id` VARCHAR(100) NOT NULL,
|
||||
`payload` TEXT NOT NULL,
|
||||
@ -59,20 +59,19 @@ function InstallThisModule($db)
|
||||
PRIMARY KEY (`id`))"
|
||||
);
|
||||
|
||||
$db->query("INSERT INTO `CronTasks`
|
||||
$nc_core->db->query("INSERT INTO `CronTasks`
|
||||
(`Cron_Minutes`, `Cron_Hours`, `Cron_Days`, `Cron_Months`, `Cron_Weekdays`, `Cron_Script_URL`)
|
||||
VALUES
|
||||
(0, 0, 0, 0, 0, '/netcat/modules/rbkmoney/recurrentCron.php')"
|
||||
);
|
||||
|
||||
$db->query("INSERT INTO `Settings`
|
||||
$nc_core->db->query("INSERT INTO `Settings`
|
||||
(`Key`, `Value`, `Module`)
|
||||
VALUES
|
||||
('apiKey', '', 'rbkmoney'),
|
||||
('shopId', '', 'rbkmoney'),
|
||||
('successUrl', 'http://example.ru', 'rbkmoney')"
|
||||
);
|
||||
$result["Success"] = 1;
|
||||
}
|
||||
|
||||
echo INSTALLATION_SUCCESS;
|
||||
$result["Success"] = 1;
|
||||
}
|
@ -20,6 +20,7 @@ use src\Api\Webhooks\InvoicesTopicScope;
|
||||
use src\Api\Webhooks\WebhookResponse\WebhookResponse;
|
||||
use src\Client\Client;
|
||||
use src\Client\Sender;
|
||||
use src\Exceptions\RBKMoneyException;
|
||||
use src\Exceptions\RequestException;
|
||||
|
||||
class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
@ -39,6 +40,17 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
*/
|
||||
private $nc_core;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $vat_map = [
|
||||
0 => '0%',
|
||||
10 => '10%',
|
||||
18 => '18%',
|
||||
10110 => '10/110',
|
||||
18118 => '18/118',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->nc_core = nc_Core::get_object();
|
||||
@ -76,70 +88,94 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
$this->add_error(ERROR_HOLD_STATUS_IS_NOT_VALID);
|
||||
}
|
||||
}
|
||||
|
||||
$errors = $this->get_errors();
|
||||
if (!empty($errors)) {
|
||||
$this->add_error('<a href="/">На главную</a>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nc_payment_invoice|null $invoice
|
||||
*
|
||||
* @throws nc_record_exception
|
||||
* @param nc_payment_invoice | null $invoice
|
||||
*/
|
||||
public function on_response(nc_payment_invoice $invoice = null)
|
||||
{
|
||||
$message = file_get_contents('php://input');
|
||||
$callback = json_decode($message);
|
||||
$invoice = new nc_payment_invoice();
|
||||
//
|
||||
}
|
||||
|
||||
if (!isset($callback->invoice->metadata->orderId)) {
|
||||
$invoice->load($callback->invoice->metadata->orderId);
|
||||
/**
|
||||
* @param $vat_rate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVatRate($vat_rate)
|
||||
{
|
||||
if (isset($this->vat_map[$vat_rate])) {
|
||||
return $this->vat_map[$vat_rate];
|
||||
}
|
||||
|
||||
$invoiceStatus = $invoice->get('status');
|
||||
|
||||
if(!empty($invoiceStatus) && $invoice::STATUS_SUCCESS === $invoiceStatus){
|
||||
$this->on_payment_success($invoice);
|
||||
} elseif (!empty($invoiceStatus) && $invoice::STATUS_SUCCESS !== $invoiceStatus) {
|
||||
include dirname(__DIR__) . '/../../rbkmoney/page_order_waiting.php';
|
||||
} else {
|
||||
$this->on_payment_failure($invoice);
|
||||
}
|
||||
return $vat_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nc_payment_invoice | null $invoice
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws RequestException
|
||||
* @throws WrongDataException
|
||||
* @throws WrongRequestException
|
||||
* @throws nc_record_exception
|
||||
*/
|
||||
public function validate_payment_callback_response(nc_payment_invoice $invoice = null)
|
||||
{
|
||||
$signature = $this->getSignatureFromHeader(getenv('HTTP_CONTENT_SIGNATURE'));
|
||||
try {
|
||||
$signature = $this->getSignatureFromHeader(getenv('HTTP_CONTENT_SIGNATURE'));
|
||||
|
||||
if (empty($signature)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `Content-Signature`');
|
||||
if (empty($signature)) {
|
||||
throw new WrongDataException(WRONG_SIGNATURE, 403);
|
||||
}
|
||||
|
||||
$signDecode = base64_decode(strtr($signature, '-_,', '+/='));
|
||||
|
||||
$message = file_get_contents('php://input');
|
||||
|
||||
if (empty($message)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `callback`', 400);
|
||||
}
|
||||
|
||||
if (!$this->verificationSignature($message, $signDecode)) {
|
||||
throw new WrongDataException(WRONG_SIGNATURE, 403);
|
||||
}
|
||||
|
||||
$callback = json_decode($message);
|
||||
|
||||
if (isset($callback->invoice)) {
|
||||
$this->paymentCallback($callback);
|
||||
} elseif (isset($callback->customer)) {
|
||||
$this->customerCallback($callback->customer);
|
||||
}
|
||||
} catch (RBKMoneyException $exception) {
|
||||
$this->callbackError($exception);
|
||||
}
|
||||
}
|
||||
|
||||
$signDecode = base64_decode(strtr($signature, '-_,', '+/='));
|
||||
|
||||
$message = file_get_contents('php://input');
|
||||
|
||||
if (empty($message)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `callback`');
|
||||
/**
|
||||
* @param RBKmoneyException $exception
|
||||
* @param nc_payment_invoice | null $invoice
|
||||
*/
|
||||
private function callbackError(RBKMoneyException $exception, nc_payment_invoice $invoice = null) {
|
||||
if (!empty($invoice)) {
|
||||
$this->on_payment_failure($invoice);
|
||||
}
|
||||
$this->printCallbackResponse($exception);
|
||||
|
||||
if (!$this->verificationSignature($message, $signDecode)) {
|
||||
throw new WrongDataException(WRONG_SIGNATURE);
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
$callback = json_decode($message);
|
||||
/**
|
||||
* @param RBKmoneyException $exception
|
||||
*/
|
||||
private function printCallbackResponse(RBKmoneyException $exception) {
|
||||
header('Content-Type: application/json', true, $exception->getCode());
|
||||
|
||||
if (isset($callback->invoice)) {
|
||||
$this->paymentCallback($callback);
|
||||
} elseif (isset($callback->customer)) {
|
||||
$this->customerCallback($callback->customer);
|
||||
}
|
||||
echo json_encode(['message' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +263,7 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
$invoiceStatus = $invoice::STATUS_WAITING;
|
||||
$netshopStatus = NETSHOP_STATUS_WAITING;
|
||||
} else {
|
||||
throw new WrongDataException(ERROR_HOLD_STATUS_IS_NOT_VALID);
|
||||
throw new WrongDataException(ERROR_HOLD_STATUS_IS_NOT_VALID, 400);
|
||||
}
|
||||
|
||||
if (in_array($type, [
|
||||
@ -262,16 +298,6 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
return number_format($price, 2, '', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tax
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTaxSlash($tax)
|
||||
{
|
||||
return substr_replace($tax, '/', 2, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @param string $signature
|
||||
@ -305,7 +331,7 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
$signature = preg_replace("/alg=(\S+);\sdigest=/", '', $contentSignature);
|
||||
|
||||
if (empty($signature)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `Content-Signature`');
|
||||
throw new WrongDataException(WRONG_SIGNATURE, 403);
|
||||
}
|
||||
|
||||
return $signature;
|
||||
@ -361,18 +387,17 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
$sourceItemId = $item->get('source_item_id');
|
||||
|
||||
if (empty($sourceItemId)) {
|
||||
$tax = DELIVERY_VAT_SETTING;
|
||||
$vat = DELIVERY_VAT_SETTING;
|
||||
} else {
|
||||
$tax = $item->get('vat_rate');
|
||||
$vat = $item->get('vat_rate');
|
||||
}
|
||||
$taxSlash = $this->getTaxSlash($tax);
|
||||
$vatRate = $this->getVatRate($vat);
|
||||
|
||||
if (in_array($taxSlash, TaxMode::$validValues)) {
|
||||
$taxMode = new TaxMode($taxSlash);
|
||||
} elseif (in_array("$tax%", TaxMode::$validValues)) {
|
||||
$taxMode = new TaxMode("$tax%");
|
||||
if (in_array($vatRate, TaxMode::$validValues)) {
|
||||
$taxMode = new TaxMode($vatRate);
|
||||
} else {
|
||||
throw new WrongDataException(ERROR_TAX_RATE_IS_NOT_VALID . $itemName);
|
||||
$this->add_error('<a href="/">На главную</a>');
|
||||
throw new WrongDataException(ERROR_TAX_RATE_IS_NOT_VALID . $itemName, 400);
|
||||
}
|
||||
|
||||
$carts[] = new Cart(
|
||||
@ -430,13 +455,19 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
/**
|
||||
* @param nc_payment_invoice $invoice
|
||||
*
|
||||
* @return array | null
|
||||
* @return array
|
||||
*/
|
||||
private function getInvoice(nc_payment_invoice $invoice)
|
||||
{
|
||||
return $this->nc_core->db->get_results("SELECT *
|
||||
$result = $this->nc_core->db->get_results("SELECT *
|
||||
FROM `RBKmoney_Invoice`
|
||||
WHERE `order_id` = '{$invoice->get_id()}'");
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -516,28 +547,36 @@ class nc_payment_system_rbkmoney extends nc_payment_system
|
||||
$holdExpiration = 'data-hold-expiration="' . $this->getHoldType()->getValue() . '"';
|
||||
}
|
||||
|
||||
$requireCardHolder = (NOT_SHOW_PARAMETER === $this->get_setting('cardHolder'));
|
||||
$shadingCvv = (NOT_SHOW_PARAMETER === $this->get_setting('shadingCvv'));
|
||||
// При echo true заменяется на 1, а checkout воспринимает только true
|
||||
$holdType = $holdType ? 'true' : 'false';
|
||||
$requireCardHolder = (SHOW_PARAMETER === $this->get_setting('cardHolder')) ? 'true' : 'false';
|
||||
$shadingCvv = (SHOW_PARAMETER === $this->get_setting('shadingCvv')) ? 'true' : 'false';
|
||||
$customerEmail = $invoice->get('customer_email');
|
||||
|
||||
$form = '<form action="' . $this->get_setting('successUrl') . '" name="pay_form" method="GET">
|
||||
<input type="hidden" name="orderId" value="' . $orderId . '">
|
||||
<input type="hidden" name="paySystem" value="' . get_class($this) . '">
|
||||
<script src="' . RBK_MONEY_CHECKOUT_URL_SETTING . '" class="rbkmoney-checkout"
|
||||
data-payment-flow-hold="' . $holdType . '"
|
||||
data-obscure-card-cvv="' . $shadingCvv . '"
|
||||
data-require-cardholder="'.$requireCardHolder.'"
|
||||
' . $holdExpiration . '
|
||||
data-name="' . $product . '"
|
||||
data-description="' . $product . '"
|
||||
'.$out .'
|
||||
data-label="' . PAY . '">
|
||||
</script>
|
||||
</form>
|
||||
<script>window.onload = function() {
|
||||
document.getElementById("rbkmoney-button").style.display = "none";
|
||||
document.getElementById("rbkmoney-button").click();
|
||||
};
|
||||
</script>';
|
||||
$form = '
|
||||
<div align="center" style="margin-top: 20%">
|
||||
'.REDIRECT_TO_PAYMENT_PAGE.'<br>
|
||||
'.CLICK_BUTTON_PAY.'
|
||||
<form action="' . $this->get_setting('successUrl') . '" name="pay_form" method="GET">
|
||||
<input type="hidden" name="orderId" value="' . $orderId . '">
|
||||
<input type="hidden" name="paySystem" value="' . get_class($this) . '">
|
||||
<script src="' . RBK_MONEY_CHECKOUT_URL_SETTING . '" class="rbkmoney-checkout"
|
||||
data-payment-flow-hold="' . $holdType . '"
|
||||
data-obscure-card-cvv="' . $shadingCvv . '"
|
||||
data-require-card-holder="'.$requireCardHolder.'"
|
||||
' . $holdExpiration . '
|
||||
data-name="' . $product . '"
|
||||
data-email="' . $customerEmail . '"
|
||||
data-description="' . $product . '"
|
||||
'.$out .'
|
||||
data-label="' . PAY . '">
|
||||
</script>
|
||||
</form>
|
||||
<script>window.onload = function() {
|
||||
document.getElementById("rbkmoney-button").click();
|
||||
};
|
||||
</script>
|
||||
</div>';
|
||||
|
||||
echo $form;
|
||||
}
|
@ -227,13 +227,14 @@ class RbkMoneyAdmin
|
||||
{
|
||||
try {
|
||||
if (!$this->settings['apiKey']) {
|
||||
throw new WrongDataException(ERROR_API_KEY_IS_NOT_VALID);
|
||||
throw new WrongDataException(ERROR_API_KEY_IS_NOT_VALID, 400);
|
||||
}
|
||||
if (!$this->settings['shopId']) {
|
||||
throw new WrongDataException(ERROR_SHOP_ID_IS_NOT_VALID);
|
||||
throw new WrongDataException(ERROR_SHOP_ID_IS_NOT_VALID, 400);
|
||||
}
|
||||
} catch (WrongDataException $exception) {
|
||||
echo $exception->getMessage();
|
||||
die;
|
||||
}
|
||||
if ($fromTime->getTimestamp() > $toTime->getTimestamp()) {
|
||||
$fromTime = new DateTime('today');
|
85
netcat/modules/rbkmoney/en.lang.php
Normal file
85
netcat/modules/rbkmoney/en.lang.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
define('TRANSACTIONS', 'Transactions');
|
||||
define('SAVE', 'Save');
|
||||
define('NEXT', 'Next');
|
||||
define('PAY', 'Pay');
|
||||
define('PREVIOUS', 'Previous');
|
||||
define('WRONG_VALUE', 'Wrong value');
|
||||
define('WRONG_SIGNATURE', 'Wrong signature');
|
||||
define('INSTALLATION_SUCCESS', 'Module installation was successful');
|
||||
define('SETTINGS', 'Settings');
|
||||
define('RECURRENT', 'Recurrent payments');
|
||||
define('RECURRENT_ITEMS', 'Items for recurrent payments');
|
||||
define('API_KEY', 'API key');
|
||||
define('ITEM_IDS', 'Articles of products for recurrent payments');
|
||||
define('SHOP_ID', 'Shop ID');
|
||||
define('SUCCESS_URL', 'Successful payment page');
|
||||
define('PAYMENT_TYPE', 'Payment type');
|
||||
define('SHOW_PARAMETER', 'Yes');
|
||||
define('NOT_SHOW_PARAMETER', 'No');
|
||||
define('CARD_HOLDER', 'Show cardholder on payment form');
|
||||
define('HOLD_EXPIRATION', 'Write-off at the end of the holding period');
|
||||
define('HOLD_STATUS', 'Order status with hold');
|
||||
define('PROCESSED', 'Processed');
|
||||
define('PAID', 'Paid');
|
||||
define('RBK_MONEY', 'RBKmoney');
|
||||
define('ERROR_SHOP_ID_IS_NOT_VALID', 'Invalid value of the `shopID` parameter');
|
||||
define('ERROR_API_KEY_IS_NOT_VALID', 'Invalid value of the `apiKey` parameter');
|
||||
define('ERROR_HOLD_STATUS_IS_NOT_VALID', 'Invalid value of the `holdStatus` parameter');
|
||||
define('ERROR_SUCCESS_URL_IS_NOT_VALID', 'Invalid value of the `successUrl` parameter');
|
||||
define('ERROR_PAYMENT_TYPE_IS_NOT_VALID', 'Invalid value of the `paymentType` parameter');
|
||||
define('ERROR_HOLD_EXPIRATION_IS_NOT_VALID', 'Invalid value of the `holdExpiration` parameter');
|
||||
define('ERROR_TAX_RATE_IS_NOT_VALID', 'Invalid value `VAT rate` for product: ');
|
||||
define('PAYMENT_TYPE_HOLD', 'Hold');
|
||||
define('PAYMENT_TYPE_INSTANTLY', 'Write-off instantly');
|
||||
define('EXPIRATION_PAYER', 'Payer');
|
||||
define('EXPIRATION_SHOP', 'Shop');
|
||||
define('RECURRENT_DELETED', 'Recurrent payment deleted');
|
||||
define('RBK_MONEY_DATE_FILTER', 'Date');
|
||||
define('RBK_MONEY_DATE_FILTER_FROM', 'from');
|
||||
define('RBK_MONEY_DATE_FILTER_TO', 'to');
|
||||
define('RBK_MONEY_FILTER_SUBMIT', 'Search');
|
||||
define('RBK_MONEY_TRANSACTION_ID', 'ID');
|
||||
define('RBK_MONEY_TRANSACTION_PRODUCT', 'Product');
|
||||
define('RBK_MONEY_TRANSACTION_STATUS', 'Status');
|
||||
define('RBK_MONEY_TRANSACTION_AMOUNT', 'Amount');
|
||||
define('RBK_MONEY_TRANSACTION_CREATED_AT', 'Created at');
|
||||
define('PAYMENT_CONFIRMED', 'Payment confirmed');
|
||||
define('PAYMENT_CANCELLED', 'Payment cancelled');
|
||||
define('REFUND_CREATED', 'Payment refund created');
|
||||
define('PAYMENT_CAPTURE_ERROR', 'Payment confirmation error');
|
||||
define('PAYMENT_CANCELLED_ERROR', 'Payment cancelled error');
|
||||
define('REFUND_CREATE_ERROR', 'Refund create error');
|
||||
define('USER_FIELD', 'User');
|
||||
define('AMOUNT_FIELD', 'Amount');
|
||||
define('PRODUCT_FIELD', 'Product');
|
||||
define('USER_STATUS', 'User status');
|
||||
define('FORM_BUTTON_DELETE', 'Delete');
|
||||
define('FISCALIZATION', 'Fiscalization (54 Federal Law)');
|
||||
define('FISCALIZATION_USE', 'Use');
|
||||
define('FISCALIZATION_NOT_USE', "Don't use");
|
||||
define('ORDER_PAYMENT', 'Order payment');
|
||||
define('ORDER_PENDING', 'Your order is pending payment. Go to the');
|
||||
define('WEBSITE', 'website');
|
||||
define('STATUS_STARTED', 'started');
|
||||
define('STATUS_PROCESSED', 'processed');
|
||||
define('STATUS_CAPTURED', 'captured');
|
||||
define('STATUS_CANCELLED', 'cancelled');
|
||||
define('STATUS_CHARGED_BACK', 'charged back');
|
||||
define('STATUS_REFUNDED', 'refunded');
|
||||
define('STATUS_FAILED', 'failed');
|
||||
define('REFUNDED_BY_ADMIN', 'Refunded by admin');
|
||||
define('CANCELLED_BY_ADMIN', 'Cancelled by admin');
|
||||
define('CAPTURED_BY_ADMIN', 'Captured by admin');
|
||||
define('SETTINGS_SAVED', 'Settings saved');
|
||||
define('CONFIRM_PAYMENT', 'Confirm payment');
|
||||
define('CANCEL_PAYMENT', 'Cancel payment');
|
||||
define('CREATE_PAYMENT_REFUND', 'Create payment refund');
|
||||
define('CUSTOMER_READY', 'Ready');
|
||||
define('CUSTOMER_UNREADY', 'Unready');
|
||||
define('RECURRENT_SUCCESS', 'Recurrent payment success: ');
|
||||
define('SHADING_CVV', 'Shading card cvv code');
|
||||
define('RECURRENT_PAYMENT', 'Recurrent payment');
|
||||
define('RBKMONEY_RESPONSE_NOT_RECEIVED', 'Response from RBKmoney is not received');
|
||||
define('REDIRECT_TO_PAYMENT_PAGE', 'Now you will be redirected to the payment page.');
|
||||
define('CLICK_BUTTON_PAY', 'If this does not happen - click on the button "Pay"');
|
@ -199,7 +199,7 @@ class Recurrent
|
||||
} elseif (in_array("$tax%", TaxMode::$validValues)) {
|
||||
$taxMode = new TaxMode("$tax%");
|
||||
} else {
|
||||
throw new WrongDataException(ERROR_TAX_RATE_IS_NOT_VALID . $payment->name);
|
||||
throw new WrongDataException(ERROR_TAX_RATE_IS_NOT_VALID . $payment->name, 400);
|
||||
}
|
||||
|
||||
$createInvoice->addCart(new Cart(
|
85
netcat/modules/rbkmoney/ru.lang.php
Normal file
85
netcat/modules/rbkmoney/ru.lang.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
define('TRANSACTIONS', 'Транзакции');
|
||||
define('SAVE', 'Сохранить');
|
||||
define('NEXT', 'Следующая');
|
||||
define('PAY', 'Оплатить');
|
||||
define('PREVIOUS', 'Предыдущая');
|
||||
define('WRONG_VALUE', 'Недопустимое значение');
|
||||
define('WRONG_SIGNATURE', 'Недопустимая сигнатура');
|
||||
define('INSTALLATION_SUCCESS', 'Установка модуля прошла успешно');
|
||||
define('SETTINGS', 'Настройки');
|
||||
define('RECURRENT', 'Регулярные платежи');
|
||||
define('RECURRENT_ITEMS', 'Товары для регулярных платежей');
|
||||
define('API_KEY', 'API ключ');
|
||||
define('ITEM_IDS', 'Артикулы товаров для рекуррентов по 1 в каждой строке');
|
||||
define('SHOP_ID', 'ID магазина');
|
||||
define('SUCCESS_URL', 'Страница успешной оплаты');
|
||||
define('PAYMENT_TYPE', 'Тип списания средств');
|
||||
define('SHOW_PARAMETER', 'Да');
|
||||
define('NOT_SHOW_PARAMETER', 'Нет');
|
||||
define('CARD_HOLDER', 'Отображение кардхолдера в форме оплаты');
|
||||
define('HOLD_EXPIRATION', 'Списание средств по окончанию срока холдирования');
|
||||
define('HOLD_STATUS', 'Статус инвойса при холде');
|
||||
define('PROCESSED', 'Принят');
|
||||
define('PAID', 'Оплачен');
|
||||
define('RBK_MONEY', 'RBKmoney');
|
||||
define('ERROR_SHOP_ID_IS_NOT_VALID', 'Некорректный параметр `shopID`');
|
||||
define('ERROR_API_KEY_IS_NOT_VALID', 'Некорректное значение API кюча');
|
||||
define('ERROR_SUCCESS_URL_IS_NOT_VALID', 'Некорректное значение страницы успешной оплаты');
|
||||
define('ERROR_PAYMENT_TYPE_IS_NOT_VALID', 'Некорректное значение типа оплаты');
|
||||
define('ERROR_HOLD_STATUS_IS_NOT_VALID', 'Некорректное значение статуса инвойса при холде');
|
||||
define('ERROR_HOLD_EXPIRATION_IS_NOT_VALID', 'Некорректное значение стороны списания средств по окончанию срока холдированния');
|
||||
define('ERROR_TAX_RATE_IS_NOT_VALID', 'Неверно указан НДС в товаре: ');
|
||||
define('PAYMENT_TYPE_HOLD', 'Холд');
|
||||
define('PAYMENT_TYPE_INSTANTLY', 'Мгновенное списание');
|
||||
define('EXPIRATION_PAYER', 'В пользу плательщика');
|
||||
define('EXPIRATION_SHOP', 'В пользу магазина');
|
||||
define('RECURRENT_DELETED', 'Привязка успешно удалена');
|
||||
define('RBK_MONEY_DATE_FILTER', 'Дата');
|
||||
define('RBK_MONEY_DATE_FILTER_FROM', 'с');
|
||||
define('RBK_MONEY_DATE_FILTER_TO', 'по');
|
||||
define('RBK_MONEY_FILTER_SUBMIT', 'Искать');
|
||||
define('RBK_MONEY_TRANSACTION_ID', 'ID');
|
||||
define('RBK_MONEY_TRANSACTION_PRODUCT', 'Продукт');
|
||||
define('RBK_MONEY_TRANSACTION_STATUS', 'Статус');
|
||||
define('RBK_MONEY_TRANSACTION_AMOUNT', 'Стоимость');
|
||||
define('RBK_MONEY_TRANSACTION_CREATED_AT', 'Время создания');
|
||||
define('PAYMENT_CONFIRMED', 'Платеж успешно подтвержден');
|
||||
define('PAYMENT_CANCELLED', 'Платеж успешно отменен');
|
||||
define('REFUND_CREATED', 'Возврат платежа успешно создан');
|
||||
define('PAYMENT_CAPTURE_ERROR', 'Ошибка подтверждения платежа');
|
||||
define('PAYMENT_CANCELLED_ERROR', 'Ошибка отмены платежа');
|
||||
define('REFUND_CREATE_ERROR', 'Ошибка создания возврата платежа');
|
||||
define('USER_FIELD', 'Пользователь');
|
||||
define('AMOUNT_FIELD', 'Сумма');
|
||||
define('PRODUCT_FIELD', 'Товар');
|
||||
define('USER_STATUS', 'Статус пользователя');
|
||||
define('FORM_BUTTON_DELETE', 'Удалить');
|
||||
define('FISCALIZATION', 'Фискализация по 54-ФЗ');
|
||||
define('FISCALIZATION_USE', 'Использовать');
|
||||
define('FISCALIZATION_NOT_USE', 'Не использовать');
|
||||
define('ORDER_PAYMENT', 'Оплата заказа');
|
||||
define('ORDER_PENDING', 'Ваш заказ ожидает оплаты. Перейти на');
|
||||
define('WEBSITE', 'сайт');
|
||||
define('STATUS_STARTED', 'Запущен');
|
||||
define('STATUS_PROCESSED', 'Обработан');
|
||||
define('STATUS_CAPTURED', 'Подтвержден');
|
||||
define('STATUS_CANCELLED', 'Отменен');
|
||||
define('STATUS_CHARGED_BACK', 'Совершен чарджбек');
|
||||
define('STATUS_REFUNDED', 'Возвращен');
|
||||
define('STATUS_FAILED', 'Неуспешен');
|
||||
define('REFUNDED_BY_ADMIN', 'Сделан возврат администратором');
|
||||
define('CANCELLED_BY_ADMIN', 'Отменено администратором');
|
||||
define('CAPTURED_BY_ADMIN', 'Подтверждено администратором');
|
||||
define('SETTINGS_SAVED', 'Настройки успешно сохранены');
|
||||
define('CONFIRM_PAYMENT', 'Подтвердить платеж');
|
||||
define('CANCEL_PAYMENT', 'Отменить платеж');
|
||||
define('CREATE_PAYMENT_REFUND', 'Создать возврат платежа');
|
||||
define('CUSTOMER_READY', 'Готов');
|
||||
define('CUSTOMER_UNREADY', 'Не готов');
|
||||
define('RECURRENT_SUCCESS', 'Платеж успешно проведен: ');
|
||||
define('SHADING_CVV', 'Затенять карточный cvv код');
|
||||
define('RECURRENT_PAYMENT', 'Рекуррентный платеж');
|
||||
define('RBKMONEY_RESPONSE_NOT_RECEIVED', 'Ответ от RBKmoney не получен');
|
||||
define('REDIRECT_TO_PAYMENT_PAGE', 'Сейчас вы будете перенаправлены на страницу оплаты.');
|
||||
define('CLICK_BUTTON_PAY', 'Если это не произошло - нажмите на кнопку "Оплатить"');
|
@ -43,7 +43,7 @@ class ContactInfo extends RBKMoneyDataObject
|
||||
public function setPhone($phoneNumber)
|
||||
{
|
||||
if (!preg_match('/^\+\d{4,15}$/', $phoneNumber)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `phoneNumber`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `phoneNumber`', 400);
|
||||
}
|
||||
|
||||
$this->phoneNumber = $phoneNumber;
|
@ -34,7 +34,7 @@ class Status
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -70,7 +70,7 @@ class TaxMode
|
||||
public function __construct($rate)
|
||||
{
|
||||
if (!in_array($rate, self::$validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `rate`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `rate`', 400);
|
||||
}
|
||||
|
||||
$this->rate = $rate;
|
@ -38,7 +38,7 @@ class Status
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -34,7 +34,7 @@ class HoldType
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `onHoldExpiration`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `onHoldExpiration`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -34,7 +34,7 @@ class PayerType
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `payerType`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `payerType`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -54,7 +54,7 @@ class PaymentSystem
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `paymentSystem`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `paymentSystem`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -36,7 +36,7 @@ class Status
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
39
netcat/modules/rbkmoney/src/Api/RBKMoneyDataObject.php
Normal file
39
netcat/modules/rbkmoney/src/Api/RBKMoneyDataObject.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace src\Api;
|
||||
|
||||
abstract class RBKMoneyDataObject
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name) {
|
||||
return property_exists(get_called_class(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name) {
|
||||
if ($this->__isset($name)) {
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Метод объявлен только для того, чтоб
|
||||
* запретить динамически создавать поля объекта
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($name, $value) {
|
||||
// Реализация не предполагается
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ class PaymentMethod
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `paymentMethod`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `paymentMethod`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -271,7 +271,7 @@ class SearchPaymentsRequest extends RBKMoneyDataObject implements GetRequestInte
|
||||
public function setCardNumberMask($cardNumberMask)
|
||||
{
|
||||
if (!preg_match('/^\d{2,4}$/', $cardNumberMask)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cardNumberMask`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cardNumberMask`', 400);
|
||||
}
|
||||
|
||||
$this->cardNumberMask = $cardNumberMask;
|
@ -46,7 +46,7 @@ class Status
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `status`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -45,13 +45,13 @@ class CardData extends PaymentTool
|
||||
public function __construct($cardNumber, $expDate, $cvv)
|
||||
{
|
||||
if (!preg_match('/^\d{12,19}$/', $cardNumber)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cardNumber`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cardNumber`', 400);
|
||||
}
|
||||
if (!preg_match('/^\d{2}\/(\d{2}|\d{4})$/', $expDate)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `expDate`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `expDate`', 400);
|
||||
}
|
||||
if (!preg_match('/^\d{3,4}$/', $cvv)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cvv`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `cvv`', 400);
|
||||
}
|
||||
|
||||
$this->cardNumber = $cardNumber;
|
@ -32,7 +32,7 @@ class TerminalProvider
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!in_array($value, $this->validValues)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `terminalProvider`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `terminalProvider`', 400);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
@ -68,7 +68,7 @@ class CustomersTopicScope extends WebhookScope
|
||||
$diff = array_diff($eventTypes, $this->validTypes);
|
||||
|
||||
if (!empty($diff)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `eventTypes`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `eventTypes`', 400);
|
||||
}
|
||||
|
||||
$this->eventTypes = $eventTypes;
|
@ -92,7 +92,7 @@ class InvoicesTopicScope extends WebhookScope
|
||||
$diff = array_diff($eventTypes, $this->validTypes);
|
||||
|
||||
if (!empty($diff)) {
|
||||
throw new WrongDataException(WRONG_VALUE . ' `eventTypes`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `eventTypes`', 400);
|
||||
}
|
||||
|
||||
$this->eventTypes = $eventTypes;
|
@ -90,7 +90,7 @@ class WebhookResponse extends RBKMoneyDataObject implements ResponseInterface
|
||||
return new CustomersTopicScope($scope->shopID, $scope->eventTypes);
|
||||
}
|
||||
|
||||
throw new WrongDataException(WRONG_VALUE . ' `topic`');
|
||||
throw new WrongDataException(WRONG_VALUE . ' `topic`', 400);
|
||||
}
|
||||
|
||||
}
|
13
netcat/modules/rbkmoney/src/Exceptions/RBKmoneyException.php
Normal file
13
netcat/modules/rbkmoney/src/Exceptions/RBKmoneyException.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace src\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Базовый Exception для RBKmoney
|
||||
*/
|
||||
class RBKMoneyException extends Exception
|
||||
{
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user