public void Update(Entities.Transactions.Transaction transaction)
 {
     TransactionDate    = transaction.TransactionDate;
     ApprovedDate       = transaction.ApprovedDate;
     ReprovedDate       = transaction.ReprovedDate;
     StatusAnticipation = transaction.Anticipation;
     Confirmation       = transaction.Confirmation;
     GrossValue         = transaction.GrossValue;
     NetValue           = transaction.NetValue;
     FixedTax           = transaction.FixedTax;
     NumberParcel       = transaction.NumberParcel;
     CreditCardSuffix   = transaction.CreditCardSuffix;
     if (Installments.Any())
     {
         foreach (var installment in transaction.Installments)
         {
             foreach (var i in Installments)
             {
                 if (i.Id == installment.Id)
                 {
                     i.Update(installment);
                 }
             }
         }
     }
 }
Exemple #2
0
        public Installment FirstInstallment()
        {
            if (!Installments.Any())
            {
                throw new ApplicationException($"No Installments for Payment Plan Id {Id.ToString()}");
            }

            return(Installments.OrderBy(i => i.Date).FirstOrDefault());
        }
Exemple #3
0
        // We only accept payments matching the Installment Amount.
        public void MakePayment(decimal amount, Guid installmentId)
        {
            if (!Installments.Any(i => i.Id == installmentId))
            {
                throw new ArgumentException($"No Installment Found for Provided installmentId: {installmentId}", nameof(installmentId));
            }

            var installment = Installments.Where(i => i.Id == installmentId).FirstOrDefault();

            if (installment.Amount != amount)
            {
                throw new ArgumentException($"Payment amount must match installment amount.", nameof(amount));
            }

            //Simulating a third party api call
            var paymentReferenceId = _thirdPartyPaymentService.MakePayment(amount);

            installment.SetStatus(paymentReferenceId);
        }
Exemple #4
0
        // We only accept payments matching the Installment Amount.
        public void MakePayment(decimal amount, Guid installmentId)
        {
            if (!Installments.Any(i => i.Id == installmentId))
            {
                throw new ArgumentException($"No Installment Found for Provided installmentId: {installmentId}", nameof(installmentId));
            }

            var installment = Installments.Where(i => i.Id == installmentId).FirstOrDefault();

            if (installment.Amount != amount)
            {
                throw new ArgumentException($"Payment amount must match installment amount.", nameof(amount));
            }

            //we call payment domain logic here, ie. service call or writing to an event stream
            var paymentReferenceId = Guid.NewGuid(); //in this instance, i'm just setting some guid to be the payment reference id,

            //but an actual implementation could call another service i.e 3rd party payment API
            installment.SetPaid(paymentReferenceId.ToString());
        }