Example #1
0
 internal CardPayment(
     Card card,
     PaymentTemplate template,
     PaymentOrder order,
     JObject submittedForm,
     Account from,
     Account to,
     Currency currency)
     : base(template, submittedForm, order, currency, from, to)
 {
     Argument.NotNull(card, "card");
     Card = card;
 }
Example #2
0
 internal CardPayment(
     Card card, 
     PaymentTemplate template,
     PaymentOrder order,
     JObject submittedForm,
     Account from,
     Account to,
     Currency currency)
     : base(template, submittedForm, order, currency, from, to)
 {
     Argument.NotNull(card, "card");
     Card = card;
 }
Example #3
0
        internal Payment(
            PaymentTemplate template,
            JObject submittedForm,
            PaymentOrder order,
            Currency currency,
            Account from,
            Account to) : base(template, from, to, currency, order.Amount)
        {
            Argument.NotNull(submittedForm, "submittedForm");
            Argument.NotNull(template, "template");
            Argument.NotNull(order, "order");

            Order = order;
            Form  = submittedForm.ToString();
        }
Example #4
0
        internal Payment(
            PaymentTemplate template,
            JObject submittedForm,
            PaymentOrder order,
            Currency currency,
            Account from, 
            Account to)
            : base(template, from, to, currency, order.Amount)
        {
            Argument.NotNull(submittedForm, "submittedForm");
            Argument.NotNull(template, "template");
            Argument.NotNull(order, "order");

            Order = order;
            Form = submittedForm.ToString();
        }
Example #5
0
        public CardPayment Create(UserCard card, PaymentTemplate template, JObject form)
        {
            Argument.NotNull(template, "template");
            Argument.NotNull(form, "form");
            Argument.NotNull(card, "card");

            var paymentProfile = _paymentProfiles.Find(card.Owner.Id);
            if (paymentProfile == null)
            {
                var message = string.Format("Payment profile for user [{0}] was not found.", card.Owner.Id);
                throw new InvalidOperationException(message);
            }
            var paymentForm = _paymentFormFactory.Create(paymentProfile, card.Account, template);
            paymentForm.MergeWith(form);
            var paymentOrder = template.OrderTemplate.CreateOrder(paymentForm);
            var to = paymentOrder.BeneficiaryBankCode == _settings.VaBankCode
                ? _accounts.Find(paymentOrder.BeneficiaryAccountNo)
                : _correspondentAccounts.QueryOne(DbQuery.For<CorrespondentAccount>().FilterBy(x => x.Bank.Code == paymentOrder.BeneficiaryBankCode));
            if (to == null)
            {
                var message = string.Format("Destination account could not be found. Bank code: {0}. Account No: {1}.",
                    paymentOrder.BeneficiaryBankCode,
                    paymentOrder.BeneficiaryAccountNo);
                throw new InvalidOperationException(message);
            }
            var currency = _currencies.Find(paymentOrder.CurrencyISOName);
            if (currency == null)
            {
                var message = string.Format("Currency with code {0} was not found.", paymentOrder.CurrencyISOName);
                throw new InvalidOperationException(message);
            }
            var payment = new CardPayment(card, template, paymentOrder, form, card.Account, to, currency);
            template.FillInfo(payment, paymentForm);
            var transactionName = _transactionReferenceBook.ForPayment(template);
            payment.Withdrawal = card.Account.Withdraw(
                card,
                transactionName.Code,
                transactionName.Description,
                _settings.Location,
                payment.MoneyAmount,
                _moneyConverter);
            return payment;
        }
Example #6
0
        public PaymentForm Create(UserPaymentProfile profile, Account account, PaymentTemplate template)
        {
            Argument.NotNull(profile, "profile");
            Argument.NotNull(account, "account");
            Argument.NotNull(template, "template");

            var form = new JObject
            {
                {"payerTin", new JValue(profile.PayerTIN)},
                {"payerName", new JValue(profile.PayerName)},
                {"payerBankCode", new JValue(_bankSettings.VaBankCode)},
                {"payerAccountNo", new JValue(account.AccountNo)}
            };
            var fields = template.OrderTemplate.EnumerateNotTemplatedFields().ToList();
            foreach (var field in fields)
            {
                form.Add(field.Key, new JValue(field.Value));
            }
            return new PaymentForm(form);
        }
 public TransactionName ForPayment(PaymentTemplate template)
 {
     Argument.NotNull(template, "template");
     return new TransactionName(template.Code, template.DisplayName);
 }