Теперь работа с плагином IIKO и нуждается в создании банкета с предоплатой. Создание работы без проблем. Но когда я пытаюсь отменить с помощью deleteexternalfiscisticalizedPaymentItem < /code>, у меня есть < /p>
resto.front.api.exceptions.constraintviolationExcept Оплата? < /p>
private void CancelBanquet(IikoPrepaidBookingRq rq, string callBackUrl)
{
if (rq.BanquetId is null)
{
PluginContext.Log.Error($"Banquet {rq.BanquetId} is empty : {nameof(PrepaidBookingHandler)} : {nameof(CancelBanquet)}");
SentryHelper.SendException($"Banquet {rq.BanquetId} is empty", new Exception(),
$"{nameof(PrepaidBookingHandler)} : {nameof(CreateBanquetAndOrder)}");
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Error",
Message = "BanquetId is empty"
}, callBackUrl);
return;
}
var reserves = PluginContext.Operations.GetReserves();
var banquetId = Guid.Parse(rq.BanquetId);
var userBanquet = reserves.SingleOrDefault(x => x.Id == banquetId);
if (userBanquet is null)
{
PluginContext.Log.Error(
$"User ${rq.UserName} : {rq.UserPhone} : Reserve with tableId {rq.TableId} not found : " +
$"{nameof(PrepaidBookingHandler)} : {nameof(CancelBanquet)}");
SentryHelper.SendException(
$"User ${rq.UserName} : {rq.UserPhone} : Reserve with tableId {rq.TableId} not found",
new Exception(), $"{nameof(PrepaidBookingHandler)} : {nameof(CreateBanquetAndOrder)}");
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "NotFound",
Message = "userBanquet not found"
}, callBackUrl);
return;
}
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var prepaidPayment = userBanquet.Order.Payments.FirstOrDefault(p => p.IsPrepay);
//TODo добавить лог посмотерть как создается через UI платеж к банкету
//Todo Resto.Front.Api.Exceptions.ConstraintViolationException: Cannot delete payment item in status PROCESSED
PluginContext.Operations.DeleteExternalFiscalizedPaymentItem(prepaidPayment, userBanquet.Order, credentials);
PluginContext.Operations.CancelReserve(credentials, userBanquet, ReserveCancelReason.ClientRefused);
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Success"
}, callBackUrl);
}
#endregion
#region CreateBanquetAndOrder
private void CreateBanquetAndOrder(IikoPrepaidBookingRq rq, string callBackUrl)
{
var editSession = PluginContext.Operations.CreateEditSession();
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var phones = new List
{
new PhoneDto
{
PhoneValue = rq.UserPhone,
IsMain = true
}
};
var client = editSession.CreateClient(Guid.NewGuid(), rq.UserName, phones, null, DateTime.Now);
var table = PluginContext.Operations.GetTables()
.SingleOrDefault(x =>
x.RestaurantSection.Id == Guid.Parse(rq.SectionId) && x.Id == Guid.Parse(rq.TableId));
var order = editSession.CreateOrder(table);
editSession.AddOrderGuest(rq.UserName, order);
editSession.ChangeEstimatedOrderGuestsCount(rq.GuestsCount, order);
var banquetSub = editSession.CreateBanquet(rq.CheckinTime, client, order);
var createdBanquet = PluginContext.Operations.SubmitChanges(credentials, editSession).Get(banquetSub);
PluginContext.Operations.ChangeReserveGuestsCount(rq.GuestsCount, createdBanquet, credentials);
if (!string.IsNullOrEmpty(rq.Comment))
{
PluginContext.Operations.ChangeReserveComment(rq.Comment, createdBanquet, credentials);
}
AddExternalFiscalizedPrepay(createdBanquet.Order, rq.PrepaidAmount, rq.PaymentTypeId);
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Success",
BanquetId = createdBanquet.Id.ToString()
}, callBackUrl);
}
#endregion
#region AddExternalFiscalizedPrepay for banquet order
private void AddExternalFiscalizedPrepay(IOrder order, int prepaidAmount, string paymentTypeId)
{
var paymentType = PluginContext.Operations.GetPaymentTypes().First(x => x.Id == Guid.Parse(paymentTypeId));
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var paymentItem = PluginContext.Operations.AddExternalFiscalizedPaymentItem(
prepaidAmount,
null,
paymentType,
order,
credentials
);
PluginContext.Operations.ProcessPrepay(credentials, order, paymentItem);
}
#endregion
Подробнее здесь: https://stackoverflow.com/questions/797 ... -with-iiko
Как удалить внешний фискализованный платеж с IIKO? ⇐ C#
Место общения программистов C#
-
Anonymous
1757344900
Anonymous
Теперь работа с плагином IIKO и нуждается в создании банкета с предоплатой. Создание работы без проблем. Но когда я пытаюсь отменить с помощью deleteexternalfiscisticalizedPaymentItem < /code>, у меня есть < /p>
resto.front.api.exceptions.constraintviolationExcept Оплата? < /p>
private void CancelBanquet(IikoPrepaidBookingRq rq, string callBackUrl)
{
if (rq.BanquetId is null)
{
PluginContext.Log.Error($"Banquet {rq.BanquetId} is empty : {nameof(PrepaidBookingHandler)} : {nameof(CancelBanquet)}");
SentryHelper.SendException($"Banquet {rq.BanquetId} is empty", new Exception(),
$"{nameof(PrepaidBookingHandler)} : {nameof(CreateBanquetAndOrder)}");
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Error",
Message = "BanquetId is empty"
}, callBackUrl);
return;
}
var reserves = PluginContext.Operations.GetReserves();
var banquetId = Guid.Parse(rq.BanquetId);
var userBanquet = reserves.SingleOrDefault(x => x.Id == banquetId);
if (userBanquet is null)
{
PluginContext.Log.Error(
$"User ${rq.UserName} : {rq.UserPhone} : Reserve with tableId {rq.TableId} not found : " +
$"{nameof(PrepaidBookingHandler)} : {nameof(CancelBanquet)}");
SentryHelper.SendException(
$"User ${rq.UserName} : {rq.UserPhone} : Reserve with tableId {rq.TableId} not found",
new Exception(), $"{nameof(PrepaidBookingHandler)} : {nameof(CreateBanquetAndOrder)}");
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "NotFound",
Message = "userBanquet not found"
}, callBackUrl);
return;
}
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var prepaidPayment = userBanquet.Order.Payments.FirstOrDefault(p => p.IsPrepay);
//TODo добавить лог посмотерть как создается через UI платеж к банкету
//Todo Resto.Front.Api.Exceptions.ConstraintViolationException: Cannot delete payment item in status PROCESSED
PluginContext.Operations.DeleteExternalFiscalizedPaymentItem(prepaidPayment, userBanquet.Order, credentials);
PluginContext.Operations.CancelReserve(credentials, userBanquet, ReserveCancelReason.ClientRefused);
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Success"
}, callBackUrl);
}
#endregion
#region CreateBanquetAndOrder
private void CreateBanquetAndOrder(IikoPrepaidBookingRq rq, string callBackUrl)
{
var editSession = PluginContext.Operations.CreateEditSession();
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var phones = new List
{
new PhoneDto
{
PhoneValue = rq.UserPhone,
IsMain = true
}
};
var client = editSession.CreateClient(Guid.NewGuid(), rq.UserName, phones, null, DateTime.Now);
var table = PluginContext.Operations.GetTables()
.SingleOrDefault(x =>
x.RestaurantSection.Id == Guid.Parse(rq.SectionId) && x.Id == Guid.Parse(rq.TableId));
var order = editSession.CreateOrder(table);
editSession.AddOrderGuest(rq.UserName, order);
editSession.ChangeEstimatedOrderGuestsCount(rq.GuestsCount, order);
var banquetSub = editSession.CreateBanquet(rq.CheckinTime, client, order);
var createdBanquet = PluginContext.Operations.SubmitChanges(credentials, editSession).Get(banquetSub);
PluginContext.Operations.ChangeReserveGuestsCount(rq.GuestsCount, createdBanquet, credentials);
if (!string.IsNullOrEmpty(rq.Comment))
{
PluginContext.Operations.ChangeReserveComment(rq.Comment, createdBanquet, credentials);
}
AddExternalFiscalizedPrepay(createdBanquet.Order, rq.PrepaidAmount, rq.PaymentTypeId);
operationProvider.SendPrepaidBanquetId(new IikoPrepaidBookingRp
{
State = "Success",
BanquetId = createdBanquet.Id.ToString()
}, callBackUrl);
}
#endregion
#region AddExternalFiscalizedPrepay for banquet order
private void AddExternalFiscalizedPrepay(IOrder order, int prepaidAmount, string paymentTypeId)
{
var paymentType = PluginContext.Operations.GetPaymentTypes().First(x => x.Id == Guid.Parse(paymentTypeId));
var credentials = PluginContext.Operations.GetCredentials(AppDataV2.PaymentProcessorUserPin);
var paymentItem = PluginContext.Operations.AddExternalFiscalizedPaymentItem(
prepaidAmount,
null,
paymentType,
order,
credentials
);
PluginContext.Operations.ProcessPrepay(credentials, order, paymentItem);
}
#endregion
Подробнее здесь: [url]https://stackoverflow.com/questions/79758976/how-to-delete-external-fiscalized-payment-with-iiko[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия