Add one more payment request
This commit is contained in:
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Hcs.Client.Api.Payload.Payments
|
||||||
|
{
|
||||||
|
// http://open-gkh.ru/Payment/importNotificationsOfOrderExecutionRequest/NotificationOfOrderExecution139Type.html
|
||||||
|
public class ImportNotificationsOfOrderExecutionPayload
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Уникальный номер платежа (идентификатор операции)
|
||||||
|
/// </summary>
|
||||||
|
public string orderId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата
|
||||||
|
/// </summary>
|
||||||
|
public DateTime orderDate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сумма оплаты (в копейках)
|
||||||
|
/// </summary>
|
||||||
|
public decimal amount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Необязательное. Признак онлайн-оплаты.
|
||||||
|
/// </summary>
|
||||||
|
public bool? onlinePayment;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Необязательное. Год. Указывать совместно с <see cref="month"/>.
|
||||||
|
/// </summary>
|
||||||
|
public short? year;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Необязательное. Месяц. Указывать совместно с <see cref="year"/>.
|
||||||
|
/// </summary>
|
||||||
|
public int? month;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор платежного документа
|
||||||
|
/// </summary>
|
||||||
|
public string paymentDocumentId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GUID платежного документа
|
||||||
|
/// </summary>
|
||||||
|
public string paymentDocumentGUID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,18 @@ namespace Hcs.Client.Api
|
|||||||
// http://open-gkh.ru/PaymentsServiceAsync/
|
// http://open-gkh.ru/PaymentsServiceAsync/
|
||||||
public class PaymentsApi(ClientBase client) : ApiBase(client)
|
public class PaymentsApi(ClientBase client) : ApiBase(client)
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ВИ_ОПЛАТА_ИЗВ. Передать перечень документов "Извещение о принятии к исполнению распоряжения".
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="payload">Пейлоад документа</param>
|
||||||
|
/// <param name="token">Токен отмены</param>
|
||||||
|
/// <returns>true, если операция выполнена успешно, иначе - false</returns>
|
||||||
|
public async Task<bool> ImportNotificationsOfOrderExecutionAsync(ImportNotificationsOfOrderExecutionPayload payload, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var request = new ImportNotificationsOfOrderExecutionRequest(client);
|
||||||
|
return await request.ExecuteAsync(payload, token);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Импорт пакета документов "Извещение о принятии к исполнению распоряжения", размещаемых исполнителем
|
/// Импорт пакета документов "Извещение о принятии к исполнению распоряжения", размещаемых исполнителем
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -0,0 +1,112 @@
|
|||||||
|
using Hcs.Client.Api.Payload.Payments;
|
||||||
|
using Hcs.Client.Api.Request.Exception;
|
||||||
|
using Hcs.Client.Internal;
|
||||||
|
using Hcs.Service.Async.Payments;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Hcs.Client.Api.Request.Payments
|
||||||
|
{
|
||||||
|
internal class ImportNotificationsOfOrderExecutionRequest(ClientBase client) : PaymentsRequestBase(client)
|
||||||
|
{
|
||||||
|
protected override bool CanBeRestarted => false;
|
||||||
|
|
||||||
|
internal async Task<bool> ExecuteAsync(ImportNotificationsOfOrderExecutionPayload payload, CancellationToken token)
|
||||||
|
{
|
||||||
|
ThrowIfPayloadIncorrect(payload);
|
||||||
|
|
||||||
|
// http://open-gkh.ru/Payment/importNotificationsOfOrderExecutionRequest.html
|
||||||
|
var request = new importNotificationsOfOrderExecutionRequest
|
||||||
|
{
|
||||||
|
Id = Constants.SIGNED_XML_ELEMENT_ID,
|
||||||
|
version = "10.0.1.1",
|
||||||
|
Items = [GetNotificationFromPayload(payload)]
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await SendAndWaitResultAsync(request, async asyncClient =>
|
||||||
|
{
|
||||||
|
var response = await asyncClient.importNotificationsOfOrderExecutionAsync(CreateRequestHeader(), request);
|
||||||
|
return response.AckRequest.Ack;
|
||||||
|
}, token);
|
||||||
|
|
||||||
|
result.Items.OfType<ErrorMessageType>().ToList().ForEach(error =>
|
||||||
|
{
|
||||||
|
throw RemoteException.CreateNew(error.ErrorCode, error.Description);
|
||||||
|
});
|
||||||
|
|
||||||
|
result.Items.OfType<CommonResultType>().ToList().ForEach(commonResult =>
|
||||||
|
{
|
||||||
|
commonResult.Items.OfType<ErrorMessageType>().ToList().ForEach(error =>
|
||||||
|
{
|
||||||
|
throw RemoteException.CreateNew(error.ErrorCode, error.Description);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThrowIfPayloadIncorrect(ImportNotificationsOfOrderExecutionPayload payload)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(payload.orderId))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(payload.orderId)} is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.month.HasValue && !payload.year.HasValue)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(payload.month)} has value but {nameof(payload.year)} has not");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!payload.month.HasValue && payload.year.HasValue)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(payload.year)} has value but {nameof(payload.month)} has not");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(payload.paymentDocumentId))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(payload.paymentDocumentId)} is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(payload.paymentDocumentGUID))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(payload.paymentDocumentGUID)} is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private importNotificationsOfOrderExecutionRequestNotificationOfOrderExecution139Type GetNotificationFromPayload(ImportNotificationsOfOrderExecutionPayload payload)
|
||||||
|
{
|
||||||
|
var notification = new importNotificationsOfOrderExecutionRequestNotificationOfOrderExecution139Type()
|
||||||
|
{
|
||||||
|
TransportGUID = Guid.NewGuid().ToString(),
|
||||||
|
OrderInfo = new NotificationOfOrderExecution139TypeOrderInfo()
|
||||||
|
{
|
||||||
|
OrderID = payload.orderId,
|
||||||
|
OrderDate = payload.orderDate,
|
||||||
|
Amount = payload.amount,
|
||||||
|
// TODO: Проверить, возможно можно предоставить только один из двух параметров
|
||||||
|
Items = [payload.paymentDocumentId, payload.paymentDocumentGUID],
|
||||||
|
ItemsElementName = [ItemsChoiceType4.PaymentDocumentID, ItemsChoiceType4.PaymentDocumentGUID]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (payload.onlinePayment.HasValue && payload.onlinePayment.Value)
|
||||||
|
{
|
||||||
|
notification.OrderInfo.OnlinePayment = true;
|
||||||
|
notification.OrderInfo.OnlinePaymentSpecified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.month.HasValue)
|
||||||
|
{
|
||||||
|
notification.OrderInfo.MonthAndYear = new NotificationOfOrderExecution139TypeOrderInfoMonthAndYear()
|
||||||
|
{
|
||||||
|
Year = payload.year.Value,
|
||||||
|
Month = payload.month.Value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return notification;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -79,6 +79,7 @@
|
|||||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportNotificationDataPayload.cs" />
|
<Compile Include="Client\Api\Payload\HouseManagement\ImportNotificationDataPayload.cs" />
|
||||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractProjectPayload.cs" />
|
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractProjectPayload.cs" />
|
||||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractDataPayload.cs" />
|
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractDataPayload.cs" />
|
||||||
|
<Compile Include="Client\Api\Payload\Payments\ImportNotificationsOfOrderExecutionPayload.cs" />
|
||||||
<Compile Include="Client\Api\Payload\Payments\ImportSupplierNotificationsOfOrderExecutionPayload.cs" />
|
<Compile Include="Client\Api\Payload\Payments\ImportSupplierNotificationsOfOrderExecutionPayload.cs" />
|
||||||
<Compile Include="Client\Api\PaymentsApi.cs" />
|
<Compile Include="Client\Api\PaymentsApi.cs" />
|
||||||
<Compile Include="Client\Api\Registry\Registry16.cs" />
|
<Compile Include="Client\Api\Registry\Registry16.cs" />
|
||||||
@ -129,6 +130,7 @@
|
|||||||
<Compile Include="Client\Api\Request\OrgRegistryCommon\ExportOrgRegistryRequest.cs" />
|
<Compile Include="Client\Api\Request\OrgRegistryCommon\ExportOrgRegistryRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\OrgRegistryCommon\OrgRegistryCommonRequestBase.cs" />
|
<Compile Include="Client\Api\Request\OrgRegistryCommon\OrgRegistryCommonRequestBase.cs" />
|
||||||
<Compile Include="Client\Api\Request\PaginationData.cs" />
|
<Compile Include="Client\Api\Request\PaginationData.cs" />
|
||||||
|
<Compile Include="Client\Api\Request\Payments\ImportNotificationsOfOrderExecutionRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\Payments\ImportSupplierNotificationsOfOrderExecutionRequest.cs" />
|
<Compile Include="Client\Api\Request\Payments\ImportSupplierNotificationsOfOrderExecutionRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\Payments\PaymentsRequestBase.cs" />
|
<Compile Include="Client\Api\Request\Payments\PaymentsRequestBase.cs" />
|
||||||
<Compile Include="Client\Api\Request\RequestBase.cs" />
|
<Compile Include="Client\Api\Request\RequestBase.cs" />
|
||||||
|
|||||||
@ -80,6 +80,7 @@ namespace Hcs.TestApp
|
|||||||
//orgRegistryCommonScenario.ExportDataProvider();
|
//orgRegistryCommonScenario.ExportDataProvider();
|
||||||
//orgRegistryCommonScenario.ExportOrgRegistry();
|
//orgRegistryCommonScenario.ExportOrgRegistry();
|
||||||
|
|
||||||
|
//paymentsScenario.ImportNotificationsOfOrderExecution();
|
||||||
//paymentsScenario.ImportSupplierNotificationsOfOrderExecution();
|
//paymentsScenario.ImportSupplierNotificationsOfOrderExecution();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@ -8,6 +8,26 @@ namespace Hcs.TestApp.Scenario
|
|||||||
{
|
{
|
||||||
private readonly UniClient client = client;
|
private readonly UniClient client = client;
|
||||||
|
|
||||||
|
internal void ImportNotificationsOfOrderExecution()
|
||||||
|
{
|
||||||
|
var payload = new ImportNotificationsOfOrderExecutionPayload()
|
||||||
|
{
|
||||||
|
// TODO: Разобраться, что это за айди
|
||||||
|
orderId = "",
|
||||||
|
orderDate = new DateTime(2025, 9, 5),
|
||||||
|
amount = 4000M,
|
||||||
|
onlinePayment = true,
|
||||||
|
year = 2025,
|
||||||
|
month = 8,
|
||||||
|
paymentDocumentId = "00АА095186-02-5081",
|
||||||
|
// TODO: Возможно что не обязательно передавать оба параметра
|
||||||
|
paymentDocumentGUID = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = client.Payments.ImportNotificationsOfOrderExecutionAsync(payload).Result;
|
||||||
|
Console.WriteLine("Scenario execution " + (result ? "succeeded" : "failed"));
|
||||||
|
}
|
||||||
|
|
||||||
internal void ImportSupplierNotificationsOfOrderExecution()
|
internal void ImportSupplierNotificationsOfOrderExecution()
|
||||||
{
|
{
|
||||||
var payload = new ImportSupplierNotificationsOfOrderExecutionPayload()
|
var payload = new ImportSupplierNotificationsOfOrderExecutionPayload()
|
||||||
|
|||||||
Reference in New Issue
Block a user