// Implementation of return payment method. Executes when order contains processed plug-in payment item and order is storning. public void ReturnPayment(decimal sum, Guid?orderId, Guid paymentTypeId, Guid transactionId, [NotNull] IPointOfSale pointOfSale, [NotNull] IUser cashier, IReceiptPrinter printer, IViewManager viewManager, IPaymentDataContext context) { PluginContext.Log.InfoFormat("Order id {0}", orderId); var data = context.GetRollbackData <CollectedDataDemoClass>(); var slip = new ReceiptSlip { Doc = new XElement(Tags.Doc, new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Return"), new XAttribute(Data.Cheques.Attributes.Right, PaymentSystemKey), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Transaction ID"), new XAttribute(Data.Cheques.Attributes.Right, transactionId.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "was card"), new XAttribute(Data.Cheques.Attributes.Right, data != null && data.IsCard ? "YES" : "NO"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right))) }; printer.Print(slip); // To abort any not successful payment action PaymentActionFailedException should be used. var success = true; if (!success) { throw new PaymentActionFailedException("Fail to storno payment. This text will be shown in dialog window and storning operation will be aborted."); } }
private void CafeSessionClosing([NotNull] IReceiptPrinter printer) { PluginContext.Log.Info("Cafe Session Closing."); var slip = new ReceiptSlip { Doc = new XElement(Tags.Doc, new XElement(Tags.Center, PaymentSystemKey), new XElement(Tags.Center, "Cafe session closed.")) }; printer.Print(slip); }
public void PaySilently(decimal sum, Guid orderId, Guid paymentTypeId, Guid transactionId, IPointOfSale pointOfSale, IUser cashier, IReceiptPrinter printer, IPaymentDataContext context) { PluginContext.Log.Info("SilentPay"); var data = context.GetCustomData(); // You can get order from api by id via operationService. var order = GetOrderSafe(orderId); // You can't change the text displayed on progress bar while on silent pay operation //progressBar.ChangeMessage("Printing slip"); // Slip to print. Slip consists of XElement children from Resto.CashServer.Agent.Print.Tags.Xml (Resto.Framework.dll) var slip = new ReceiptSlip { Doc = new XElement(Tags.Doc, new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Payment System"), new XAttribute(Data.Cheques.Attributes.Right, PaymentSystemKey), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Transaction ID"), new XAttribute(Data.Cheques.Attributes.Right, transactionId.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Data"), new XAttribute(Data.Cheques.Attributes.Right, data ?? "unknown"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Order #"), new XAttribute(Data.Cheques.Attributes.Right, order?.Number.ToString() ?? "unknown"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Full sum"), new XAttribute(Data.Cheques.Attributes.Right, order?.FullSum.ToString() ?? "unknown"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Sum to pay"), new XAttribute(Data.Cheques.Attributes.Right, order?.ResultSum.ToString() ?? "unknown"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Sum to process"), new XAttribute(Data.Cheques.Attributes.Right, sum.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right))) }; printer.Print(slip); context.SetInfoForReports(data, "Custom data"); }
// Implementation of payment method. Executes when order contains plug-in payment item type and order payment process begins. public void Pay(decimal sum, [NotNull] IOrder order, Guid paymentTypeId, Guid transactionId, [NotNull] IPointOfSale pointOfSale, [NotNull] IUser cashier, [NotNull] IOperationService operations, IReceiptPrinter printer, IViewManager viewManager, IPaymentDataContext context) { PluginContext.Log.InfoFormat("Pay {0}", sum); var data = context.GetRollbackData <CollectedDataDemoClass>(); // Changing the text displayed on progress bar on pay operation viewManager.ChangeProgressBarMessage("Printing slip"); // Slip to print. Slip consists of XElement children from Resto.CashServer.Agent.Print.Tags.Xml (Resto.Framework.dll) var slip = new ReceiptSlip { Doc = new XElement(Tags.Doc, new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Payment System"), new XAttribute(Data.Cheques.Attributes.Right, PaymentSystemKey), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Transaction ID"), new XAttribute(Data.Cheques.Attributes.Right, transactionId.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Data"), new XAttribute(Data.Cheques.Attributes.Right, data != null ? data.Data : "unknown"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "was card"), new XAttribute(Data.Cheques.Attributes.Right, data != null && data.IsCard ? "YES" : "NO"), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Order #"), new XAttribute(Data.Cheques.Attributes.Right, order.Number.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Full sum"), new XAttribute(Data.Cheques.Attributes.Right, order.FullSum.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Sum to pay"), new XAttribute(Data.Cheques.Attributes.Right, order.ResultSum.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right)), new XElement(Tags.Pair, new XAttribute(Data.Cheques.Attributes.Left, "Sum to process"), new XAttribute(Data.Cheques.Attributes.Right, sum.ToString()), new XAttribute(Data.Cheques.Attributes.Fit, Data.Cheques.Attributes.Right))) }; printer.Print(slip); context.SetInfoForReports(data?.Data, "Test Card Type"); var donationType = operations.GetDonationTypesCompatibleWith(order).FirstOrDefault(dt => dt.PaymentTypes.Any(pt => pt.Kind == PaymentTypeKind.External)); if (donationType != null) { var paymentType = donationType.PaymentTypes.First(x => x.Kind == PaymentTypeKind.External && x.Name == "SampleApiPayment"); var additionalData = new ExternalPaymentItemAdditionalData { CustomData = Serializer.Serialize(new PaymentAdditionalData { SilentPay = true }) }; var credentials = operations.GetCredentials(); operations.AddDonation(credentials, order, donationType, paymentType, additionalData, false, order.ResultSum / 2); } }