Exemplo n.º 1
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Cashier == null))
                {
                    ICashier cashierCasted = item.As <ICashier>();
                    if ((cashierCasted != null))
                    {
                        this._parent.Cashier = cashierCasted;
                        return;
                    }
                }
                if ((this._parent.PointOfSale == null))
                {
                    IPointOfSale pointOfSaleCasted = item.As <IPointOfSale>();
                    if ((pointOfSaleCasted != null))
                    {
                        this._parent.PointOfSale = pointOfSaleCasted;
                        return;
                    }
                }
                IReceipt receiptsCasted = item.As <IReceipt>();

                if ((receiptsCasted != null))
                {
                    this._parent.Receipts.Add(receiptsCasted);
                }
                ITransaction transactionsCasted = item.As <ITransaction>();

                if ((transactionsCasted != null))
                {
                    this._parent.Transactions.Add(transactionsCasted);
                }
            }
Exemplo n.º 2
0
        public UPayAgent(IPointOfSale pointOfSale, ITransactionSwitch transactionSwitch, ILogger logger)
        {
            _pointOfSale       = pointOfSale;
            _transactionSwitch = transactionSwitch;
            _logger            = logger;

            AgentState = UPayAgentState.AcceptPointOfSaleConnection;
        }
Exemplo n.º 3
0
 protected override void OnStart(string[] args)
 {
     _logger = LoggerFactory.GetLogger();
     _logger.Info("UPayService is starting...");
     _pointOfSale       = new PointOfSale(_logger);
     _transactionSwitch = new TransactionSwitch(_logger);
     _agent             = new UPayAgent(_pointOfSale, _transactionSwitch, _logger);
     _agent.Start();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.PointOfSale == null))
     {
         IPointOfSale pointOfSaleCasted = item.As <IPointOfSale>();
         if ((pointOfSaleCasted != null))
         {
             this._parent.PointOfSale = pointOfSaleCasted;
             return;
         }
     }
 }
Exemplo n.º 5
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IPointOfSale pointOfSaleItem = item.As <IPointOfSale>();

                if (((pointOfSaleItem != null) &&
                     this._parent.PointOfSales.Remove(pointOfSaleItem)))
                {
                    return(true);
                }
                ICashier cashierItem = item.As <ICashier>();

                if (((cashierItem != null) &&
                     this._parent.Cashiers.Remove(cashierItem)))
                {
                    return(true);
                }
                if ((this._parent.MerchantAccount == item))
                {
                    this._parent.MerchantAccount = null;
                    return(true);
                }
                IBankStatement bankStatementItem = item.As <IBankStatement>();

                if (((bankStatementItem != null) &&
                     this._parent.BankStatements.Remove(bankStatementItem)))
                {
                    return(true);
                }
                IVendorShift vendorShiftItem = item.As <IVendorShift>();

                if (((vendorShiftItem != null) &&
                     this._parent.VendorShifts.Remove(vendorShiftItem)))
                {
                    return(true);
                }
                return(false);
            }
Exemplo n.º 6
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IPointOfSale pointOfSalesCasted = item.As <IPointOfSale>();

                if ((pointOfSalesCasted != null))
                {
                    this._parent.PointOfSales.Add(pointOfSalesCasted);
                }
                ICashier cashiersCasted = item.As <ICashier>();

                if ((cashiersCasted != null))
                {
                    this._parent.Cashiers.Add(cashiersCasted);
                }
                if ((this._parent.MerchantAccount == null))
                {
                    IMerchantAccount merchantAccountCasted = item.As <IMerchantAccount>();
                    if ((merchantAccountCasted != null))
                    {
                        this._parent.MerchantAccount = merchantAccountCasted;
                        return;
                    }
                }
                IBankStatement bankStatementsCasted = item.As <IBankStatement>();

                if ((bankStatementsCasted != null))
                {
                    this._parent.BankStatements.Add(bankStatementsCasted);
                }
                IVendorShift vendorShiftsCasted = item.As <IVendorShift>();

                if ((vendorShiftsCasted != null))
                {
                    this._parent.VendorShifts.Add(vendorShiftsCasted);
                }
            }
        // 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.");
            }
        }
 public void EmergencyCancelPaymentSilently(decimal sum, Guid?orderId, Guid paymentTypeId, Guid transactionId, IPointOfSale pointOfSale, IUser cashier, IReceiptPrinter printer, IPaymentDataContext context)
 {
     PluginContext.Log.InfoFormat("Silent cancel {0}", sum);
     //there are no instances of viewManager and progressBar
     ReturnPayment(sum, orderId, paymentTypeId, transactionId, pointOfSale, cashier, printer, null, context);
 }
        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 emergency cancel payment method. Executes when already processed plug-in payment item is removing from order.
 // May be the same method with ReturnPayment() if there is no difference in payment system guidelines.
 public void EmergencyCancelPayment(decimal sum, Guid?orderId, Guid paymentTypeId, Guid transactionId, [NotNull] IPointOfSale pointOfSale, [NotNull] IUser cashier, IReceiptPrinter printer,
                                    IViewManager viewManager, IPaymentDataContext context)
 {
     PluginContext.Log.InfoFormat("Cancel {0}", sum);
     ReturnPayment(sum, orderId, paymentTypeId, transactionId, pointOfSale, cashier, printer, viewManager, context);
 }
        // 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);
            }
        }
 public void ReturnPaymentWithoutOrder(decimal sum, Guid paymentTypeId, IPointOfSale pointOfSale,
                                       IUser cashier, IReceiptPrinter printer, IViewManager viewManager)
 {
     // if you need to implement return payment without iiko order, you should register your IExternalPaymentProcessor as 'canProcessPaymentReturnWithoutOrder = true'
     throw new PaymentActionFailedException("Not supported action");
 }
 public void ReturnPayment(decimal sum, Guid?orderId, Guid paymentTypeId, Guid transactionId, IPointOfSale pointOfSale, IUser cashier,
                           IReceiptPrinter printer, IViewManager viewManager, IPaymentDataContext context, IProgressBar progressBar)
 {
     PluginContext.Log.Info($"=== ReturnPayment {sum}");
 }
Exemplo n.º 14
0
 /**
  *  <summary>
  *  Initialises the instance of PointOfSaleTerminal
  *  with a instance of IPointOfSale.
  *  </summary>
  *  <param name="pointOfSale"><see cref="IPointOfSale"/>
  *  : instance of IPointOfSale
  *  </param>
  **/
 public PointOfSaleTerminal(IPointOfSale pointOfSale)
 {
     _pointOfSale = pointOfSale;
 }