Exemplo n.º 1
0
        public async void testSetPaymentSystem()
        {
            Console.WriteLine("------testSetPaymentSystem");
            try
            {
                int id = await ApiClass.CreatePromotion();

                //id = -1;
                Assert.False(id == -1, Messages.msg_object_not_created);
                Console.WriteLine(Messages.msg_object_created);

                PaymentSystems etalon    = TestHelper.BasePaymentSystem();
                string         ResSetpay = await ApiClass.SetPaymentSystems(id, etalon);

                if (ResSetpay != "")
                {
                    Console.WriteLine(ResSetpay);
                }
                Assert.IsNullOrEmpty(ResSetpay, Messages.msg_object_not_created);
                Console.WriteLine(Messages.msg_object_created);

                PaymentSystemsResult ResGetpay = await ApiClass.GetPaymentSystem(id);

                PaymentSystems actual = ResGetpay as PaymentSystems;
                Assert.AreEqual(etalon, actual, Messages.msg_objects_not_equal);

                Console.WriteLine(Messages.msg_objects_equal);
                Console.WriteLine(Messages.msg_test_pass);
            }
            catch (Exception e)
            {
                Console.WriteLine(Messages.msg_test_fail);
            }
        }
Exemplo n.º 2
0
        public static PaymentSystems BasePaymentSystem()
        {
            var paySystems = new PaymentSystems();

            paySystems.payment_systems.Add(new PaymentSystem
            {
                id = int.Parse(Properties.Resources.payment_systems_id)
            });
            return(paySystems);
        }
Exemplo n.º 3
0
        private TransactionBdo MapTo(transaction t)
        {
            TransactionBdo transaction = null;

            if (t != null)
            {
                PaymentStatusIds paymentStatus = PaymentStatusIds.NotProcessed;
                PaymentSystems   paymentSystem = PaymentSystems.None;
                int projectId = 0;

                int.TryParse(t.project_id, out projectId);
                Enum.TryParse(t.pay_system_id.ToString(), out paymentSystem);
                Enum.TryParse(t.payment_status_id.ToString(), out paymentStatus);

                transaction = new TransactionBdo
                {
                    Id = t.id,
                    IsPaymentProcessed = t.is_payment_processed,
                    IsTestPayment      = t.is_test_payment,

                    RequestedAmount       = t.requested_amount,
                    RequestedCurrencyCode = t.requested_currency_code,
                    PaidAmount            = t.paid_amount,
                    PaidCurrencyCode      = t.paid_currency_code,
                    PaidThrough           = t.paid_through,

                    PayerName     = t.p_name,
                    PayerLastName = t.p_lastname,
                    PayerEmail    = t.p_email,
                    PayerPhone    = t.p_phone,
                    Remarks       = t.remarks,

                    ProjectId    = projectId,
                    PosId        = t.pos_id,
                    PosUserUid   = t.pos_user_uid,
                    PaySystemUid = t.pay_system_uid,
                    ProductId    = t.product_id,
                    ProductUid   = t.product_uid,
                    OrderNr      = t.order_nr,

                    PaymentStatus = paymentStatus,
                    PaymentSystem = paymentSystem,

                    CreatedAt                 = t.created_at,
                    PaySystemResponseAt       = t.pay_system_response_at.HasValue ? t.pay_system_response_at.Value : DateTime.MinValue,
                    ResponseFromPaymentSystem = t.response_from_payment
                };
            }

            return(transaction);
        }
Exemplo n.º 4
0
        public static async Task <string> SetPaymentSystems(int promotionId, PaymentSystems paymentSystems)
        {
            string json = JsonConvert.SerializeObject(paymentSystems);

            return(await SetConverter(String.Format(Resources.payment_systems, promotionId), json));
        }
Exemplo n.º 5
0
        public IEnumerable <TransactionBdo> GetLastTransactions(int posId, int offset, int limit)
        {
            Logger.InfoFormat("Getting last transactions for POS ID: #{0}", posId);
            Logger.DebugFormat("  setting offset to:    {0}", offset);
            Logger.DebugFormat("  setting limit to:     {0}", limit);

            var list = new List <TransactionBdo>();

            try
            {
                // TODO: validate offset and limit
                using (var db = new GiftServiceEntities())
                {
                    IQueryable <transaction> ts = db.transactions.OrderByDescending(x => x.id);
                    if (posId > 0)
                    {
                        ts = ts.Where(x => x.pos_id == posId);
                    }
                    ts.Skip(offset).Take(limit);

                    int projectId = 0;
                    PaymentStatusIds paymentStatus = PaymentStatusIds.NotProcessed;
                    PaymentSystems   paymentSystem = PaymentSystems.None;

                    foreach (var t in ts)
                    {
                        int.TryParse(t.project_id, out projectId);
                        Enum.TryParse(t.pay_system_id.ToString(), out paymentSystem);
                        Enum.TryParse(t.payment_status_id.ToString(), out paymentStatus);

                        list.Add(new TransactionBdo
                        {
                            Id = t.id,
                            IsPaymentProcessed = t.is_payment_processed,
                            IsTestPayment      = t.is_test_payment,

                            RequestedAmount       = t.requested_amount,
                            RequestedCurrencyCode = t.requested_currency_code,
                            PaidAmount            = t.paid_amount,
                            PaidCurrencyCode      = t.paid_currency_code,
                            PaidThrough           = t.paid_through,

                            PayerName     = t.p_name,
                            PayerLastName = t.p_lastname,
                            PayerEmail    = t.p_email,
                            PayerPhone    = t.p_phone,
                            Remarks       = t.remarks,

                            ProjectId    = projectId,
                            PosId        = t.pos_id,
                            PosUserUid   = t.pos_user_uid,
                            PaySystemUid = t.pay_system_uid,
                            OrderNr      = t.order_nr,
                            ProductId    = t.product_id,
                            ProductUid   = t.product_uid,

                            PaymentStatus = paymentStatus,
                            PaymentSystem = paymentSystem,

                            CreatedAt           = t.created_at,
                            PaySystemResponseAt = t.pay_system_response_at.HasValue ? t.pay_system_response_at.Value : DateTime.MinValue
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Erro getting last transactions", ex);
                throw;
            }

            return(list);
        }