Returning an order (cancellation)
Now it is possible to return orders not only from UI Syrve POS,
but also from the V8Preview7 API. To do this you need to call the method StornoOrder
.
Thus, we have closed the payment loop from the API, in which a full set of actions is now available:
- Making an advance payment:
ProcessPrepay
- Refund of prepayment / completed payment:
UnprocessPayment
- Payment for the order:
PayOrder
,PayOrderAndPayOutOnUser
- Order refund/cancellation:
StornoOrder
To return an order, the plugin must support payment transactions.
The employee whose
ICredentials
we transfer to the order reversal method must have the F_STRN (Make a refund) right.
The cash register shift in which the order was paid must be open and belong to the current terminal, because reversal is done locally.
There should be enough cash in the cash register if the order was paid in cash.
All payments subject to refund must support quiet payment.
Details about unsuccessful reversal, which may result in discarding PaymentActionFailedException
,
were merged with details about unsuccessful payment,
accordingly, the field PaymentActionFailedException.Reason
is now filled in in the method StornoOrder
.
List PaymentActionFailedExceptionReason
has been expanded with new items:
SomeOfCafeSessionsIsClosed
,StornoOrderFailed
,StornoNotSupported
,OrderStatusIsNotClosed
,OrderCloseAndStornoOnDifferentTerminalNotSupported
,DeliveryOrderStatusIsCanceled
From which
PaymentsProcessingCanceled
,PaymentsProcessingFailed
,BeforeDoChequeOperationFailed
,ChequeTaskProcessorFailed
,CashRegisterOperationFailed
have the specified property PaymentActionFailedException.Details
,
which will contain an exception message generated by another plugin in
IPaymentProcessor.ReturnPaymentSilently
,INotificationService.BeforeDoCheque
,IChequeTaskProcessor.BeforeDoCheckAction
,ICashRegister.DoCheque
.
Reason for failed reversal (PaymentActionFailedException.Reason
)
CashForChangeNotEnough
was renamed to CashNotEnough
.
I would also like to note that it is now possible to delete a paid order. An example call diagram for a closed order would look like this:
var order = PluginContext.Operations.GetOrders().Last(o => o.Status == OrderStatus.Closed);
var credentials = PluginContext.Operations.AuthenticateByPin("777");
// We cancel the order and return the payment
order = PluginContext.Operations.StornoOrder(order, credentials);
// We refund prepayments if they were included in the order
foreach (var orderPayment in order.Payments)
{
PluginContext.Operations.UnprocessPayment(order, orderPayment, credentials);
order = PluginContext.Operations.GetOrderById(order.Id);
}
// Deleting printed order items
if (order.Items.Count > 0)
{
PluginContext.Operations.DeletePrintedOrderItems(
"reason",
WriteoffOptions.WriteoffToCafe(PluginContext.Operations.GetActiveRemovalTypes().First(rt => rt.WriteoffType.HasFlag(WriteoffType.Cafe))),
order,
order.Items,
credentials);
order = PluginContext.Operations.GetOrderById(order.Id);
}
// Deleting an order
PluginContext.Operations.DeleteOrder(order, credentials);