protected void CreatePayment_Click(object sender, EventArgs e)
        {
            // Create Payment
            OnlineBillPay.Models.Payment newPayment = new OnlineBillPay.Models.Payment();
            newPayment.PaymentId       = System.Guid.NewGuid().ToString().ToUpper();
            newPayment.UserPayeeId     = hdnExistingUserPayeeId.Value;
            newPayment.FundingSourceId = ddlFundingSource.SelectedValue;
            newPayment.UserId          = User.Identity.GetUserId();
            newPayment.Amount          = float.Parse(txtPaymentAmount.Text);
            newPayment.DateCreated     = DateTime.Now;
            newPayment.Currency        = txtCurrency.Text;
            newPayment.Status          = "Pending";

            // Store into DB
            PaymentDb.InsertPayment(newPayment);

            UserPayee payee = (UserPayee)Session["PaymentInProgress_payee"];

            // Set Payment success notification message
            Session["Payment_confirmation_message"]            = "Your payment to " + payee.Nickname + " for " + newPayment.Amount + "(" + newPayment.Currency + ") is " + newPayment.Status + ". Thank you!";
            Session["Payment_confirmation_message_play_count"] = 0;

            // Dump the UserPayee in Session
            Session["PaymentInProgress_payee"] = null;

            // Redirect to Account Home
            Response.Redirect("/Account/Default");
        }
        public async Task TestCreatePaymentInactiveMerchant()
        {
            Merchant.Active = false;
            await PaymentDb.SaveChangesAsync();

            var paymentRequest = GetPaymentRequest();
            var response       = await Subject.PostPayment(paymentRequest);

            Assert.IsInstanceOfType(response.Result, typeof(BadRequestObjectResult));
            Assert.IsNull(response.Value);
        }
        public async Task TestGetPaymentNotCurrentMerchant()
        {
            var payment = GetPayment(UnknownMerchantId);

            PaymentDb.Payments.Add(payment);
            await PaymentDb.SaveChangesAsync();

            var response = await Subject.GetPayment(payment.Id);

            Assert.IsInstanceOfType(response.Result, typeof(NotFoundResult));
            Assert.IsNull(response.Value);
        }
 internal static Payment ToDTO(this PaymentDb paymentDb)
 {
     return(new Payment
     {
         Id = paymentDb.Id,
         Month = paymentDb.Month,
         ClientId = paymentDb.ClientId,
         TotalPayment = paymentDb.TotalPayment,
         Client = paymentDb.Client.ToDTO(),
         Line = paymentDb.Line.ToDTO(),
         LineId = paymentDb.LineId
     });
 }
        public async Task TestGetPaymentsEmpty()
        {
            var payments = new[]
            {
                GetPayment(UnknownMerchantId),
            };

            PaymentDb.Payments.AddRange(payments);
            await PaymentDb.SaveChangesAsync();

            var response = await Subject.GetPayments();

            var paymentsResponse = response.Value.ToArray();

            Assert.AreEqual(0, paymentsResponse.Length);
        }
        protected void SubmitMassPayee_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("REPEATER HAS: " + PayeeList.Items.Count);

            int i = 0;

            //for (int i = 0; i < PayeeList.Items.Count; i++)
            foreach (RepeaterItem item in PayeeList.Items)
            {
                // Amount
                TextBox      txtAmount        = (TextBox)item.FindControl("txtAmount");
                TextBox      txtCurrency      = (TextBox)item.FindControl("txtCurrency");
                DropDownList ddlFundingSource = (DropDownList)item.FindControl("ddlFundingSource");
                HiddenField  hdnField         = (HiddenField)item.FindControl("hdnField");

                Debug.WriteLine("AMOUNTS HAS: " + txtAmount.Text);                // Has Valye from Form
                Debug.WriteLine("Funding IS: " + ddlFundingSource.SelectedValue); // Has Valye from Form
                Debug.WriteLine("UserPayee IS: " + hdnField.Value);               // Has Valye from Form

                // todo - Insert to DB
                // Create Payment
                OnlineBillPay.Models.Payment newPayment = new OnlineBillPay.Models.Payment();
                newPayment.PaymentId       = System.Guid.NewGuid().ToString().ToUpper();
                newPayment.UserPayeeId     = hdnField.Value;
                newPayment.FundingSourceId = ddlFundingSource.SelectedValue;
                newPayment.UserId          = User.Identity.GetUserId();
                newPayment.Amount          = float.Parse(txtAmount.Text);
                newPayment.DateCreated     = DateTime.Now;
                newPayment.Currency        = txtCurrency.Text;
                newPayment.Status          = "Pending";

                // Store into DB
                PaymentDb.InsertPayment(newPayment);
                i++;
            }

            // Set Payment success notification message
            Session["Payment_confirmation_message"]            = "Your " + i + " payments were posted. Thank you!";
            Session["Payment_confirmation_message_play_count"] = 0;

            // Dump the UserPayee in Session
            Session["PaymentInProgress_payee"] = null;

            // Redirect to Account Home
            Response.Redirect("/Account/Default");
        }
        public async Task TestGetPaymentSuccess()
        {
            var payment = GetPayment(Merchant.Id);

            PaymentDb.Payments.Add(payment);
            await PaymentDb.SaveChangesAsync();

            var response = await Subject.GetPayment(payment.Id);

            var paymentResponse = response.Value;

            Assert.AreEqual(payment.Id, paymentResponse.Id);
            Assert.AreEqual(payment.Status, paymentResponse.Status);
            Assert.AreEqual(payment.Amount, paymentResponse.Amount);
            Assert.AreEqual(payment.Currency, paymentResponse.Currency);
            Assert.AreEqual(payment.ExpiryMonth, paymentResponse.ExpiryMonth);
            Assert.AreEqual(payment.ExpiryYear, paymentResponse.ExpiryYear);
            Assert.AreEqual("XXXXXX" + payment.CardLastDigits, paymentResponse.MaskedCardNumber);
        }
        public override async Task Setup()
        {
            await base.Setup();

            BankRegistry = new Mock <IBankRegistry>();
            Merchant     = new Merchant
            {
                AcquirerType   = AcquirerType.MasterCard,
                Active         = true,
                HashedPassword = "******",
                Id             = 1,
                Login          = "******",
                Salt           = EncryptionService.GenerateSalt(),
                Name           = "Some Merchant"
            };
            PaymentDb.Merchants.Add(Merchant);
            await PaymentDb.SaveChangesAsync();

            Acquirer = new Mock <IAcquirer>();
            BankRegistry.Setup(t => t.GetAcquirer(Merchant))
            .Returns(Acquirer.Object);
            Subject = new PaymentsController(PaymentDb, BankRegistry.Object, EncryptionService);
            SetMerchantId(Subject, Merchant.Id);
        }
Esempio n. 9
0
        public PaymentService(String dbType)
        {
            DbFactory dbf = new DbFactory();

            payments = dbf.GetDatabase(dbType);
        }