Пример #1
0
        public static CaptureOperationResult CapturePayment(BarionClient barionClient, GetPaymentStateOperationResult beforeFinishReservationState)
        {
            var capturePayment = new CaptureOperation
            {
                PaymentId = beforeFinishReservationState.PaymentId
            };

            var transactionToCapture = new TransactionToFinish
            {
                TransactionId = beforeFinishReservationState.Transactions
                                .Single(t => t.POSTransactionId == POSTransactionId).TransactionId,
                Total = 500
            };

            capturePayment.Transactions = new[] { transactionToCapture };

            Console.WriteLine("Sending Capture...");
            var captureResult = barionClient.ExecuteAsync <CaptureOperationResult>(capturePayment).Result;

            if (!captureResult.IsOperationSuccessful)
            {
                throw new Exception("Capture operation was not successful.");
            }

            return(captureResult);
        }
Пример #2
0
 private void StartCaptureOperation(int x, int y, CaptureOperation op)
 {
     lastX            = x;
     lastY            = y;
     captureOperation = op;
     Capture          = true;
     canFling         = false;
 }
Пример #3
0
 private void StartCaptureOperation(MouseEventArgs e, CaptureOperation op)
 {
     Debug.Assert(captureOperation == CaptureOperation.None);
     mouseLastX       = e.X;
     mouseLastY       = e.Y;
     captureStartX    = e.X;
     captureStartY    = e.Y;
     captureOperation = op;
     Capture          = true;
 }
Пример #4
0
        private void EndCaptureOperation(int x, int y)
        {
            switch (captureOperation)
            {
            case CaptureOperation.PlayPiano:
                EndPlayPiano();
                break;

            case CaptureOperation.MobilePan:
            case CaptureOperation.MobileZoom:
                canFling = true;
                break;
            }

            Capture          = false;
            captureOperation = CaptureOperation.None;
            MarkDirty();
        }
Пример #5
0
 private void EndCaptureOperation(int x, int y)
 {
     captureOperation = CaptureOperation.None;
     Capture          = false;
     MarkDirty();
 }
Пример #6
0
        public static void Run()
        {
            var settings = new BarionSettings
            {
                BaseUrl = new Uri(AppSettings.BarionBaseAddress),
                POSKey  = Guid.Parse(AppSettings.BarionPOSKey),
                Payee   = AppSettings.BarionPayee
            };

            using (var barionClient = new BarionClient(settings))
            {
                var startPaymentOperation = new StartPaymentOperation
                {
                    GuestCheckOut        = true,
                    PaymentType          = PaymentType.DelayedCapture,
                    DelayedCapturePeriod = TimeSpan.FromDays(1),
                    FundingSources       = new[] { FundingSourceType.All },
                    PaymentRequestId     = "P1",
                    OrderNumber          = "1_0",
                    Currency             = Currency.EUR,
                    CallbackUrl          = "http://index.sk",
                    Locale      = CultureInfo.CurrentCulture,
                    RedirectUrl = "http://index.sk"
                };

                var transaction = new PaymentTransaction
                {
                    Payee            = settings.Payee,
                    POSTransactionId = "T1",
                    Total            = new decimal(50),
                    Comment          = "comment"
                };

                var item = new Item
                {
                    Name        = "Test",
                    Description = "Test",
                    ItemTotal   = new decimal(50),
                    Quantity    = 1,
                    Unit        = "piece",
                    UnitPrice   = new decimal(50),
                    SKU         = "SKU"
                };

                transaction.Items = new[] { item };
                startPaymentOperation.Transactions = new[] { transaction };

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Sending StartPayment...");
                var result = barionClient.ExecuteAsync <StartPaymentOperationResult>(startPaymentOperation).Result;
                Console.ResetColor();
                Console.WriteLine("StartPayment result:");
                Console.ForegroundColor = result.IsOperationSuccessful ? ConsoleColor.Green : ConsoleColor.Red;
                Console.WriteLine($"\tSuccess: {result.IsOperationSuccessful}");
                Console.WriteLine($"\tPaymentId: {result.PaymentId}");
                Console.WriteLine($"\tStatus: {result.Status}");

                Console.ResetColor();
                Console.WriteLine();
                Console.WriteLine("Starting the browser with the barion pay page.");

                System.Diagnostics.Process.Start(result.GatewayUrl);

                Console.WriteLine("Press any key to continue the flow...");
                Console.ReadKey();

                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Sending GetPaymentState...");

                var statusOperation = new GetPaymentStateOperation
                {
                    PaymentId = result.PaymentId
                };

                var result2 = barionClient.ExecuteAsync <GetPaymentStateOperationResult>(statusOperation).Result;

                Console.ResetColor();
                Console.WriteLine("GetPaymentState result:");
                Console.ForegroundColor = result.IsOperationSuccessful ? ConsoleColor.Green : ConsoleColor.Red;
                Console.WriteLine($"\tSuccess: {result2.IsOperationSuccessful}");
                Console.WriteLine($"\tPaymentId: {result2.PaymentId}");
                Console.WriteLine($"\tStatus: {result2.Status}");

                var capturePayment = new CaptureOperation
                {
                    PaymentId = result2.PaymentId
                };

                var transactionToFinish = new TransactionToFinish
                {
                    TransactionId = result2.Transactions.Single(t => t.POSTransactionId == "T1").TransactionId,
                    Total         = 50
                };

                capturePayment.Transactions = new[] { transactionToFinish };

                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Sending capture...");

                var result3 = barionClient.ExecuteAsync <CaptureOperationResult>(capturePayment).Result;

                Console.ResetColor();
                Console.WriteLine("Capture result:");
                Console.ForegroundColor = result.IsOperationSuccessful ? ConsoleColor.Green : ConsoleColor.Red;
                Console.WriteLine($"\tSuscess: {result3.IsOperationSuccessful}");
                Console.WriteLine($"\tPaymentId: {result3.PaymentId}");
                Console.WriteLine($"\tStatus: {result3.Status}");
            }
        }
Пример #7
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (captureOperation != CaptureOperation.None)
            {
                if (captureOperation == CaptureOperation.ClickPattern)
                {
                    if (GetPatternForCoord(e.X, e.Y, out int channelIdx, out int patternIdx))
                    {
                        minSelectedChannelIdx = channelIdx;
                        maxSelectedChannelIdx = channelIdx;
                        minSelectedPatternIdx = patternIdx;
                        maxSelectedPatternIdx = patternIdx;
                        ConditionalInvalidate();
                    }
                    else
                    {
                        ClearSelection();
                    }
                }
                else if (captureOperation == CaptureOperation.DragSelection)
                {
                    bool copy = ModifierKeys.HasFlag(Keys.Control);

                    int centerX        = e.X - selectionDragAnchorX + patternSizeX / 2;
                    int basePatternIdx = (centerX - trackNameSizeX + scrollX) / patternSizeX;

                    Pattern[,] tmpPatterns = new Pattern[maxSelectedChannelIdx - minSelectedChannelIdx + 1, maxSelectedPatternIdx - minSelectedPatternIdx + 1];

                    App.UndoRedoManager.BeginTransaction(TransactionScope.Song, Song.Id);

                    for (int i = minSelectedChannelIdx; i <= maxSelectedChannelIdx; i++)
                    {
                        for (int j = minSelectedPatternIdx; j <= maxSelectedPatternIdx; j++)
                        {
                            tmpPatterns[i - minSelectedChannelIdx, j - minSelectedPatternIdx] = Song.Channels[i].PatternInstances[j];
                            if (!copy)
                            {
                                Song.Channels[i].PatternInstances[j] = null;
                            }
                        }
                    }

                    for (int i = minSelectedChannelIdx; i <= maxSelectedChannelIdx; i++)
                    {
                        for (int j = minSelectedPatternIdx; j <= maxSelectedPatternIdx; j++)
                        {
                            Song.Channels[i].PatternInstances[j + basePatternIdx - minSelectedPatternIdx] = tmpPatterns[i - minSelectedChannelIdx, j - minSelectedPatternIdx];
                        }
                    }

                    App.UndoRedoManager.EndTransaction();

                    ClearSelection();
                    ConditionalInvalidate();
                }

                Capture          = false;
                captureOperation = CaptureOperation.None;
            }