示例#1
0
    // method to get payment by paymentID from the database
    public static PaymentPay getPaymentbyID(string payID)
    {
        PaymentPay pay = new PaymentPay();

        try
        {
            SqlCommand command = new SqlCommand("Select * from Payment WHERE paymentID = @paymentID");
            command.Parameters.AddWithValue("@paymentID", payID);
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            if (reader.Read())
            {
                readAPayment(ref pay, ref reader);
            }
            else
            {
                pay = new PaymentPay(null, null);
            }

            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(pay);
    }
示例#2
0
    // method to get all payments from the database
    public static List <PaymentPay> getAllPayment()
    {
        List <PaymentPay> paymentList = new List <PaymentPay>();

        try
        {
            SqlCommand command = new SqlCommand("Select * from Payment");
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                PaymentPay p = new PaymentPay();
                readAPayment(ref p, ref reader);

                paymentList.Add(p);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(paymentList);
    }
示例#3
0
 // constructor for Extension
 public Extension(string extensionID, string newReturnLocation, TimeSpan newReturnTime, DateTime newEndDate, string unit, string status, decimal extensionRentalFee, PaymentPay payment, Rental rental)
 {
     ExtensionID       = extensionID;
     NewReturnLocation = newReturnLocation;
     NewReturnTime     = newReturnTime;
     NewEndDate        = newEndDate;
     Unit               = unit;
     Status             = status;
     ExtensionRentalFee = extensionRentalFee;
     Payment            = payment;
     Rental             = rental;
 }
示例#4
0
    // method to add payment into the database, takes in parameter of Payment type
    public static int addPayment(PaymentPay pay)
    {
        try
        {
            SqlCommand command = new SqlCommand("INSERT INTO Payment (stripeRefNum) values (@stripeRefNum)");
            command.Parameters.AddWithValue("@stripeRefNum", pay.StripeRefNum);

            command.Connection = connection;
            connection.Open();

            if (command.ExecuteNonQuery() > 0)
            {
                return(1);
            }
        }
        finally
        {
            connection.Close();
        }
        return(-1);
    }
示例#5
0
 // constructor for Rental
 public Rental(string rentalID, string pickUpLocation, TimeSpan pickUpTime, string returnLocation,
               TimeSpan returnTime, decimal rentalFee, string unit, decimal deposit, DateTime dateCreated, DateTime startDate,
               DateTime endDate, string status, string paymentReleaseCode, string depositRetrievalCode, Item itemID,
               PaymentPay payment, Member renteeID)
 {
     RentalID             = rentalID;
     PickUpLocation       = pickUpLocation;
     PickUpTime           = pickUpTime;
     ReturnLocation       = returnLocation;
     ReturnTime           = returnTime;
     RentalFee            = rentalFee;
     Unit                 = unit;
     Deposit              = deposit;
     DateCreated          = dateCreated;
     StartDate            = startDate;
     EndDate              = endDate;
     Status               = status;
     PaymentReleaseCode   = paymentReleaseCode;
     DepositRetrievalCode = depositRetrievalCode;
     Item                 = itemID;
     Payment              = payment;
     Rentee               = renteeID;
 }
示例#6
0
 // method to read the column values in the database (through the referenced reader) and assign it to the correct properties of the referenced Payment object
 // allows for easier editing of column names if needed, used only for methods with select statments regarding Payment
 private static void readAPayment(ref PaymentPay pay, ref SqlDataReader reader)
 {
     pay.PaymentID    = reader["paymentID"].ToString();
     pay.StripeRefNum = reader["stripeRefNum"].ToString();
 }
示例#7
0
    protected void btnPay_Click(object sender, EventArgs e)
    {
        // submit payment

        Item itemInfo = ItemDB.getItembyID(Request.QueryString["itemID"]);

        Member mem = MemberDB.getMemberbyEmail(Session["user"].ToString());

        Rental rentInfo = (Rental)Session["rental"];
        var    myCharge = new StripeChargeCreateOptions();

        myCharge.Amount   = Convert.ToInt32(rentInfo.RentalFee) * 100;
        myCharge.Currency = "sgd";

        myCharge.SourceCard = new SourceCard()
        {
            Number          = "4242424242424242",
            ExpirationYear  = 2022,
            ExpirationMonth = 10,
            AddressCountry  = "SG",                      // optional
            AddressLine1    = mem.Address,               // optional
            AddressLine2    = mem.Address,               // optional
            AddressCity     = "Singapore",               // optional
            AddressState    = "NC",                      // optional
            AddressZip      = mem.PostalCode.ToString(), // optional
            Name            = mem.Name,                  // optional
            Cvc             = "1223"                     // optional
        };
        var          chargeService = new StripeChargeService();
        StripeCharge stripeCharge  = chargeService.Create(myCharge);

        PaymentPay pay = new PaymentPay();

        pay.StripeRefNum = Utility.getRandomizedChar(5, 0);

        string n         = Session["rentalPeriod"].ToString();
        string startDate = n.Substring(0, 10);
        string endDate   = n.Substring(n.Length - 10);

        if (Session["itemExtension"].ToString() == "NotExtension")
        {
            rentInfo.DateCreated        = DateTime.Now;
            rentInfo.Deposit            = itemInfo.Deposit;
            rentInfo.PaymentReleaseCode = Utility.getRandomizedChar(6, 0);
            rentInfo.Item = itemInfo;

            rentInfo.StartDate = Convert.ToDateTime(startDate);
            rentInfo.EndDate   = Convert.ToDateTime(endDate);
            rentInfo.Status    = "Scheduled";

            rentInfo.Payment = PaymentDB.getPaymentbyID(Utility.convertIdentitytoPK("PAY", PaymentDB.addPayment(pay)));
            rentInfo.Rentee  = mem;
            rentInfo.Unit    = "Day";

            Response.Redirect("RentalDetails.aspx?rentalID=" + Utility.convertIdentitytoPK("RNT", RentalDB.addRental(rentInfo)));
        }
        else
        {
            Rental rent = RentalDB.getRentalbyID(Request.QueryString["rentalID"]);

            Extension ext = new Extension();

            ext.ExtensionRentalFee = rentInfo.RentalFee;
            ext.NewEndDate         = Convert.ToDateTime(endDate);
            ext.NewReturnLocation  = rent.ReturnLocation;
            int paymentID = PaymentDB.addPayment(pay);

            pay.PaymentID     = Utility.convertIdentitytoPK("PAY", paymentID);
            ext.NewReturnTime = rent.ReturnTime;
            ext.Payment       = pay;

            ext.Rental = rent;
            ext.Status = "Granted";
            ext.Unit   = "Day";

            ExtensionDB.addExtension(ext);

            Response.Redirect("RentalDetails.aspx?rentalID=" + Request.QueryString["rentalID"]);
        }
    }
示例#8
0
    protected void btnPay_Click(object sender, EventArgs e)
    {
        Item itemInfo = ItemDB.getItembyID(Request.QueryString["itemID"]);

        Member mem = MemberDB.getMemberbyEmail(Session["user"].ToString());

        var myCharge = new StripeChargeCreateOptions();

        myCharge.Amount   = 50;
        myCharge.Currency = "sgd";

        myCharge.SourceCard = new SourceCard()
        {
            Number          = "4242424242424242",
            ExpirationYear  = 2022,
            ExpirationMonth = 10,
            AddressCountry  = "SG",                      // optional
            AddressLine1    = mem.Address,               // optional
            AddressLine2    = mem.Address,               // optional
            AddressCity     = "Singapore",               // optional
            AddressState    = "NC",                      // optional
            AddressZip      = mem.PostalCode.ToString(), // optional
            Name            = mem.Name,                  // optional
            Cvc             = "1223"                     // optional
        };
        var          chargeService = new StripeChargeService();
        StripeCharge stripeCharge  = chargeService.Create(myCharge);

        Rental rent = new Rental();

        rent.DateCreated          = DateTime.Now;
        rent.Deposit              = itemInfo.Deposit;
        rent.DepositRetrievalCode = Utility.getRandomizedChar(6, 1);
        rent.PaymentReleaseCode   = Utility.getRandomizedChar(6, 1);
        rent.PickUpLocation       = Session["pickUpLocation"].ToString();

        DateTime pickUpTime = DateTime.ParseExact(Session["pickUpTime"].ToString(),
                                                  "hh:mm tt", CultureInfo.InvariantCulture);
        TimeSpan pickUpTimeSpan = pickUpTime.TimeOfDay;

        DateTime returnTime = DateTime.ParseExact(Session["returnTime"].ToString(),
                                                  "hh:mm tt", CultureInfo.InvariantCulture);
        TimeSpan returnTimeSpan = returnTime.TimeOfDay;

        rent.PickUpTime = pickUpTimeSpan;
        rent.ReturnTime = returnTimeSpan;

        rent.ReturnLocation = Session["returnLocation"].ToString();
        rent.Item           = itemInfo;


        string n         = Session["rentalPeriod"].ToString();
        string startDate = n.Substring(0, 10);
        string endDate   = n.Substring(n.Length - 10);

        rent.StartDate = Convert.ToDateTime(startDate);
        rent.EndDate   = Convert.ToDateTime(endDate);
        rent.Status    = "Scheduled";

        PaymentPay pay = new PaymentPay();


        pay.StripeRefNum = Utility.getRandomizedChar(5, 1);

        rent.Payment = PaymentDB.getPaymentbyID(Utility.convertIdentitytoPK("PAY", PaymentDB.addPayment(pay)));

        rent.Rentee = mem;


        rent.Unit = "Day";

        Response.Redirect("RentalDetails.aspx?rentalID=" + Utility.convertIdentitytoPK("RNT", RentalDB.addRental(rent)));
    }