Ejemplo n.º 1
0
        public void GPConnectorTestEETPReceiptFindByFilter()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            var filter = new EETReceiptFilter
            {
                DateFrom = new DateTime(2017, 3, 2),
                DateTo   = new DateTime(2017, 4, 2),
                IdProvoz = 11
            };

            try
            {
                var receipts = connector.GetAppToken().FindEETReceiptsByFilter(filter);

                foreach (var currReceipt in receipts)
                {
                    Console.WriteLine(currReceipt);
                }
                Console.WriteLine(receipts.Count);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("EET Receipt by filter ERROR");
                var err  = ex.Error;
                var 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);

            var basePayment = createBasePayment();

            try
            {
                var result = connector.GetAppToken().CreatePayment(basePayment);
                Assert.NotNull(result);
                Assert.NotEqual(0, 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;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void GPConnectorTestEETPaymentRefund()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            var refundedItems = new List <OrderItem>();

            refundedItems.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"
            });
            refundedItems.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 eet = new EET
            {
                CelkTrzba = 139950,
                ZaklDan1  = 99165,
                Dan1      = 20825,
                ZaklDan2  = 17357,
                Dan2      = 2603,
                Mena      = Currency.CZK
            };

            var refundObject = new RefundPayment
            {
                Amount = 139950,
                Items  = refundedItems,
                Eet    = eet
            };

            try
            {
                var refundEETPayment = connector.GetAppToken().RefundPayment(3049250113, refundObject);
                Console.WriteLine("EET refund result: {0}", refundEETPayment);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("EET Payment refund ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 5
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 GPConnectorTestStatus()
        {
            long id = 3049249619;

            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            try
            {
                var payment = connector.GetAppToken().PaymentStatus(id);
                Assert.NotEqual(0, payment.Id);

                Console.WriteLine("Payment id: {0}", payment.Id);
                Console.WriteLine("Payment gw_url: {0}", payment.GwUrl);
                Console.WriteLine("Payment state: {0}", payment.State);
                Console.WriteLine("Payment instrument: {0}", payment.PaymentInstrument);
                Console.WriteLine("PreAuthorization: {0}", payment.PreAuthorization);
                Console.WriteLine("Recurrence: {0}", payment.Recurrence);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Payment status ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 7
0
        public void GPConnectorTestCardTokenPaymentStatus()
        {
            long id = 3052269740;

            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            try
            {
                var payment = connector.GetAppToken().PaymentStatus(id);
                Assert.IsNotNull(payment.Id);

                Console.WriteLine("Payment id: {0}", payment.Id);
                Console.WriteLine("Payment gw_url: {0}", payment.GwUrl);
                Console.WriteLine("Payment state: {0}", payment.State);
                Console.WriteLine("PayerCard - card token: {0}", payment.Payer.PaymendCard.CardToken);
                Console.WriteLine("Payer 3DS Result: {0}", payment.Payer.PaymendCard.ThreeDResult);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Payment status ERROR");
                var      err  = ex.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 8
0
        public void GPConnectorTestEETPReceiptFindByPaymentId()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            try
            {
                var receipts = connector.GetAppToken().GetEETReceiptByPaymentId(3049205133);

                foreach (var currReceipt in receipts)
                {
                    Console.WriteLine(currReceipt);
                }
                Console.WriteLine(receipts.Count);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("EET Receipt by payment ID ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 9
0
        public GPConnector Create(GoPayBaseModel model)
        {
            var connector = new GPConnector(_config.GoPayApi, model.ClientId, model.ClientSecret);

            connector.GetAppToken();

            return(connector);
        }
Ejemplo n.º 10
0
        public void GPConnectorTest()
        {
            var connector = new GPConnector(API_URL, CLIENT_ID, CLIENT_SECRET);

            connector.GetAppToken();

            Assert.IsNotNull(connector.AccessToken);
            Assert.IsNotNull(connector.AccessToken.Token);
        }
        public void GPConnectorTest()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            connector.GetAppToken();

            Console.WriteLine("Token expires in: {0}", connector.AccessToken.ExpiresIn);

            Assert.NotNull(connector.AccessToken);
            Assert.NotNull(connector.AccessToken.Token);
        }
Ejemplo n.º 12
0
        public void GPConnectorTestNextOnDemandEET()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            try
            {
                var nextPayment = new NextPayment
                {
                    OrderNumber      = "EETOnDemand4321",
                    Amount           = 2000,
                    Currency         = Currency.CZK,
                    OrderDescription = "EETOnDemand4321Description"
                };
                nextPayment.Items.Add(new OrderItem
                {
                    Name       = "OnDemand Prodlouzena zaruka",
                    Amount     = 2000,
                    Count      = 1,
                    VatRate    = VatRate.RATE_4,
                    ItemType   = ItemType.ITEM,
                    Ean        = "12345678901234",
                    ProductURL = @"https://www.eshop123.cz/pocitac/prodlouzena_zaruka"
                });

                var eet = new EET
                {
                    CelkTrzba = 2000,
                    ZaklDan1  = 1580,
                    Dan1      = 420,
                    Mena      = Currency.CZK
                };
                nextPayment.Eet = eet;

                var onDemandEETPayment = connector.GetAppToken().CreateRecurrentPayment(3049250282, nextPayment);

                Console.WriteLine("OnDemand payment id: {0}", onDemandEETPayment.Id);
                Console.WriteLine("OnDemand payment gw_url: {0}", onDemandEETPayment.GwUrl);
                Console.WriteLine("OnDemand EET Payment instrument: {0}", onDemandEETPayment.PaymentInstrument);
                Console.WriteLine("OnDemand recurrence: {0}", onDemandEETPayment.Recurrence);
                Console.WriteLine("OnDemand amount: {0}", onDemandEETPayment.Amount);
                Console.Write(onDemandEETPayment.EetCode);
                Console.WriteLine(nextPayment.Eet);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Creating next on demand EET payment ERROR");
                var err  = exception.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 13
0
        public void GPConnectorTestStatus()
        {
            long id        = 3044158975;
            var  connector = new GPConnector(API_URL, CLIENT_ID, CLIENT_SECRET);

            try {
                var payment = connector.GetAppToken().PaymentStatus(id);
                Assert.IsNotNull(payment.Id);
            } catch (GPClientException ex)
            {
                //
            }
        }
Ejemplo n.º 14
0
        public Payment NextPayment(GPConnector connector, long IdOfPaidOnDemandPayment, NextPayment nextPayment)
        {
            nextPayment.Items = new List <OrderItem>
            {
                new OrderItem
                {
                    Amount = nextPayment.Amount,
                    Count  = 1,
                    Name   = "Opakovaná platba",
                }
            };

            return(connector.CreateRecurrentPayment(IdOfPaidOnDemandPayment, nextPayment));
        }
Ejemplo n.º 15
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)
                {
                    //
                }
            }
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        public void GPConnectorTestCreateRecurrentEETPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            var baseEETPayment = createEETBasePayment();

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


            var onDemandRecurrence = new Recurrence
            {
                Cycle  = RecurrenceCycle.ON_DEMAND,
                DateTo = DateTime.Today.AddDays(1)
            };

            baseEETPayment.Recurrence = onDemandRecurrence;


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

            baseEETPayment.Eet = eet;

            var result = createEETPaymentObject(connector, baseEETPayment);

            Console.WriteLine(result.Recurrence);
        }
Ejemplo n.º 18
0
        //  [TestMethod()]
        public void GPConnectorTestRefund()
        {
            var  connector = new GPConnector(API_URL, CLIENT_ID, CLIENT_SECRET);
            long id        = 3044158975;

            try {
                var result = connector.GetAppToken().RefundPayment(id, 7500);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);
            }
            catch (GPClientException exception)
            {
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //Handle
                }
            }
        }
Ejemplo n.º 19
0
        public void GPConnectorTestCreateEETPayment()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID_EET, TestUtils.CLIENT_SECRET_EET);

            var baseEETPayment = createEETBasePayment();

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

            baseEETPayment.Eet = eet;

            var result = createEETPaymentObject(connector, baseEETPayment);
        }
        public void GPConnectorTestStatementGenerating()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            var accountStatement = new AccountStatement
            {
                DateFrom = new DateTime(2017, 1, 1),
                DateTo   = new DateTime(2017, 2, 27),
                GoID     = TestUtils.GOID,
                Currency = Currency.CZK,
                Format   = StatementGeneratingFormat.CSV_A
            };

            try
            {
                var statement = connector.GetAppToken().GetStatement(accountStatement);
                Assert.NotNull(statement);

                var content = Encoding.UTF8.GetString(statement);

                Console.WriteLine("Content of Array to string: {0}", content);
                Console.WriteLine(
                    "----------------------------------------------------------------------------------------");

                Console.Write("Byte content: ");
                for (var i = 0; i < statement.Length; i++)
                {
                    Console.Write(" {0}", statement[i]);
                }
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Generating account statement ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 21
0
        //[TestMethod()]
        public void GPConnectorTestGetSupercashCoupon()
        {
            var  connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
            long couponId  = 100154175;

            try
            {
                SupercashPayment result = connector.GetAppToken().GetSupercashCoupon(couponId);
                Assert.IsNotNull(result);
                Console.WriteLine(result.ToString());
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Get Supercash Coupon ERROR");
                var      err  = ex.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 22
0
        public void GPConnectorTestGetSupercashCouponBatchStatus()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
            var batchId   = 961667719;

            try
            {
                var result = connector.GetAppToken().GetSupercashCouponBatchStatus(batchId);
                Assert.NotNull(result);
                Console.WriteLine(result.ToString());
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Get Supercash Coupon Batch Status ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 23
0
        public void GPConnectorTestCreateSupercashCoupon()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            var couponRequest = new SupercashCouponRequest
            {
                GoId             = TestUtils.GOID,
                SubType          = SubType.POSTPAID,
                CustomId         = "ID-123457",
                Amount           = 100,
                OrderNumber      = "1",
                OrderDescription = "Supercash Coupon Test",
                BuyerEmail       = "*****@*****.**",
                BuyerPhone       = "+420777123456",
                DateValidTo      = new DateTime(2018, 12, 31),
                NotificiationUrl = "http://www.example-notify.cz/supercash"
            };

            try
            {
                var result = connector.GetAppToken().CreateSupercashCoupon(couponRequest);
                Assert.NotNull(result);

                Console.WriteLine("SC coupon id: {0}", result.SupercashCouponId);
                Console.WriteLine("SC custom id: {0}", result.CustomId);
                Console.WriteLine("SC coupon number: {0}", result.SupercashNumber);
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Create Supercash Coupon ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 24
0
        public void GPConnectorTestFindSupercashCoupons()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
            //long[] paymentSessionIds = new long[] { 3050857992, 3050858018 };
            long paymentSessionIds = 3050857992;

            try
            {
                var result = connector.GetAppToken().FindSupercashCoupons(TestUtils.GOID, paymentSessionIds);
                Assert.NotNull(result);
                Console.WriteLine(result.ToString());
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("Find Supercash Coupons ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
        public void GPConnectorTestVoidAuthorization()
        {
            var  connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
            long id        = 3049249125;

            try
            {
                var result = connector.GetAppToken().VoidAuthorization(id);
                Assert.NotEqual(0, result.Id);

                Console.WriteLine("Void Authorization result: {0}", result);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Void authorization ERROR");
                var err  = exception.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //Handle
                }
            }
        }
        public void GPConnectorTestPaymentInstrumentRoot()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            try
            {
                var instrumentsList = connector.GetAppToken().GetPaymentInstruments(TestUtils.GOID, Currency.CZK);
                Assert.NotNull(instrumentsList);

                Console.WriteLine("List of enabled payment instruments for shop with go_id: {0} - OK", TestUtils.GOID);
                Console.WriteLine(instrumentsList.ToString());
            }
            catch (GPClientException ex)
            {
                Console.WriteLine("List of enabled payment instruments ERROR");
                var err  = ex.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
Ejemplo n.º 27
0
        public void GPConnectorTestCapturePayment()
        {
            var  connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
            long id        = 3049249190;

            try
            {
                var result = connector.GetAppToken().CapturePayment(id);
                Assert.IsNotNull(result.Id);

                Console.WriteLine("Capture payment result: {0}", result);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Capture payment ERROR");
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //Handle
                }
            }
        }
        public void GPConnectorTestOnDemand()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            var basePayment = CreatePaymentTests.createBasePayment();

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

            basePayment.Recurrence = onDemandRecurrence;

            try
            {
                var result = connector.GetAppToken().CreatePayment(basePayment);
                Assert.NotNull(result);
                Assert.NotEqual(0, 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);
                Console.WriteLine("Payment amount: {0}", result.Amount);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Creating OnDemand payment ERROR");
                var err  = exception.Error;
                var date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }
        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)
                {
                    //
                }
            }
        }
Ejemplo n.º 30
0
        public void GPConnectorTestNextOnDemand()
        {
            var connector = new GPConnector(TestUtils.API_URL, TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);

            try
            {
                NextPayment nextPayment = new NextPayment()
                {
                    OrderNumber      = "OnDemand4321",
                    Amount           = 4000,
                    Currency         = Currency.CZK,
                    OrderDescription = "OnDemand4321Description",
                };
                nextPayment.Items.Add(new OrderItem()
                {
                    Name = "OnDemand First Item", Amount = 2000, Count = 2
                });

                Payment onDemandPayment = connector.GetAppToken().CreateRecurrentPayment(3049249957, nextPayment);

                Console.WriteLine("OnDemand payment id: {0}", onDemandPayment.Id);
                Console.WriteLine("OnDemand payment gw_url: {0}", onDemandPayment.GwUrl);
                Console.WriteLine("OnDemand Payment instrument: {0}", onDemandPayment.PaymentInstrument);
                Console.WriteLine("OnDemand recurrence: {0}", onDemandPayment.Recurrence);
                Console.WriteLine("OnDemand amount: {0}", onDemandPayment.Amount);
            }
            catch (GPClientException exception)
            {
                Console.WriteLine("Creating next on demand payment ERROR");
                var      err  = exception.Error;
                DateTime date = err.DateIssued;
                foreach (var element in err.ErrorMessages)
                {
                    //
                }
            }
        }