Exemple #1
0
        private IEnumerable <PaymentInfo> GetPaymentData(int max, int paymentProcessorCode)
        {
            //empty the database
            //seed initial data
            //create paymentrequests out of seeded data
            var currency  = DefaultData.TransactionCurrency;
            var processor = paymentProcessorCode switch
            {
                0 => DefaultData.MonerisPaymentProcessor,
                1 => DefaultData.StripePaymentProcessor,
                2 => DefaultData.IatsPaymentProcessor,
                _ => throw new NotSupportedException($"PaymentProcessorCode with value {paymentProcessorCode} not supported."),
            };

            var configuration = DefaultData.Configuration(processor);

            this.db.Add(processor);
            this.db.Add(configuration);
            this.db.Add(currency);

            var random   = new Random();
            var requests = Enumerable.Range(0, max).Select(x =>
            {
                var info = new PaymentInfo
                {
                    PaymentProcessor    = processor,
                    Configuration       = configuration,
                    TransactionCurrency = currency
                };

                switch (processor.PaymentGatewayType)
                {
                case PaymentGatewayCode.Moneris:
                    info.Input = CreateMonerisPaymentInput(info);
                    break;

                case PaymentGatewayCode.Iats:
                    info.Input = CreateIatsPaymentInput(info);
                    break;

                case PaymentGatewayCode.Stripe:
                    info.Input = CreateStripePaymentInput(info);
                    break;

                default:
                    break;
                }

                return(info);
            });

            return(requests);
        }