コード例 #1
0
        /// <summary>
        /// Добавление внешнего непроведенного платежа и его проведение.
        /// </summary>
        private void AddAndProcessExternalPrepay()
        {
            var order          = PluginContext.Operations.GetOrders().Last(o => o.Status == OrderStatus.New);
            var paymentType    = PluginContext.Operations.GetPaymentTypes().Last(x => x.Kind == PaymentTypeKind.External && x.Name == "SampleApiPayment");
            var additionalData = new ExternalPaymentItemAdditionalData {
                CustomData = Serializer.Serialize(new PaymentAdditionalData {
                    SilentPay = true
                })
            };
            var credentials = PluginContext.Operations.GetCredentials();
            var paymentItem = PluginContext.Operations.AddExternalPaymentItem(order.ResultSum, false, additionalData, paymentType, order, credentials);

            PluginContext.Operations.ProcessPrepay(credentials, order, paymentItem);
        }
コード例 #2
0
        private void AddNotProcessedExternalDonation()
        {
            const bool isProcessed    = false;
            var        order          = PluginContext.Operations.GetOrders().Last(o => o.Status == OrderStatus.New);
            var        donationType   = PluginContext.Operations.GetDonationTypesCompatibleWith(order).First(dt => dt.PaymentTypes.Any(pt => pt.Kind == PaymentTypeKind.External));
            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 = PluginContext.Operations.GetCredentials();

            var paymentItem = PluginContext.Operations.AddDonation(credentials, order, donationType, paymentType, additionalData, isProcessed, order.ResultSum / 2);

            order = PluginContext.Operations.GetOrderById(order.Id);
            Debug.Assert(order.Donations.Contains(paymentItem));
        }
コード例 #3
0
        // 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);
            }
        }