The "No Revenue" Payment Type Now Supports Silent Payment

Tags: v8

In SyrveFront version 8.4.4 and above, it is now possible to close an order containing a “No Revenue” payment type remotely using the method PayOrder.

Also, in API V8, a new field AuthorizationUser has been added to WriteoffPaymentItemAdditionalData — “Employee or guest for whom the write-off is made”. This field should be filled in if the settings for the “No Revenue” payment type select authorization by an employee or guest. The user being passed must have the checkbox checked for “Guest” and/or “Employee” in their personal card, depending on the settings in the payment type. If authorization in the payment type is not required, AuthorizationUser can be omitted.

The employee whose ICredentials we pass to the method for adding payment to the order must have the F_COTH right (Close orders at the expense of the establishment).

Example usage:

// Employee whose F_COTH right (Close orders at the expense of the establishment) will be checked.
var credentials = PluginContext.Operations.AuthenticateByPin("777");
var order = PluginContext.Operations.GetOrders().Last(o => o.Status == OrderStatus.New);
var paymentType = PluginContext.Operations.GetPaymentTypes().First(x => x.Kind == PaymentTypeKind.Writeoff);
var additionalData = new WriteoffPaymentItemAdditionalData
{
    Ratio = 1,
    Reason = "Write-off",
    // Employee or guest for whom the write-off is made.
    AuthorizationUser = PluginContext.Operations.GetUsers().SingleOrDefault(user => user.Name == "Guest Grigory")
};
// Adding an external unprocessed payment without revenue.
PluginContext.Operations.AddExternalPaymentItem(order.ResultSum, false, additionalData, null, paymentType, order, credentials);
// Or adding a regular payment without revenue.
// PluginContext.Operations.AddPaymentItem(order.ResultSum, additionalData, paymentType, order, credentials);

order = PluginContext.Operations.GetOrderById(order.Id);
// Remote payment of the order using existing payments locally.
PluginContext.Operations.PayOrder(credentials, order, true);

Documentation that may be useful: