Ejemplo n.º 1
0
        public BaseApiResponse InsertUpdatePayment(PaymentEntity model)
        {
            var response = new BaseApiResponse();

            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("PmtNo", (object)model.PmtNo ?? (object)DBNull.Value)
                    ,                         new SqlParameter("PaidBy", (object)model.PaidBy ?? (object)DBNull.Value)
                    ,                         new SqlParameter("ChkNo", (object)model.ChkNo ?? (object)DBNull.Value)
                    ,                         new SqlParameter("PmtDate", (object)model.PmtNo ?? (object)DBNull.Value)
                    ,                         new SqlParameter("ChkAmt", (object)model.ChkAmt ?? (object)DBNull.Value)
                };
                var result = _repository.ExecuteSQL <int>("InsertUpdatePayment", param).FirstOrDefault();
                if (result > 0)
                {
                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Message.Add(ex.Message);
            }
            return(response);
        }
Ejemplo n.º 2
0
        public async void Delete_EntryNotFound()
        {
            // Arrange
            var paymentRepository = new PaymentRepository(ambientDbContextLocator);
            var accountRepository = new AccountRepository(ambientDbContextLocator);

            var testAccount = new AccountEntity {
                Name = "testAccount"
            };

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                accountRepository.Add(testAccount);
                await dbContextScope.SaveChangesAsync();
            }

            var testEntry = new PaymentEntity {
                ChargedAccount = testAccount
            };

            // Act / Assert
            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                paymentRepository.Delete(testEntry);
                await Assert.ThrowsAsync <DbUpdateConcurrencyException>(async() => await dbContextScope.SaveChangesAsync());
            }
        }
Ejemplo n.º 3
0
        public async void Delete_AssignedPaymentsSetNull()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var categoryRepository = new CategoryRepository(factory);
            var paymentRepository  = new PaymentRepository(factory);

            var category = new CategoryEntity {
                Name = "TestCategory"
            };
            var payment = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Category = category
            };

            categoryRepository.Add(category);
            paymentRepository.Add(payment);
            await unitOfWork.Commit();

            // Act
            categoryRepository.Delete(category);
            await unitOfWork.Commit();

            // Assert
            Assert.Null(payment.Category);
            Assert.Null(paymentRepository.GetById(payment.Id).Result.Category);
        }
Ejemplo n.º 4
0
        public async void Add_AddNewEntryOnEveryCall()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var testEntry = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            testEntry.Id = 0;
            repository.Add(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(2, repository.GetAll().Count());
        }
        public void Test_Mapping_Functional()
        {
            //Arrange
            Db.Recreate();

            var payment = new PaymentEntity()
            {
                Id = 1, SourceAccountId = "1", TransactionSuccessful = true, Amount = 1, From = "1", To = "2"
            };

            //Act
            using (AppDbContext ctx1 = Db.GetAdminContext())
            {
                ctx1.Set <PaymentEntity>().Add(payment);
                ctx1.SaveChanges();
            }

            //Assert
            using AppDbContext ctx2 = Db.GetAdminContext();

            PaymentEntity savedPayment = ctx2.Set <PaymentEntity>().Find(payment.Id);

            Assert.AreEqual(payment.Id, savedPayment.Id);
            Assert.AreEqual(payment.SourceAccountId, savedPayment.SourceAccountId);
            Assert.AreEqual(payment.To, savedPayment.To);
            Assert.AreEqual(payment.From, savedPayment.From);
            Assert.AreEqual(payment.Amount, savedPayment.Amount);
            Assert.AreEqual(payment.TransactionSuccessful, savedPayment.TransactionSuccessful);
        }
Ejemplo n.º 6
0
        public async void Update_IdUnchanged()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var testEntry = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            var idBeforeUpdate = testEntry.Id;

            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(idBeforeUpdate, testEntry.Id);
        }
Ejemplo n.º 7
0
        public async void Delete_EntryMatchedFilterDeleted()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var filterText = "Text";
            var repository = new PaymentRepository(factory);
            var testEntry1 = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = filterText
            };
            var testEntry2 = new PaymentEntity {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                }
            };

            repository.Add(testEntry1);
            repository.Add(testEntry2);
            await unitOfWork.Commit();

            // Act
            repository.Delete(x => x.Note == filterText);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(1, repository.GetAll().Count());
        }
        public async void Delete_RelatedPaymentSetNull()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var recurringPaymentRepository = new RecurringPaymentRepository(dbFactory);
            var paymentRepository          = new PaymentRepository(dbFactory);

            var recurringPaymentEntity = new RecurringPaymentEntity {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                }
            };
            var payment = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                RecurringPayment = recurringPaymentEntity
            };

            paymentRepository.Add(payment);
            await unitOfWork.Commit();

            // Act
            recurringPaymentRepository.Delete(recurringPaymentEntity);
            await unitOfWork.Commit();

            // Assert
            Assert.Null(payment.RecurringPayment);
            Assert.Null(paymentRepository.GetById(payment.Id).Result.RecurringPayment);
        }
        public DataResultArgs <PaymentEntity> SetPaymentAmount(string id, string encryptStudentId, string year, string month,
                                                               string currentAmount, string paymentType)
        {
            PaymentEntity paymentEntity = new PaymentEntity
            {
                EncryptStudentId = encryptStudentId,
                StudentId        = GeneralFunctions.GetData <int>(Cipher.Decrypt(encryptStudentId)),
                Year             = GeneralFunctions.GetData <short>(year),
                Month            = GeneralFunctions.GetData <short>(month),
                Amount           = GeneralFunctions.GetData <decimal>(currentAmount),
                Id = GeneralFunctions.GetData <int>(id)
            };

            paymentEntity.DatabaseProcess = (paymentEntity.Id > 0) ? DatabaseProcess.Update : DatabaseProcess.Add;
            paymentEntity.IsActive        = true;
            paymentEntity.IsDeleted       = false;
            paymentEntity.PaymentDate     = DateTime.Now;
            paymentEntity.IsPayment       = null;
            paymentEntity.PaymentType     = GeneralFunctions.GetData <short>(paymentType);

            DataResultArgs <string> resultSet = new PaymentBusiness().Set_Payment(paymentEntity);

            paymentEntity.Id = GeneralFunctions.GetData <int>(resultSet.Result);
            DataResultArgs <PaymentEntity> returnResultSet = new DataResultArgs <PaymentEntity>
            {
                ErrorCode        = resultSet.ErrorCode,
                ErrorDescription = resultSet.ErrorDescription,
                HasError         = resultSet.HasError,
                Result           = paymentEntity
            };

            return(returnResultSet);
        }
        private void CreateTestObject()
        {
            _paymentRequest = new PaymentRequest()
            {
                Amount          = 900,
                Currency        = "EUR",
                CardInformation = new CardInformation()
                {
                    CardNumber  = "1111222233334444",
                    ExpiryMonth = 12,
                    ExpiryYear  = 2021,
                    Cvv         = 123
                }
            };

            _paymentRequest2 = new PaymentRequest()
            {
                Amount          = 1500,
                Currency        = "EUR",
                CardInformation = new CardInformation()
                {
                    CardNumber  = "1111222233334444",
                    ExpiryMonth = 12,
                    ExpiryYear  = 2021,
                    Cvv         = 123
                }
            };

            _successfulPaymentResponse = new PaymentResponse()
            {
                PaymentId = new Guid("10013B70-6182-48E7-8222-1E14EBF86000"),
                Message   = "Successful",
                Status    = true
            };

            _unsuccessfulPaymentResponse = new PaymentResponse()
            {
                PaymentId = new Guid("10013B70-6182-48E7-8222-1E14EBF86111"),
                Message   = "Unsuccessful",
                Status    = false
            };

            _paymentResponseFromRepo = new PaymentEntity()
            {
                Amount   = 899,
                CardId   = 1,
                Code     = new Guid("10013B70-6182-48E7-8222-1E14EBF866CF"),
                Currency = "EUR",
                Message  = "Successful",
                Status   = true
            };

            _cardInformation = new CardInformationEntity()
            {
                CardNumber  = "1111222233334444",
                Cvv         = 123,
                ExpiryMonth = 12,
                ExpiryYear  = 2022
            };
        }
Ejemplo n.º 11
0
        public TransactionEntity Create(PaymentEntity payment)
        {
            TransactionEntity transaction = new TransactionEntity();
            bool processingError          = false;

            _DownPayment   = Company.GetBusinessObject(BoObjectTypes.oVendorPayments);
            _PaymentEntity = payment;
            _CreatePaymentHeading();
            _AssignPaymentType();

            foreach (var document in payment.Documents)
            {
                TransactionEntity payTransaction        = null;
                TransactionEntity creditNoteTransaction = null;

                if (document.PayAmount > 0)
                {
                    payTransaction = _PayDocument(payment, document);
                    if (!payTransaction.Success)
                    {
                        transaction.Message = payTransaction.Message;
                        processingError     = true;
                        break;
                    }
                }

                if (document.CreditNote.Amount > 0)
                {
                    creditNoteTransaction = _AddCreditNote(payment, document);
                    if (!creditNoteTransaction.Success)
                    {
                        transaction.Message = creditNoteTransaction.Message;
                        processingError     = true;
                        break;
                    }
                }
            }

            if (!processingError)
            {
                if (_DownPayment.Add() != 0)
                {
                    transaction.Message = ErrorMessage;
                }
                else
                {
                    string newEntityId;
                    Company.GetNewObjectCode(out newEntityId);
                    transaction.Successfull(newEntityId);
                }
            }
            else
            {
                _DownPayment.Cancel();
            }

            Company.Disconnect();

            return(transaction);
        }
Ejemplo n.º 12
0
        public void TestAddAttachment()
        {
            DateTime     dueDate   = new DateTime(2010, 10, 10);
            decimal      dueAmount = 100m;
            APartyEntity payee     = new SupplierEntity(SupplierType.Cruise, "", "Galasam");
            APartyEntity payer     = new CustomerEntity(CustomerType.Bureau, "", "Lonely Tree");
            PaymentType  type      = PaymentType.Full;
            string       sale      = "SR Josef";
            int          booking   = 59;

            PaymentEntity paymentEntity = new PaymentEntity(dueDate, dueAmount, payer,
                                                            payee, type, sale, booking);

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

            expectedAttachments.Add("attachment1");
            expectedAttachments.Add("attachment2");
            expectedAttachments.Add("attachment3");

            paymentEntity.AddAttachment("attachment1");
            paymentEntity.AddAttachment("attachment2");
            paymentEntity.AddAttachment("attachment3");

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

            foreach (string attachment in paymentEntity.Attachments)
            {
                actualAttachments.Add(attachment);
            }

            CollectionAssert.AreEqual(expectedAttachments, actualAttachments);
        }
Ejemplo n.º 13
0
        public void TestConstructorSetsAllProperties()
        {
            DateTime     dueDate   = new DateTime(2010, 10, 10);
            decimal      dueAmount = 100m;
            APartyEntity payee     = new SupplierEntity(SupplierType.Cruise, "", "Galasam");
            APartyEntity payer     = new CustomerEntity(CustomerType.Bureau, "", "Lonely Tree");
            PaymentType  type      = PaymentType.Full;
            string       sale      = "VF March";
            int          booking   = 128;

            PaymentEntity paymentEntity = new PaymentEntity(dueDate, dueAmount, payer,
                                                            payee, type, sale, booking);

            DateTime expectedPaidDate         = new DateTime(1900, 01, 01);
            decimal  expectedPaidAmount       = 0m;
            bool     expectedPaid             = false;
            bool     expectedArchived         = false;
            int      expectedAttachmentsCount = 0;

            Assert.AreEqual(dueDate, paymentEntity.DueDate);
            Assert.AreEqual(dueAmount, paymentEntity.DueAmount);
            Assert.AreEqual(payee, paymentEntity.Payee);
            Assert.AreEqual(payer, paymentEntity.Payer);
            Assert.AreEqual(expectedPaidDate, paymentEntity.PaidDate);
            Assert.AreEqual(expectedPaidAmount, paymentEntity.PaidAmount);
            Assert.AreEqual(expectedPaid, paymentEntity.Paid);
            Assert.AreEqual(expectedArchived, paymentEntity.Archived);
            Assert.AreEqual(expectedAttachmentsCount, paymentEntity.Attachments.Count);
        }
Ejemplo n.º 14
0
        public override CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity)
        {
#pragma warning disable CS0618

            BitcoinLikePaymentData paymentData;
            if (string.IsNullOrEmpty(paymentEntity.CryptoPaymentDataType))
            {
                // For invoices created when CryptoPaymentDataType was not existing, we just consider that it is a RBFed payment for safety
                paymentData                   = new BitcoinLikePaymentData();
                paymentData.Outpoint          = paymentEntity.Outpoint;
                paymentData.Output            = paymentEntity.Output;
                paymentData.RBF               = true;
                paymentData.ConfirmationCount = 0;
                paymentData.Legacy            = true;
                return(paymentData);
            }

            paymentData =
                JsonConvert.DeserializeObject <BitcoinLikePaymentData>(paymentEntity.CryptoPaymentData);
            // legacy
            paymentData.Output   = paymentEntity.Output;
            paymentData.Outpoint = paymentEntity.Outpoint;
#pragma warning restore CS0618
            return(paymentData);
        }
Ejemplo n.º 15
0
        public async void Add_WithRecurringPayment()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var testAccount = new AccountEntity {
                Name = "testAccount"
            };
            var testEntry = new PaymentEntity
            {
                ChargedAccount   = testAccount,
                RecurringPayment = new RecurringPaymentEntity
                {
                    ChargedAccount = testAccount,
                    Recurrence     = PaymentRecurrence.Bimonthly,
                    IsEndless      = true
                },
                IsRecurring = true,
                Note        = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.NotNull(testEntry.Id);
            Assert.NotEqual(0, testEntry.Id);
            Assert.NotEqual(0, testEntry.RecurringPayment.Id);
            Assert.NotEqual(0, testEntry.RecurringPaymentId);
        }
Ejemplo n.º 16
0
 public ActionResult GetPayment2(int id)
 {
     if (id == 0)
     {
         return(BadRequest(new MessageResponse("Thiếu param id", "param request")));
     }
     try
     {
         PaymentEntity paymentEntity = this.paymentDAO.getPayment(id);
         paymentEntity = paymentEntity.querry(httpClient);
         paymentEntity = this.paymentDAO.UpdatePayment(paymentEntity);
         string urlReturn = paymentEntity.UrlReturn;
         if (urlReturn.LastIndexOf("?") > 0)
         {
             urlReturn = urlReturn.Substring(0, urlReturn.LastIndexOf("?"));
         }
         urlReturn += "?" + paymentEntity.ParamsUrlStatus;
         return(Redirect(urlReturn));
         //return Redirect("https://localhost:5001/test");
         //return Ok(paymentEntity);
     }
     catch (Exception e)
     {
         return(BadRequest(new { err = e.Message }));
     }
 }
Ejemplo n.º 17
0
        public async void Update_EntryUpdated()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var newValue  = "newText";
            var testEntry = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            testEntry.Note = newValue;
            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            var loadedEntry = await repository.GetById(testEntry.Id);

            Assert.Equal(newValue, loadedEntry.Note);
        }
        public async Task <PaymentDto> UpdatePayment(PaymentDto payment)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (payment != null)
                    {
                        PaymentEntity entity = payment.ToModel();
                        entity.PaymentId = payment.PaymentId;
                        db.Payment.Attach(entity);
                        foreach (var propName in db.Entry(entity).CurrentValues.PropertyNames)
                        {
                            if (propName != "PaymentId")
                            {
                                db.Entry(entity).Property(propName).IsModified = true;
                            }
                        }
                        await db.SaveChangesAsync();

                        return(entity.ToDto());
                    }
                    return(null);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Ejemplo n.º 19
0
        public async void Update_NoNewEntryAdded()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var testEntry = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(1, repository.GetAll().Count());
        }
Ejemplo n.º 20
0
        private static List <PaymentEntity> GetList(DataResultArgs <SqlDataReader> result)
        {
            DataProcess.ControlAdminAuthorization();

            SqlDataReader        dr  = result.Result;
            List <PaymentEntity> lst = new List <PaymentEntity>();

            while (dr.Read())
            {
                var paymentEntity = new PaymentEntity
                {
                    Id           = GeneralFunctions.GetData <Int32>(dr["id"]),
                    StudentId    = GeneralFunctions.GetData <Int32?>(dr["studentId"]),
                    Year         = GeneralFunctions.GetData <Int16?>(dr["year"]),
                    Month        = GeneralFunctions.GetData <Int16?>(dr["month"]),
                    Amount       = GeneralFunctions.GetData <Decimal?>(dr["amount"]),
                    IsPayment    = GeneralFunctions.GetData <Boolean?>(dr["isPayment"]),
                    PaymentDate  = GeneralFunctions.GetData <DateTime?>(dr["paymentDate"]),
                    PaymentType  = GeneralFunctions.GetData <Int32?>(dr["paymentType"]),
                    IsActive     = GeneralFunctions.GetData <Boolean?>(dr["isActive"]),
                    IsNotPayable = GeneralFunctions.GetData <Boolean>(dr["isNotPayable"])
                };
                lst.Add(paymentEntity);
            }

            dr.Close();
            return(lst);
        }
Ejemplo n.º 21
0
        public async void Add_AddedAndRead()
        {
            // Arrange
            var factory    = new DbFactory();
            var unitOfWork = new UnitOfWork(factory);

            var repository = new PaymentRepository(factory);

            var testEntry = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            // Assert
            var loadedEntry = await repository.GetById(testEntry.Id);

            Assert.Equal(testEntry.Note, loadedEntry.Note);
        }
Ejemplo n.º 22
0
        public async Task UpdateAsync(PaymentEntity payment)
        {
            Guard.IsNotNull(payment, nameof(payment));

            const string query = @"
                UPDATE payments
                SET
                        status = @Status,
                        response_code = @ResponseCode,
                        acquirer_payment_id = @AcquirerPaymentId,
                        acquirer_status = @AcquirerStatus,
                        acquirer_response_code = @AcquirerResponseCode
                WHERE   id = @Id
            ";

            var parameters = new
            {
                Id = payment.PaymentId.ToString(),
                payment.Status,
                payment.ResponseCode,
                payment.AcquirerPaymentId,
                payment.AcquirerStatus,
                payment.AcquirerResponseCode
            };

            using (var connection = new NpgsqlConnection(_databaseOptions.GatewayDatabaseConnectionString))
            {
                var affectedRows = await connection.ExecuteAsync(query, parameters);

                if (affectedRows < 1)
                {
                    throw new GatewayException("Update payment failed.");
                }
            }
        }
Ejemplo n.º 23
0
        public bool ValidateRequest(PaymentEntity request, out string errmsg)
        {
            errmsg = string.Empty;


            // Validate Credit Card number
            if (!CreditCardValidator.IsValid(request.CreditCardNumber))
            {
                errmsg = "Invalid Credit Card number";
            }

            //Check if Expiration date is not a past date
            if (request.ExpirationDate < DateTime.Now)
            {
                errmsg = errmsg.Length > 0 ? errmsg + ";" + "Invalid Expiration Date" : "Invalid Expiration Date";
            }

            //Check if Amount is positive
            if (request.Amount < 0)
            {
                errmsg = errmsg.Length > 0 ? errmsg + ";" + "Invalid Amount" : "Invalid Amount";
            }

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(false);
            }



            return(true);
        }
        public override CryptoPaymentData GetCryptoPaymentData(PaymentEntity paymentEntity)
        {
#pragma warning disable CS0618
            return(JsonConvert.DeserializeObject <LightningLikePaymentData>(paymentEntity.CryptoPaymentData));

#pragma warning restore CS0618
        }
Ejemplo n.º 25
0
        public async void Add_IdSet()
        {
            // Arrange
            var paymentRepository = new PaymentRepository(ambientDbContextLocator);
            var accountRepository = new AccountRepository(ambientDbContextLocator);

            var account = new AccountEntity {
                Name = "testAccount"
            };

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                accountRepository.Add(account);
                await dbContextScope.SaveChangesAsync();
            }

            var testEntry = new PaymentEntity
            {
                ChargedAccount = account,
                Note           = "Testtext"
            };

            // Act
            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                paymentRepository.Add(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Assert
            Assert.NotNull(testEntry.Id);
            Assert.NotEqual(0, testEntry.Id);
        }
Ejemplo n.º 26
0
    private void Pay()
    {
        PaymentEntity entity = new PaymentEntity();

        entity.IOC_Class_Alias = ConfigurationManager.AppSettings["PaymentGatewayForAdmin"];
        entity.Gateway         = entity.IOC_Class_Alias;

        //if (Request.QueryString.Count > 1)
        //{
        //    entity.Website = Request.QueryString["website"];
        //    entity.Amount = decimal.Parse(TxtTotal_fee.Text.Trim());
        //    entity.Title = Request.QueryString["title"];
        //    entity.Description = Request.QueryString["desc"];
        //    entity.Payer = Request.QueryString["payer"];
        //    entity.OrderID_Salve = Request.QueryString["OrderID_Salve"];
        //    entity.URL_Return_Slave = Request.QueryString["URL_Return_Slave"];
        //    entity.URL_Callback_Slave = Request.QueryString["URL_Callback_Slave"];
        //    entity.OrderId = Payment.CreateOrder(entity);
        //}
        //else
        {
            entity.Website     = Request.Url.Host;
            entity.Amount      = decimal.Parse(TxtTotal_fee.Text.Trim());
            entity.Title       = TxtSubject.Text.Trim();
            entity.Description = TxtBody.Text.Trim();
            entity.Payer       = User.Identity.Name;

            entity.OrderId = Payment.CreateOrder(entity);
        }

        //if (Request.Url.Host == Common.PaymentDomainName)
        Payment.Transfer(entity);
        //else
        //    Payment.TransferByMasterSite(entity);
    }
Ejemplo n.º 27
0
        public PaymentResponse SetPayment(Payment payment)
        {
            // Generate id for the payment
            Guid paymentId = Guid.NewGuid();

            // 5% chance of payment failure to make it more interesting
            PaymentStatus paymentStatus = PaymentStatus.Success;

            if (GetRandomInteger(0, 100) < 5)
            {
                paymentStatus = PaymentStatus.Failure;
            }

            PaymentEntity paymentEntity = new PaymentEntity()
            {
                Id            = paymentId,
                PaymentStatus = paymentStatus,
                CardNumber    = payment.CardNumber,
                ExpiryYear    = payment.ExpiryYear,
                ExpiryMonth   = payment.ExpiryMonth,
                Amount        = payment.Amount,
                CurrencyCode  = payment.CurrencyCode,
                CVV           = payment.CVV
            };

            payments.TryAdd(paymentId, paymentEntity);

            PaymentResponse paymentResponse = new PaymentResponse()
            {
                Id            = paymentEntity.Id,
                PaymentStatus = paymentEntity.PaymentStatus
            };

            return(paymentResponse);
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> Edit(int id, PaymentEntity paymentEntity)
        {
            if (id != paymentEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentEntityExists(paymentEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentEntity));
        }
Ejemplo n.º 29
0
        public async void DeleteAccount_RelatedChargedPaymentsRemoved()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var accountRepository = new AccountRepository(dbFactory);
            var paymentRepository = new PaymentRepository(dbFactory);

            var account = new AccountEntity
            {
                Name = "Testtext"
            };

            var payment = new PaymentEntity
            {
                Note           = "Foo",
                ChargedAccount = account
            };

            accountRepository.Add(account);
            paymentRepository.Add(payment);
            await unitOfWork.Commit();

            Assert.Equal(1, await accountRepository.GetAll().CountAsync());
            Assert.Equal(1, await paymentRepository.GetAll().CountAsync());

            // Act
            accountRepository.Delete(account);
            await unitOfWork.Commit();

            // Assert
            Assert.False(await accountRepository.GetAll().AnyAsync());
            Assert.False(await paymentRepository.GetAll().AnyAsync());
        }
Ejemplo n.º 30
0
        public async void Get_MatchedDataReturned()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var repository = new PaymentRepository(dbFactory);
            var filterText = "Text";
            var testEntry  = new PaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = filterText
            };

            repository.Add(testEntry);
            repository.Add(new PaymentEntity {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                }
            });
            repository.Add(new PaymentEntity {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                }
            });
            await unitOfWork.Commit();

            // Act
            var result = await repository.Get(x => x.Note == filterText);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(testEntry.Id, result.Id);
        }