public void AddPayment(Domain.Payment.Models.Payment payment)
        {
            //Verify payment type and method are supported.
            if (payment.PaymentType != SupportedType)
            {
                throw new InvalidPaymentException("Payment type not supported by current payment service.");
            }
            if (!SupportedMethods.Contains(((CreditCardPayment)payment).PaymentMethod))
            {
                throw new InvalidPaymentException("Payment method not supported by current payment service.");
            }

            var paymentList =
                _sessionStorage.Get <List <Domain.Payment.Models.Payment> >(SessionKeys.DomainPayments) ??
                new List <Domain.Payment.Models.Payment>();

            //Add Reference Id to generate Payment Id.
            payment.ReferenceId = "123456";

            //Generate random status.
            payment.Status = _random.Next(100) <= 80
                ? PaymentStatus.Approved
                : _random.Next(100) <= 50
                    ? PaymentStatus.Pending
                    : PaymentStatus.Declined;

            paymentList.Add(payment);

            _sessionStorage.Add(SessionKeys.DomainPayments, paymentList);
        }
Пример #2
0
        public BookingPricing Retrieve()
        {
            var currentBooking = _sessionStorage.Get <BookingPricing>("DomainBooking");

            BookingPricing bookingPricing;

            if (currentBooking != null)
            {
                bookingPricing = currentBooking;
            }
            else
            {
                bookingPricing = new BookingPricing
                {
                    Currency = "EUR",
                    Journeys = new List <Journey>
                    {
                        new Journey
                        {
                            ReferenceId = "AAA000",
                            Segments    = new List <Segment>
                            {
                                new Segment
                                {
                                    ReferenceId = "ABC01",
                                    Transport   = new Transport {
                                        Carrier = new Carrier {
                                            Code = "E9"
                                        }, Number = "VU101"
                                    },
                                    Legs = new List <Leg>
                                    {
                                        new Leg
                                        {
                                            Origin      = "MAD",
                                            Destination = "CUN",
                                            STD         = DateTime.Today
                                        }
                                    }
                                },
                                new Segment
                                {
                                    ReferenceId = "ABC02",
                                    Transport   = new Transport {
                                        Carrier = new Carrier {
                                            Code = "E9"
                                        }, Number = "VU102"
                                    },
                                    Legs = new List <Leg>
                                    {
                                        new Leg
                                        {
                                            Origin      = "CUN",
                                            Destination = "MAD",
                                            STD         = DateTime.Today.AddDays(1)
                                        }
                                    }
                                }
                            }
                        }
                    }
                };
            }

            return(bookingPricing);
        }