Exemplo n.º 1
0
        private Payment createEETPaymentObject(GPConnector connector, BasePayment baseEETPayment)
        {
            Payment result = null;

            try
            {
                result = connector.GetAppToken().CreatePayment(baseEETPayment);
                Assert.NotNull(result);
                Assert.NotEqual(0, result.Id);

                Console.WriteLine("EET Payment id: {0}", result.Id);
                Console.WriteLine("EET Payment gw_url: {0}", result.GwUrl);
                Console.WriteLine("EET Payment instrument: {0}", result.PaymentInstrument);
                Console.WriteLine(baseEETPayment.Eet);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Create EET payment ERROR");
                var err  = exception.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }

                throw;
            }

            return(result);
        }
Exemplo n.º 2
0
        //[TestMethod()]
        public void GPConnectorTestCreatePreAuthorizedPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            BasePayment basePayment = CreatePaymentTests.createBasePayment();

            basePayment.PreAuthorization = true;

            try
            {
                Payment result = connector.GetAppToken().CreatePayment(basePayment);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);

                Console.WriteLine("Payment id: {0}", result.Id);
                Console.WriteLine("Payment gw_url: {0}", result.GwUrl);
                Console.WriteLine("Payment instrument: {0}", result.PaymentInstrument);
                Console.WriteLine("PreAuthorization: {0}", result.PreAuthorization);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("PreAuthorized payment ERROR");
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
        public void GPConnectorTestCreatePayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            connector.IncomingDataEventHandler += incomingDataListener;

            BasePayment basePayment = createBasePayment();

            try
            {
                Payment result = connector.GetAppToken().CreatePayment(basePayment);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);

                Console.WriteLine("Payment id: {0}", result.Id);
                Console.WriteLine("Payment gw_url: {0}", result.GwUrl);
                Console.WriteLine("Payment instrument: {0}", result.PaymentInstrument);
                Console.WriteLine(result.Payer.Contact);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Create payment ERROR");
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Exemplo n.º 4
0
        public async Task <Payment> CreatePaymentAsync(BasePayment payment)
        {
            var restRequest = CreateRestRequest(@"/payments/payment");

            restRequest.AddJsonBody(payment);
            var response = await Client.ExecuteTaskAsync(restRequest);

            return(await Task.Factory.StartNew(() => ProcessResponse <Payment>(response)));
        }
Exemplo n.º 5
0
        /// <exception cref="GPClientException"></exception>
        public Payment CreatePayment(BasePayment payment)
        {
            var restRequest = CreateRestRequest(@"/payments/payment");

            restRequest.AddJsonBody(payment);
            var response = Client.Execute(restRequest);

            return(ProcessResponse <Payment>(response));
        }
Exemplo n.º 6
0
 public override string ToString()
 {
     return("Base paymente: "
            + BasePayment.ToString("F2", CultureInfo.InvariantCulture)
            + "\nTax: "
            + Tax.ToString("F2", CultureInfo.InvariantCulture)
            + "\nTotal payment: "
            + TotalPayment.ToString("F2", CultureInfo.InvariantCulture));
 }
Exemplo n.º 7
0
        /// <exception cref="GPClientException"></exception>
        public Payment CreatePayment(BasePayment payment)
        {
            var restRequest = CreateRestRequest(@"/payments/payment", "application/json");

            var jsonData = serializeToJson(payment);

            restRequest.AddParameter("application/json", jsonData, ParameterType.RequestBody);

            var response = Client.Execute(restRequest);

            return(ProcessResponse <Payment>(response));
        }
Exemplo n.º 8
0
        public async Task <Payment> CreatePaymentAsync(BasePayment payment)
        {
            var restRequest = CreateRestRequest(@"/payments/payment", "application/json");

            var jsonData = serializeToJson(payment);

            restRequest.AddParameter("application/json", jsonData, ParameterType.RequestBody);

            var response = await Client.ExecuteTaskAsync(restRequest);

            return(await Task.Factory.StartNew(() => ProcessResponse <Payment>(response)));
        }
Exemplo n.º 9
0
        public Payment CreatePaidOnDemandPayment(GPConnector connector)
        {
            var recurrence = new Recurrence()
            {
                Cycle  = RecurrenceCycle.ON_DEMAND,
                DateTo = DateTime.Now.AddYears(1),
            };

            var payment = new BasePayment();

            payment.Target = new Target
            {
                GoId = 8156260189,
                Type = Target.TargetType.ACCOUNT
            };
            payment.Amount = 1;

            payment.Items = new List <OrderItem>
            {
                new OrderItem
                {
                    Amount = 1,
                    Count  = 1,
                    Name   = "Iniciační opakovaná platba",
                }
            };

            payment.Callback = new Callback
            {
                NotificationUrl = "http://www.test.cz",
                ReturnUrl       = "http://www.test.cz"
            };

            payment.Recurrence = recurrence;

            payment.Payer = new Payer
            {
                Contact = new PayerContact
                {
                    Email = "*****@*****.**"
                },
                DefaultPaymentInstrument = PaymentInstrument.PAYMENT_CARD
            };

            var result = connector.CreatePayment(payment);

            return(result);
        }
Exemplo n.º 10
0
        public void GPConnectorTestCreatePayment()
        {
            var         connector = new GPConnector(API_URL, CLIENT_ID, CLIENT_SECRET);
            BasePayment payment   = new BasePayment()
            {
                Currency    = Currency.EUR,
                Lang        = "ENG",
                OrderNumber = "789456167879",
                Amount      = 7500,
                Target      = new Target()
                {
                    GoId = GOID,
                    Type = Target.TargetType.ACCOUNT
                },
                Callback = new Callback()
                {
                    NotificationUrl = "https://eshop798456.com/notify",
                    ReturnUrl       = "Https://eshop78945.com/return"
                },
                Recurrence = new Recurrence()
                {
                    Cycle  = RecurrenceCycle.ON_DEMAND,
                    DateTo = new DateTime(2020, 12, 12)
                },
                Payer = new Payer()
                {
                    Contact = new PayerContact()
                    {
                        Email = "*****@*****.**"
                    },
                    DefaultPaymentInstrument = PaymentInstrument.PAYMENT_CARD
                }
            };

            try {
                Payment result = connector.GetAppToken().CreatePayment(payment);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);
            } catch (GPClientException exception)
            {
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Exemplo n.º 11
0
        //[TestMethod()]
        public void GPConnectorTestCreateRecurrentEETPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            BasePayment baseEETPayment = createEETBasePayment();

            /*
             * Recurrence recurrence = new Recurrence()
             * {
             *  Cycle = RecurrenceCycle.WEEK,
             *  Period = 1,
             *  DateTo = new DateTime(2018, 4, 1)
             * };
             * baseEETPayment.Recurrence = recurrence;
             */


            Recurrence onDemandRecurrence = new Recurrence()
            {
                Cycle  = RecurrenceCycle.ON_DEMAND,
                DateTo = new DateTime(2018, 4, 1)
            };

            baseEETPayment.Recurrence = onDemandRecurrence;


            EET eet = new EET()
            {
                CelkTrzba = 139950,
                ZaklDan1  = 99165,
                Dan1      = 20825,
                ZaklDan2  = 17357,
                Dan2      = 2603,
                Mena      = Currency.CZK
            };

            baseEETPayment.Eet = eet;

            Payment result = createEETPaymentObject(connector, baseEETPayment);

            Console.WriteLine(result.Recurrence);
        }
Exemplo n.º 12
0
        //[TestMethod()]
        public void GPConnectorTestCreateEETPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            BasePayment baseEETPayment = createEETBasePayment();

            EET eet = new EET()
            {
                CelkTrzba = 139950,
                ZaklDan1  = 99165,
                Dan1      = 20825,
                ZaklDan2  = 17357,
                Dan2      = 2603,
                Mena      = Currency.CZK
            };

            baseEETPayment.Eet = eet;

            Payment result = createEETPaymentObject(connector, baseEETPayment);
        }
Exemplo n.º 13
0
        void Run()
        {
            var hdr = new Header();

            AppendToOutput(hdr.ToFixedTextLine());

            BasePayment pymt = null;
            BaseOrigPartyNameAddress origNameAddr = null;
            BaseRecvPartyNameAddress recvNameAddr = null;

            //var aplist = AP.SqlQueryAp;
            using (var db = new AppDbContext()) {
                foreach (var ap in db.APs.ToArray())
                {
                    switch (ap.PaymentMode)
                    {
                    case PaymentMode.Check:
                        pymt         = new CheckPayment(ap);
                        origNameAddr = new CheckOrigPartyNameAddress(ap);
                        recvNameAddr = new CheckRecvPartyNameAddress(ap);
                        break;

                    case PaymentMode.Eft:
                        pymt         = new EftPayment(ap);
                        origNameAddr = new EftOrigPartyNameAddress(ap);
                        recvNameAddr = new EftRecvPartyNameAddress(ap);
                        break;

                    default:
                        pymt         = new UnknownPayment(ap);
                        origNameAddr = new OtherOrigPartyNameAddress(ap);
                        recvNameAddr = new OtherRecvPartyNameAddress(ap);
                        break;
                    }
                    AppendToOutput(pymt.ToFixedTextLine());
                    AppendToOutput(origNameAddr.ToFixedTextLine());
                    AppendToOutput(recvNameAddr.ToFixedTextLine());
                }
            }
            WriteToOutput(linesOut);
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            apiService = new APIService();

            int n = -1;

            while (n != 4)
            {
                Console.WriteLine("\n\nMenu\n1.Make a Payment\n2.Fetch payment using UId\n3.Fetch All Payments\n4.Exit\nPlease note that while fetching the card number and cvv the details have been encrypted.\n");
                Console.WriteLine("Enter your choice ");
                string choice = Console.ReadLine();
                Int32.TryParse(choice, out n);
                switch (n)
                {
                case 1:
                    IPayment pymt = new BasePayment();
                    pymt.TakeInput();
                    MakePayment(pymt);
                    break;

                case 2:
                    Console.WriteLine("Enter uid to search");
                    string uid = Console.ReadLine();
                    GetPaymentWithUid(uid);
                    break;

                case 3:
                    GetAllPayments();
                    break;

                case 4:
                    break;

                default:
                    Console.WriteLine("Invalid Input . Please try agaian.");
                    break;
                }
            }
        }
        public void GPConnectorTestCreateRecurrentPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            BasePayment basePayment = CreatePaymentTests.createBasePayment();

            Recurrence recurrence = new Recurrence()
            {
                Cycle  = RecurrenceCycle.WEEK,
                Period = 1,
                DateTo = new DateTime(2018, 4, 1)
            };

            basePayment.Recurrence = recurrence;

            try
            {
                Payment result = connector.GetAppToken().CreatePayment(basePayment);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);

                Console.WriteLine("Payment id: {0}", result.Id);
                Console.WriteLine("Payment gw_url: {0}", result.GwUrl);
                Console.WriteLine("Payment instrument: {0}", result.PaymentInstrument);
                Console.WriteLine("Recurrence: {0}", result.Recurrence);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Recurrent payment ERROR");
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Exemplo n.º 16
0
        public static BasePayment createBaseCardTokenPayment()
        {
            List <AdditionalParam> addParams = new List <AdditionalParam>();

            addParams.Add(new AdditionalParam()
            {
                Name = "AdditionalKey", Value = "AdditionalValue"
            });

            List <OrderItem> addItems = new List <OrderItem>();

            addItems.Add(new OrderItem()
            {
                Name = "First Item", Amount = 4000, Count = 1
            });

            List <PaymentInstrument> allowedInstruments = new List <PaymentInstrument>();

            allowedInstruments.Add(PaymentInstrument.PAYMENT_CARD);

            BasePayment basePayment = new BasePayment()
            {
                Callback = new Callback()
                {
                    ReturnUrl       = @"https://eshop123.cz/return",
                    NotificationUrl = @"https://eshop123.cz/notify"
                },

                OrderNumber      = "4321",
                Amount           = 4000,
                Currency         = Currency.CZK,
                OrderDescription = "4321Description",

                Lang = "CS",

                AdditionalParams = addParams,

                Items = addItems,

                Target = new Target()
                {
                    GoId = TestUtils.GOID,
                    Type = Target.TargetType.ACCOUNT
                },

                Payer = new Payer()
                {
                    AllowedPaymentInstruments = allowedInstruments,
                    DefaultPaymentInstrument  = PaymentInstrument.PAYMENT_CARD,
                    Contact = new PayerContact()
                    {
                        FirstName = "Jarda",
                        LastName  = "Sokol",
                        Email     = "*****@*****.**"
                    },
                    AllowedCardToken = "VUHweq2TUuQpgU6UaD4c+123xzUwTBXiZK7jHhW7rhSbUb07XcG69Q0cwTxTYvBG3qyym3sJ5zphQS4vL0kEHvvinxXYMqkZtx4rBA9mtZj9JSpy4cIHkXnH3gR+i6CoQ4M+zI2EXGJ+TQ==",
                    // VerifyPin = ""
                }
            };

            return(basePayment);
        }
 public BasePaymentViewModel(ProfileViewModel profile, BasePayment model)
     : base(profile, model)
 {
     Due     = new DueInfoViewModel(model.Due);
     Payment = model.Payment;
 }
Exemplo n.º 18
0
        public ActionResult BookingRoomDateView(BookingRoomDateViewModles model)
        {
            using (var context = HttpContext.GetOwinContext().Get <ApplicationDbContext>())
            {
                var DepartureDate = model.DateArrival.AddDays(model.NoOfDaysStayed);
                var query         =
                    //(
                    from Room in context.Rooms
                    join Booking in context.Bookings
                    on Room.RoomId equals Booking.Room.RoomId into RoomBooking
                    from Booking in RoomBooking.DefaultIfEmpty()
                    select new
                {
                    FoundRoom    = Room,
                    FoundBooking = Booking
                };
                //).FirstOrDefault();

                Room foundRoom = null;

                foreach (var rom in query)
                {
                    if (rom.FoundRoom.Bookings == null)
                    {
                        foundRoom = rom.FoundRoom;
                        break;
                    }
                    if (rom.FoundBooking.ArrivalDate > model.DateArrival.AddDays(model.NoOfDaysStayed) ||
                        rom.FoundBooking.DepartureDate < model.DateArrival)
                    {
                        foundRoom = rom.FoundRoom;
                        break;
                    }
                }

                if (foundRoom == null)
                {
                    return(RedirectToAction("NoRoomFound"));
                }

                var newBooking = new Booking
                {
                    Price         = foundRoom.Price,
                    Payed         = false,
                    ArrivalDate   = model.DateArrival,
                    DepartureDate = model.DateArrival.AddDays(model.NoOfDaysStayed),
                    AadOns        = "",
                    ChechIn       = 0,
                    ChechOut      = 0,

                    ApplicationUser = UserManager.FindById(User.Identity.GetUserId()),
                    Room            = foundRoom
                };

                var             pay        = new BasePayment(newBooking);
                LoyaltyDiscount decorator1 = new LoyaltyDiscount(pay);

                if (foundRoom.Bookings == null)
                {
                    foundRoom.Bookings = new List <Booking>
                    {
                        newBooking
                    };

                    context.SaveChanges();
                }
                else
                {
                    foundRoom.Bookings.Add(newBooking);
                }


                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public static BasePayment createBasePayment()
        {
            List <AdditionalParam> addParams = new List <AdditionalParam>();

            addParams.Add(new AdditionalParam()
            {
                Name = "AdditionalKey", Value = "AdditionalValue"
            });

            List <OrderItem> addItems = new List <OrderItem>();

            addItems.Add(new OrderItem()
            {
                Name = "First Item", Amount = 1700, Count = 1
            });

            List <PaymentInstrument> allowedInstruments = new List <PaymentInstrument>();

            allowedInstruments.Add(PaymentInstrument.BANK_ACCOUNT);
            allowedInstruments.Add(PaymentInstrument.PAYMENT_CARD);

            List <string> swifts = new List <string>();

            swifts.Add("GIBACZPX");
            swifts.Add("RZBCCZPP");

            /*
             * PayerPaymentCard payCard = new PayerPaymentCard()
             * {
             *  CardNumber = "4444444444444448",
             *  CardExpiration = "1909",
             *  CardBrand = "VISA",
             *  CardIssuerCountry = "CZE",
             *  CardIssuerBank = "ČESKÁ SPOŘITELNA, A.S."
             * };
             */

            BasePayment basePayment = new BasePayment()
            {
                Callback = new Callback()
                {
                    ReturnUrl       = @"https://eshop123.cz/return",
                    NotificationUrl = @"https://eshop123.cz/notify"
                },

                OrderNumber      = "4321",
                Amount           = 1700,
                Currency         = Currency.CZK,
                OrderDescription = "4321Description",

                Lang = "CS",

                AdditionalParams = addParams,

                Items = addItems,

                Target = new Target()
                {
                    GoId = TestUtils.GOID,
                    Type = Target.TargetType.ACCOUNT
                },

                Payer = new Payer()
                {
                    AllowedPaymentInstruments = allowedInstruments,
                    AllowedSwifts             = swifts,
                    //DefaultPaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    //PaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    Contact = new PayerContact()
                    {
                        Email = "*****@*****.**"
                    }
                }
            };

            return(basePayment);
        }
        public static BasePayment createBasePayment()
        {
            var addParams = new List <AdditionalParam>();

            addParams.Add(new AdditionalParam {
                Name = "AdditionalKey", Value = "AdditionalValue"
            });

            var addItems = new List <OrderItem>();

            addItems.Add(new OrderItem {
                Name = "First Item", Amount = 1700, Count = 1
            });

            var allowedInstruments = new List <PaymentInstrument>();

            allowedInstruments.Add(PaymentInstrument.BANK_ACCOUNT);
            allowedInstruments.Add(PaymentInstrument.PAYMENT_CARD);

            var swifts = new List <string>();

            swifts.Add("GIBACZPX");
            swifts.Add("RZBCCZPP");

            var basePayment = new BasePayment
            {
                Callback = new Callback
                {
                    ReturnUrl       = @"https://eshop123.cz/return",
                    NotificationUrl = @"https://eshop123.cz/notify"
                },

                OrderNumber      = "4321",
                Amount           = 1700,
                Currency         = Currency.CZK,
                OrderDescription = "4321Description",

                Lang = "CS",

                AdditionalParams = addParams,

                Items = addItems,

                Target = new Target
                {
                    GoId = TestUtils.GOID,
                    Type = Target.TargetType.ACCOUNT
                },

                Payer = new Payer
                {
                    AllowedPaymentInstruments = allowedInstruments,
                    AllowedSwifts             = swifts,
                    //DefaultPaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    //PaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    Contact = new PayerContact
                    {
                        Email = "*****@*****.**"
                    }
                }
            };

            return(basePayment);
        }
Exemplo n.º 21
0
        private BasePayment createEETBasePayment()
        {
            var addParams = new List <AdditionalParam>();

            addParams.Add(new AdditionalParam {
                Name = "AdditionalKey", Value = "AdditionalValue"
            });

            var addItems = new List <OrderItem>();

            addItems.Add(new OrderItem
            {
                Name       = "Pocitac Item1",
                Amount     = 119990,
                Count      = 1,
                VatRate    = VatRate.RATE_4,
                ItemType   = ItemType.ITEM,
                Ean        = "1234567890123",
                ProductURL = @"https://www.eshop123.cz/pocitac"
            });
            addItems.Add(new OrderItem
            {
                Name       = "Oprava Item2",
                Amount     = 19960,
                Count      = 1,
                VatRate    = VatRate.RATE_3,
                ItemType   = ItemType.ITEM,
                Ean        = "1234567890189",
                ProductURL = @"https://www.eshop123.cz/pocitac/oprava"
            });

            var allowedInstruments = new List <PaymentInstrument>();

            allowedInstruments.Add(PaymentInstrument.BANK_ACCOUNT);
            allowedInstruments.Add(PaymentInstrument.PAYMENT_CARD);

            var swifts = new List <string>();

            swifts.Add("GIBACZPX");
            swifts.Add("RZBCCZPP");

            var baseEETPayment = new BasePayment
            {
                Callback = new Callback
                {
                    ReturnUrl       = @"https://eshop123.cz/return",
                    NotificationUrl = @"https://eshop123.cz/notify"
                },

                OrderNumber      = "EET4321",
                Amount           = 139950,
                Currency         = Currency.CZK,
                OrderDescription = "EET4321Description",

                Lang = "CS",

                AdditionalParams = addParams,

                Items = addItems,

                Target = new Target
                {
                    GoId = TestUtils.GOID_EET,
                    Type = Target.TargetType.ACCOUNT
                },

                Payer = new Payer
                {
                    AllowedPaymentInstruments = allowedInstruments,
                    AllowedSwifts             = swifts,
                    //DefaultPaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    //PaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
                    Contact = new PayerContact
                    {
                        Email = "*****@*****.**"
                    }
                }
            };

            return(baseEETPayment);
        }