ref #92904
Добавление опции работы с интегрированными оплатами Добавлен функционал создания оплаты и её обновления
This commit is contained in:
parent
a7dbb7f5c4
commit
7fba8622b3
4 changed files with 50 additions and 6 deletions
|
@ -141,11 +141,11 @@ class RetailCrmService
|
|||
}
|
||||
|
||||
if (empty($type['sites'])) {
|
||||
$result[] = $type;
|
||||
$result[$type['code']] = $type;
|
||||
} else {
|
||||
foreach ($type['sites'] as $site) {
|
||||
if (!empty($availableSites[$site])) {
|
||||
$result[] = $type;
|
||||
$result[$type['code']] = $type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,3 +139,7 @@ $MESS ['LOCATION_LABEL'] = 'Location';
|
|||
$MESS ['TEXT_ADDRESS_LABEL'] = 'Address (line)';
|
||||
|
||||
$MESS ['SYNC_INTEGRATION_PAYMENT'] = 'Activate synchronization of integrated payments';
|
||||
$MESS ['DESCRIPTION_AUTO_PAYMENT_TYPE'] = 'Automatically created payment type for integration substitution (Bitrix)';
|
||||
$MESS ['SUBSTITUTED_PAYMENT'] = '(Substituted Bitrix)';
|
||||
$MESS ['ERR_CHECK_JOURNAL'] = 'Error while saving. Details in the event log';
|
||||
$MESS ['ERROR_LINK_INTEGRATION_PAYMENT'] = 'Integration payment linkage error';
|
||||
|
|
|
@ -198,3 +198,7 @@ $MESS ['LOCATION_LABEL'] = 'Местоположение (LOCATION)';
|
|||
$MESS ['TEXT_ADDRESS_LABEL'] = 'Адрес (строкой)';
|
||||
|
||||
$MESS ['SYNC_INTEGRATION_PAYMENT'] = 'Активировать синхронизацию интегрированных оплат';
|
||||
$MESS ['DESCRIPTION_AUTO_PAYMENT_TYPE'] = 'Автоматически созданный тип оплаты для подмены интеграционной (Bitrix)';
|
||||
$MESS ['SUBSTITUTED_PAYMENT'] = '(Подменённый Bitrix)';
|
||||
$MESS ['ERR_CHECK_JOURNAL'] = 'Ошибка при сохранении. Подробности в журнале событий';
|
||||
$MESS ['ERROR_LINK_INTEGRATION_PAYMENT'] = 'Ошибка связи интеграционных оплат';
|
||||
|
|
|
@ -244,6 +244,7 @@ if (!empty($availableSites)) {
|
|||
|
||||
//update connection settings
|
||||
if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
||||
$error = null;
|
||||
$api_host = htmlspecialchars(trim($_POST['api_host']));
|
||||
$api_key = htmlspecialchars(trim($_POST['api_key']));
|
||||
|
||||
|
@ -840,10 +841,35 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
if ($syncIntegrationPayment === 'Y') {
|
||||
ConfigProvider::setSyncIntegrationPayment($syncIntegrationPayment);
|
||||
|
||||
$integrationPaymentsList = RetailcrmConfigProvider::getIntegrationPaymentTypes();
|
||||
foreach (RetailcrmConfigProvider::getIntegrationPaymentTypes() as $integrationPayment) {
|
||||
if (array_search($integrationPayment, $paymentTypesArr)) {
|
||||
$crmCodePaymentList = array_column($arResult['paymentTypesList'], 'code');
|
||||
|
||||
foreach (RetailcrmConfigProvider::getIntegrationPaymentTypes() as $integrationPayment) {
|
||||
if (in_array($integrationPayment, $paymentTypesArr)) {
|
||||
$originalPayment = $arResult['paymentTypesList'][$integrationPayment];
|
||||
$codePayment = $integrationPayment . '-not-integration';
|
||||
$sites = $siteListArr !== [] ? array_values($siteListArr) : array_keys($availableSites);
|
||||
$sites = array_filter($sites, function ($site) {return $site !== null;});
|
||||
|
||||
$response = $api->paymentTypesEdit([
|
||||
'name' => $originalPayment['name'] . ' ' . GetMessage('SUBSTITUTED_PAYMENT'),
|
||||
'code' => $codePayment,
|
||||
'active' => true,
|
||||
'description' => GetMessage('DESCRIPTION_AUTO_PAYMENT_TYPE'),
|
||||
'sites' => $sites,
|
||||
'paymentStatuses' => $originalPayment['paymentStatuses']
|
||||
]);
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
if ($statusCode !== 200 && $statusCode !== 201) {
|
||||
RCrmActions::eventLog(
|
||||
'Retailcrm::options.php',
|
||||
'syncIntegrationPayment',
|
||||
GetMessage('ERROR_LINK_INTEGRATION_PAYMENT') . ' : ' . $response->getResponseBody()
|
||||
);
|
||||
|
||||
$error = 'ERR_CHECK_JOURNAL';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,7 +1036,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
COption::SetOptionString($mid, $PROTOCOL, 'http://');
|
||||
}
|
||||
|
||||
$uri .= '&ok=Y';
|
||||
if ($error !== null) {
|
||||
$uri .= '&errc=' . $error;
|
||||
} else {
|
||||
$uri .= '&ok=Y';
|
||||
}
|
||||
|
||||
LocalRedirect($uri);
|
||||
} else {
|
||||
$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0);
|
||||
|
@ -1107,6 +1138,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
$availableSites,
|
||||
$api->paymentTypesList()->paymentTypes
|
||||
);
|
||||
|
||||
$arResult['paymentTypesList'] = array_filter($arResult['paymentTypesList'], function ($payment) {
|
||||
return strripos($payment['code'], '-not-integration') === false;
|
||||
});
|
||||
|
||||
$arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes(
|
||||
$availableSites,
|
||||
$api->deliveryTypesList()->deliveryTypes
|
||||
|
|
Loading…
Add table
Reference in a new issue