예제 #1
0
        public async Task <string> ProcessPayment(CardPayment payment)
        {
            var authCode = await rpcClient.MakePaymentAsync(payment);

            Console.WriteLine($"Payment Sent {payment.Name}, {payment.CardNumber}, ${payment.Amount}, code: {authCode}");
            return(authCode);
        }
예제 #2
0
        public async Task <PaymentResult> CreateCardPayment(CardPayment cardPayment)
        {
            var result = new PaymentResult();

            try
            {
                await _paymentsRepository.CreatePaymentRequest(cardPayment);

                result = await _foobarBankClient.CreatePayment(cardPayment);

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Exception occurred creating card payment Reference={cardPayment.Reference}");
                result = new PaymentResult()
                {
                    PaymentStatus = PaymentStatus.Error,
                    Reference     = cardPayment.Reference
                };
                return(result);
            }
            finally
            {
                await _paymentsRepository.UpdatePaymentResult(result);
            }
        }
예제 #3
0
        /// <summary>
        /// Добавить оплату картой
        /// </summary>
        public void AddNewCardPayment()
        {
            var cardPayment = new CardPayment()
            {
                Guid         = Guid.NewGuid(),
                PaymentDate  = DateTime.Now,
                Amount       = _orderPayView.CardAmount,
                CardNumber   = _orderPayView.CardNumber,
                Manual       = _orderPayView.CardInputManual,
                RNN          = _orderPayView.CardNumber,
                DocumentName = _orderPayView.CardPathToFile
            };

            _cardPayments.Add(cardPayment);

            if (!string.IsNullOrWhiteSpace(cardPayment.DocumentName))
            {
                _orderDocuments.Add(new OrderDocument(cardPayment.DocumentName, _orderPayView.CardFileStream));
            }

            var paymentRow = new PaymentRow(cardPayment);

            _orderPayView.AddPaymentToGrid(paymentRow);
            _orderPayView.CardAmount      = 0;
            _orderPayView.CardNumber      = string.Empty;
            _orderPayView.CardInputManual = false;
            _orderPayView.CardNumber      = string.Empty;
            _orderPayView.CardPathToFile  = string.Empty;

            MainController.RecalculatePayment();
        }
예제 #4
0
        static void Main(string[] args)
        {
            //Card Payment - with CITI Payment System
            Payment order = new CardPayment
            {
                PaymentSystem = new CitiPaymentSystem()
            };

            order.MakePayment();

            //Card Payment - with IDBI PaymentSystem
            Payment order2 = new CardPayment
            {
                PaymentSystem = new IDBIPaymentSystem()
            };

            order2.MakePayment();

            //NetBanking - with CitiPaymentSystem
            Payment order3 = new NetBankingPayment
            {
                PaymentSystem = new CitiPaymentSystem()
            };

            order3.MakePayment();

            Console.ReadKey();
        }
예제 #5
0
        public MainViewModel()
        {
            _coffeeStrength = Strength.Normal;
            _sugarAmount    = Amount.Normal;
            _milkAmount     = Amount.Normal;

            LogText = new ObservableCollection <string>();
            LogText.Add("Starting up...");
            LogText.Add("Done, what would you like to drink?");

            drinkFactory       = new DrinkFactory();
            paymentFactory     = new PaymentFactory();
            teaBlendRepository = new TeaBlendRepository();
            deserializer       = new Deserializer();


            Blends         = new List <string>(teaBlendRepository.BlendNames);
            KoffieSpecials = new List <string>();

            foreach (var item in deserializer.GetSpecialCoffees())
            {
                KoffieSpecials.Add(item.Naam);
            }

            card = (CardPayment)paymentFactory.CreatePayment("Card", 0, null);

            PaymentCardUsernames        = new ObservableCollection <string>(card.CashOncards.Keys);
            SelectedPaymentCardUsername = PaymentCardUsernames[0];
        }
예제 #6
0
        public IActionResult Add(CardPayment card)
        {
            Thread.Sleep(2000);
            var result = _paymentService.CardPaymentAdd(card);

            return(Ok(result));
        }
예제 #7
0
        static void Main(string[] args)
        {
            var bus = RabbitHutch.CreateBus("host=localhost");

            while (true)
            {
                var msg = Console.ReadLine();
                count++;
                if (count % 2 == 0)
                {
                    var message = new PurchaseOrder()
                    {
                        Amount          = DateTime.Now.Second,
                        CompanyName     = msg,
                        PaymentDayTerms = DateTime.Now.Millisecond,
                        PoNumber        = DateTime.Now.Day.ToString()
                    };
                    bus.Publish <IPayment>(message);
                }

                else
                {
                    var message = new CardPayment()
                    {
                        Amount         = DateTime.Now.Second,
                        CardHolderName = msg,
                        CardNumber     = DateTime.Now.Millisecond.ToString(),
                        ExpiryDate     = DateTime.Now.Day.ToString()
                    };
                    bus.Publish <IPayment>(message);
                }
            }
        }
예제 #8
0
        //public int Payment(OrderDetails details,ref string response)
        //{
        //    try
        //    {
        //        bool addressMatch = false;

        //        string responseError = string.Empty;
        //        if (!ValidateRequest(details,ref responseError))
        //        {
        //            response = responseError;
        //            return 400;
        //        }
        //        if (!string.IsNullOrEmpty(details.HPPAddressMatchIndicator) && details.HPPAddressMatchIndicator.ToLower() == "true")
        //        {
        //            bool.TryParse(details.HPPAddressMatchIndicator, out addressMatch);
        //        }
        //        // configure client, request and HPP settings
        //        var service = new HostedService(new GatewayConfig
        //        {
        //            MerchantId = _config.MerchantId,
        //            AccountId = _config.AccountId,
        //            SharedSecret = _config.SharedSecret,
        //            ServiceUrl = _config.ServiceUrl,
        //            SecretApiKey = details.SecretKey,
        //            HostedPaymentConfig = new HostedPaymentConfig
        //            {
        //                Version = _config.Version,
        //                PaymentButtonText = _config.PaymentButtonText
        //            }
        //        });

        //        // Add 3D Secure 2 Mandatory and Recommended Fields
        //        var hostedPaymentData = new HostedPaymentData
        //        {
        //            CustomerEmail = details.CustomerEmail,
        //            CustomerPhoneMobile = details.CustomerPhoneNum,
        //            AddressesMatch = addressMatch
        //        };

        //        var billingAddress = new Address
        //        {
        //            StreetAddress1 = details.BillingStreet1,
        //            StreetAddress2 = details.BillingStreet2,
        //            StreetAddress3 = details.BillingStreet3,
        //            City = details.BillingCity,
        //            PostalCode = details.BillingPostalCode,
        //            Country = details.BillingCountry
        //        };

        //        var shippingAddress = new Address
        //        {
        //            StreetAddress1 = details.ShippingStreet1,
        //            StreetAddress2 = details.ShippingStreet2,
        //            StreetAddress3 = details.ShippingStreet3,
        //            City = details.ShippingCity,
        //            State = details.ShippingState,
        //            PostalCode = details.ShippingPostalCode,
        //            Country = details.ShippingCountry,
        //        };

        //        try
        //        {
        //            String timeStamp = GetTimestamp(new DateTime());
        //            decimal amount = 0.0m;
        //            decimal.TryParse(details.Amount, out amount);
        //            string sha1HashCode = GetSha1HashCode(details,_config, timeStamp);

        //            var responseJson = service.Charge(amount)
        //               .WithCurrency(details.Currency)
        //               .WithHostedPaymentData(hostedPaymentData)
        //               .WithAddress(billingAddress, AddressType.Billing)
        //               .WithAddress(shippingAddress, AddressType.Shipping)
        //               .WithTimestamp(timeStamp)
        //               .WithTransactionId(sha1HashCode)
        //               .Serialize();
        //            response = responseJson;
        //            return 200;
        //        }

        //        catch (ApiException ex)
        //        {
        //            throw new Exception(ex.Message);
        //            // TODO: Add your error handling here
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }
        //    //return null;
        //}
        public int ProcessMessageMethod(OrderDetails details, ref string response)
        {
            int    responseCode  = 0;
            string responseError = string.Empty;

            try
            {
                if (!HelperClass.ValidateRequest(details, ref responseError))
                {
                    response = responseError;
                    return(400);
                }
                switch (details.PaymentMethod.ToUpper())
                {
                case "CARD":
                    CardPayment cp = new CardPayment(_config);
                    return(cp.ProcessPayment(details, ref response));

                case "PAYPAL":
                    PayPalPayment ppp = new PayPalPayment(_config);
                    return(ppp.ProcessPayment(details, ref response));
                    //case "APPLE-PAY":
                    //    CardPayment cp = new CardPayment(_config);
                    //    return cp.ApplePay(details, ref response);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(responseCode);
        }
예제 #9
0
        private static void LoadPaymentTypes(DalContext dalContext)
        {
            var cardPaymentPrice = new Price()
            {
                GrossAmount = 0,
                NetAmount   = 0,
                VatRate     = 8
            };
            var cardPayment = new CardPayment
            {
                ServiceFee = cardPaymentPrice,
                Name       = "Card payment"
            };

            var onlinePaymentPrice = new Price()
            {
                GrossAmount = 3,
                NetAmount   = 2.78m,
                VatRate     = 8
            };
            var onlinePayment = new OnlinePayment()
            {
                ServiceFee = onlinePaymentPrice,
                Name       = "Online payment"
            };

            dalContext.Prices.Add(cardPaymentPrice);
            dalContext.CardPayments.Add(cardPayment);

            dalContext.Prices.Add(onlinePaymentPrice);
            dalContext.OnlinePayments.Add(onlinePayment);

            dalContext.SaveChanges();
        }
        public IHttpActionResult MakePayment([FromBody] CardPayment payment)
        {
            string reply;

            try
            {
                /*
                 * We could just call in to the back end payment systems directly,
                 * but we still want to use messages to flow through the RabbitMQ queues.
                 * This will be achieved by using the remote procedure called Pattern
                 */

                RabbitMQDirectClient client = new RabbitMQDirectClient();
                client.CreateConnection();
                reply = client.MakePayment(payment);

                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(reply));
        }
예제 #11
0
        static void Main(string[] args)
        {
            Payment payment = new CardPayment();

            payment.PaymentSystem = new CityPaymentSystem();
            payment.MakePayment();

            payment.PaymentSystem = new IDBIPaymentSystem();
            payment.MakePayment();


            payment = new MobileBankingPayment();
            payment.PaymentSystem = new CityPaymentSystem();
            payment.MakePayment();

            payment.PaymentSystem = new IDBIPaymentSystem();
            payment.MakePayment();


            payment = new CASHPayment();
            payment.PaymentSystem = new CityPaymentSystem();
            payment.MakePayment();

            payment.PaymentSystem = new IDBIPaymentSystem();
            payment.MakePayment();


            Console.Read();
        }
예제 #12
0
        public string MakePayment(CardPayment payment)
        {
            _corrId = Guid.NewGuid().ToString();
            var props = _channel.CreateBasicProperties();

            props.ReplyTo       = _replyQueueName;
            props.CorrelationId = _corrId;

            _channel.BasicPublish("", "rpc_queue", props, payment.Serialize());

            consumer.Received += Consumer_Received;

            while (true)
            {
                consumer.Received += Consumer_Received;

                //var ea = _consumer.Queue.Dequeue();

                //if (ea.BasicProperties.CorrelationId != corrId) continue;

                //var authCode = Encoding.UTF8.GetString(ea.Body);
                //return authCode;
            }

            return(_authCode);
        }
        public string MakePayment(CardPayment payment)
        {
            // correleation id is useful when talking between micro services, we hence make sure we are recieving correct messages/replies
            var corrId = Guid.NewGuid().ToString();
            var props  = _channel.CreateBasicProperties();

            props.ReplyTo       = _replyQueueName;
            props.CorrelationId = corrId;

            // defaulting to default exchange
            _channel.BasicPublish("", "rpc_queue", props, payment.Serialize());

            // we made a payment then started wauiting for a response
            while (true)
            {
                var ea = _consumer.Queue.Dequeue();
                // checking that is the correct correlation id of the stuff that I just sent
                if (ea.BasicProperties.CorrelationId != corrId)
                {
                    continue;
                }

                var authCode = Encoding.UTF8.GetString(ea.Body);
                return(authCode);
            }
        }
        /// <summary>
        /// This method complete card payment
        /// </summary>
        /// <param name="cardPaymentModel"></param>
        /// <param name="cardPayment"></param>
        /// <returns></returns>
        private PaymentStatus CompleteCardPament(CardPaymentModel cardPaymentModel, CardPayment cardPayment)
        {
            PaymentStatus paymentStatus = new PaymentStatus();

            if (cardPayment != null)
            {
                if (cardPayment.Amount > cardPaymentModel.Amount)
                {
                    cardPayment.Amount = (cardPayment.Amount - cardPaymentModel.Amount);
                    this.cardPaymentRepository.Update(cardPayment);
                    unitOfWork.Save();
                    paymentStatus.Status = true;
                }
                else
                {
                    paymentStatus.Error = InsufficientFunds;
                }
            }
            else
            {
                paymentStatus.Error = CardErrorMessage;
            }

            return(paymentStatus);
        }
        //this displayes the stripe payment view
        //it sends StripePublishKey information to the front allong with the order total and order Id
        public ActionResult Index(CardPayment p)
        {
            ViewBag.StripePublishKey = ConfigurationManager.AppSettings["stripePublishableKey"];

            ViewBag.Total   = p.Total;
            ViewBag.OrderId = p.OrderId;
            return(View());
        }
예제 #16
0
        public override string CardIDBI(Context context)
        {
            Payment order = new CardPayment();

            order._IPaymentSystem = new CitiPaymentSystem();
            order.MakePayment();
            return("");
        }
예제 #17
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="cardPayment">Оплата</param>
 public PaymentRow(CardPayment cardPayment)
 {
     this.Guid         = cardPayment.Guid;
     this.PaymentDate  = cardPayment.PaymentDate;
     this.Type         = ControllerResources.OrderPayControl_CardPaymentType;
     this.Amount       = cardPayment.Amount;
     this.IsManual     = cardPayment.Manual;
     this.DocumentName = cardPayment.DocumentName;
 }
예제 #18
0
        public void Run(APIGatewayProxyRequest request, APIGatewayProxyResponse response, FinanceUser user)
        {
            var cardPayment = new CardPayment(new ConsoleLogger(), Configuration.CLOVER_MI_PUEBLO_PRIVATE_TOKEN);
            var start       = request.QueryStringParameters.ContainsKey("start") ? request.QueryStringParameters["start"] : string.Empty;
            var end         = request.QueryStringParameters.ContainsKey("end") ? request.QueryStringParameters["end"] : string.Empty;
            var income      = cardPayment.GetCardCharges(start, end);

            response.Body = JsonConvert.SerializeObject(income);
        }
 private int HandlePayment(CardPayment payment)
 {
     using (var scope = serviceScopeFactory.CreateScope())
     {
         var cardPaymentService = scope.ServiceProvider.GetRequiredService <ICardPaymentService>();
         cardPaymentService.MakePayment(payment);
     }
     return(random.Next(100000, 999999));
 }
예제 #20
0
        public async Task SaveCardPaymentAsync(CardPayment cardPayment)
        {
            using (var context = ContextFactory.CreateDbContext(ConnectionString))
            {
                await context.AddAsync(cardPayment).ConfigureAwait(false);

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
예제 #21
0
        public ActionResult ProcessCardPayment(CardPayment paymentDetail)
        {
            //Redirect Based on Business Rules
            //PaymentUtils.PrePageLoadRedirectUrlsAccountsBalance();

            CardPaymentHelper cardPaymentRepo = new CardPaymentHelper();
            var model = cardPaymentRepo.SubmitCardPayment(paymentDetail);

            return(View(model));
        }
예제 #22
0
        public ActionResult CardPayments(CardPayment paymentDetails)
        {
            //BlueGreenContext bgContext = new BlueGreenContext();
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now);
            Response.Expires = 0;

            CardPaymentHelper cardPaymentRepo = new CardPaymentHelper();
            var model = cardPaymentRepo.SubmitCardPayment(paymentDetails);

            return(View(paymentDetails));
        }