Order Return (Storno)
Now it is possible to return orders not only from the UI SyrveFront,
but also from the API V8Preview7. To do this, you need to call the method StornoOrder.
Thus, we have closed the payment loop from the API, where a full set of actions is now available:
- Prepayment:
ProcessPrepay - Refund of prepayment / completed payment:
UnprocessPayment - Order payment:
PayOrder,PayOrderAndPayOutOnUser - Refund of order payment / storno:
StornoOrder
To return an order, the plugin must support payment operations.
The employee whose ICredentials we pass to the order storno method must have the right F_STRN (To perform a payment refund).
The cash register shift in which the order was paid must be open and belong to the current terminal, as storno is performed locally.
There must be enough cash in the register if cash was used to pay for the order.
All payments subject to refund must support silent payment.
Details about unsuccessful storno, in which case a PaymentActionFailedException may be thrown,
have been combined with details about unsuccessful payment,
accordingly, the field PaymentActionFailedException.Reason
is now filled in the StornoOrder method as well.
The list of PaymentActionFailedExceptionReason
has been updated with the following items:
SomeOfCafeSessionsIsClosed,StornoOrderFailed,StornoNotSupported,OrderStatusIsNotClosed,OrderCloseAndStornoOnDifferentTerminalNotSupported,DeliveryOrderStatusIsCanceled
Among them,
PaymentsProcessingCanceled,PaymentsProcessingFailed,BeforeDoChequeOperationFailed,ChequeTaskProcessorFailed,CashRegisterOperationFailed
have the specified property PaymentActionFailedException.Details,
which will contain the exception message generated by another plugin in
IPaymentProcessor.ReturnPaymentSilently,INotificationService.BeforeDoCheque,IChequeTaskProcessor.BeforeDoCheckAction,ICashRegister.DoCheque.
The reason for unsuccessful storno (PaymentActionFailedException.Reason)
CashForChangeNotEnough has been renamed to CashNotEnough.
It is also worth noting that there is now an option to delete a paid order. The approximate call scheme for a closed order will look like this:
var order = PluginContext.Operations.GetOrders().Last(o => o.Status == OrderStatus.Closed);
var credentials = PluginContext.Operations.AuthenticateByPin("777");
// Storno the order, returning payments
order = PluginContext.Operations.StornoOrder(order, credentials);
// Return prepayments if they were in the order
foreach (var orderPayment in order.Payments)
{
PluginContext.Operations.UnprocessPayment(order, orderPayment, credentials);
order = PluginContext.Operations.GetOrderById(order.Id);
}
// Delete 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);
}
// Delete the order
PluginContext.Operations.DeleteOrder(order, credentials);