Пример #1
0
class tester(TestCase):
    # valid cart luhn10 tests
    def test_valid_ID1(self):
        card_number = "5454545454545454"
        self.card = CreditCard("Kshitij", "5454545454545454", 5000)
        self.assertEqual(self.card.valid_card(card_number), True)

    def test_valid_ID2(self):
        card_number = "1234567890123456"
        self.card = CreditCard("Quincy", "1234567890123456", 8000)
        self.assertEqual(self.card.valid_card(card_number), False)

    def test_valid_ID3(self):
        card_number = "2128529407"
        self.card = CreditCard("Braintree", "2128529407", 9000)
        self.assertEqual(self.card.valid_card(card_number), True)

    # All of these tests test the input class, creating an account, charging, crediting and some edge cases
    def test_single_input(self):
        self.inputter = Input(['Add Lisa 5454545454545454 $3000'])
        self.assertEqual(len(self.inputter.card_book), 1)

    def test_multiple_input(self):
        input_line = [
            'Add Lisa 5454545454545454 $3000', 'Add Kshitij 79927398713 $6000'
        ]
        processor = Input(input_line)
        output = processor.card_book
        self.assertEqual(len(processor.card_book), 2)

    #inputting same person, should overwrite, thus keeping the dictionary with 1 key value
    def test_same_input(self):
        input_line = [
            'Add Kshitij 79927398713 $6000', 'Add Kshitij 79927398713 $6000'
        ]
        processor = Input(input_line)
        output = processor.card_book
        self.assertEqual(len(processor.card_book), 1)

    def test_charge_credit_account(self):
        self.inputter = Input([
            'Add Lisa 5454545454545454 $3000', 'Charge Lisa $8',
            'Credit Lisa $100'
        ], )
        value = self.inputter.card_book['Lisa'].get_balance()
        self.assertEqual(value, -92)

    def test_decline_card(self):
        self.decliner = Input([
            'Add Tom 4111111111111111 $1000', 'Charge Tom $650',
            'Charge Tom $800'
        ])
        val = self.decliner.card_book['Tom'].get_balance()
        self.assertEqual(val, 650)
Пример #2
0
	def __init__(self, customer, bank, acnt, limit, apr):
		''' Create a new predatory credit card instance.

		The initial balance is zero.

		customer 	the name of the customer (e.g., 'Sebastian Valencia')
		bank 		the name of the bank (e.g., 'California Savings')
		acnt 		the account identifier (e.g., '5391 0375 9387 5309')
		limit 		credit limit (measured in dollars)
		apr 		annual percentage rate (e.g., 0.0825 for 8.25 APR)
		'''

		CreditCard.__init__(self, customer, bank, acnt, limit)
		self.apr = apr
Пример #3
0
    def __init__(self, customer, bank, acnt, limit, apr):
        ''' Create a new predatory credit card instance.

		The initial balance is zero.

		customer 	the name of the customer (e.g., 'Sebastian Valencia')
		bank 		the name of the bank (e.g., 'California Savings')
		acnt 		the account identifier (e.g., '5391 0375 9387 5309')
		limit 		credit limit (measured in dollars)
		apr 		annual percentage rate (e.g., 0.0825 for 8.25 APR)
		'''

        CreditCard.__init__(self, customer, bank, acnt, limit)
        self.apr = apr
Пример #4
0
def populate_database():
    """Populate the database."""
    emp = Employees(123456, 'Sammy', 'Retail Applications', 'IT Analyst')
    emp1 = Employees(5678, 'Nancy', 'Capital Market', 'Teller')
    emp.create_employees()
    emp1.create_employees()

    cust = Customer(123, 'John', '*****@*****.**', '1-233-2234')
    cust1 = Customer(5678, 'Katherine', '*****@*****.**', '1-456-4578')
    cust2 = Customer(6788, 'Vijay', '*****@*****.**', '1-678-5555')
    cust.create_customer()
    cust1.create_customer()
    cust2.create_customer()

    bank_Acc = BankAccount(1234444, 123, 'Chequing', 100)
    bank_Acc.create_Bank_Account()

    bank_Acc1 = BankAccount(567888, 5678, 'Saving', 200)
    bank_Acc1.create_Bank_Account()

    bank_Acc2 = BankAccount(1677777, 6788, 'Chequing', 400)
    bank_Acc2.create_Bank_Account()

    creditCard = CreditCard('Ms', 'Nancy', 'Smith', '15 Bloor St, Toronto',
                            14566666, 'May', 2023, '677', 'Visa', 'CAD')
    creditCard.create_Credit_Account()
    creditCard1 = CreditCard('Mr', 'Sam', 'Rogers', '15 Upland St, Toronto',
                             8999666, 'Aug', 2021, '127', 'Visa', 'CAD')
    creditCard1.create_Credit_Account()
Пример #5
0
 def purchase(self):
     if request.method == 'GET':
         d = dict()
         d['totalCost'] = self.purchaseInfo['totalCost']
         return render_template('purchase.html', purchaseInfo=d)
     if request.method == 'POST':
         cardNumber = request.form.get('cardNumber')
         securityCode = request.form.get('securityCode')
         cardType = request.form.get('cardType')
         expireMonth = request.form.get('expireMonth')
         expireYear = request.form.get('expireYear')
         expireDate = expireMonth + '/' + expireYear
         ##-- Template Pattern --##
         if cardType == "credit":
             payPass = CreditCard(cardNumber, securityCode,
                                  expireDate).PaymentSummary()
         else:
             payPass = DebitCard(cardNumber, securityCode,
                                 expireDate).PaymentSummary()
         if payPass == 1:
             self.purchaseInfo['cardNumber'] = cardNumber
             self.purchaseInfo['expireDate'] = expireDate
             self.model.addPurchase(self.purchaseInfo)
         else:
             print("Sorry your card did not go through the system")
         return redirect(url_for('dashboard'))
Пример #6
0
def AlwaysDatedCard():
    someName = random.choice("aabbcccdde  effgghhii")
    cardNumber = random.randint(1111111111111111, 9999999999999999)
    today = datetime.date.today()
    expirationDate = today - datetime.timedelta(days=today.day + 1)

    return CreditCard(someName, cardNumber,
                      MonthYear(expirationDate.month, expirationDate.year))
Пример #7
0
 def checkout(self, cartID, aCardOwner, aCardNumber, aCardExpirationDate):
     session = self.getSession(cartID)
     with session:
         cart = session.cart
         aCreditCard = CreditCard(aCardOwner, aCardNumber,
                                  aCardExpirationDate)
         cashier = Cashier(self.merchantProcessor, cart, aCreditCard,
                           session.clientId, self.salesBook)
         cashier.checkout()
Пример #8
0
	def charge(self, price):
		''' Charge given price to the card, assuming sufficient
			credit limit.

		Return True if charge was processed
		Return False and assess $5 fee if charge is denied
		'''

		success = CreditCard.charge(self, price)
		if not success:
			self.balance += 5
		return success
Пример #9
0
    def charge(self, price):
        ''' Charge given price to the card, assuming sufficient
			credit limit.

		Return True if charge was processed
		Return False and assess $5 fee if charge is denied
		'''

        success = CreditCard.charge(self, price)
        if not success:
            self.balance += 5
        return success
Пример #10
0
def creditCardCreate(creditCard):
    c = creditCard
    dbAcnt = CreditCard(name=c['name'],
                        description=c['description'],
                        cardNumber=c['cardNumber'],
                        cardType=c['cardType'],
                        creditLimit=c['creditLimit'],
                        availCreditLimit=c['availCreditLimit'],
                        availCashLimit=c['availCashLimit'],
                        outstandingTotal=c['outstandingTotal'],
                        holdersName=c['holdersName']).save()
    print("Credit Card", colored(dbAcnt.name), "created")
Пример #11
0
 def alwaysDatedCard(self):
     someName = self.validCardOwner()
     cardNumber = self.validCardNumber()
     today = datetime.date.today()
     month_year = self.datedCardExpirationDate(today)
     return CreditCard(someName, cardNumber, month_year)
from CreditCard import CreditCard

wallet = CreditCard('Lateema Spencer', 'California Savings',
                    '5391 0375 9387 5309', 100)
print('Customer =', wallet.get_customer())
print('Bank =', wallet.get_bank())
print('Account =', wallet.get_account())
print('Limit =', wallet.get_limit())
print('Balance =', wallet.get_balance())
while wallet.get_balance() > 100:
    wallet.make_payment(100)
    print('New Balance =', wallet.get_balance())
print()
Пример #13
0
from CreditCard import CreditCard

my_customers = []
if __name__ == "__main__":
    my_customers.append(CreditCard("tomi", "gtb", "3465 7896 5868 3452", 3000))
    my_customers.append(CreditCard("tunji", "gtb", "3788 3756 0978 5482",
                                   2500))
    my_customers.append(CreditCard("remi", "gtb", "5096 9796 9563 0375", 5000))

    for val in range(17):
        my_customers[0].charge(val)
        my_customers[1].charge(2 * val)
        my_customers[2].charge(3 * val)

    for c in range(3):
        print("Customer:", my_customers[c].get_customer())
        print("Bank:", my_customers[c].get_bank())
        print("Account:", my_customers[c].get_account())
        print("Limit:", my_customers[c].get_limit())
        print("Balance:", my_customers[c].get_balance())
        while my_customers[c].get_balance() > int(100):
            my_customers[c].make_payment(100)
            print("New balance:", my_customers[c].get_balance())
        print()
Пример #14
0
def ValidCard():
    someName = random.choice("aabbcccdde  effgghhii")
    cardNumber = random.randint(1111111111111111, 9999999999999999)
    expirationDate = datetime.date.today() + datetime.timedelta(days=365)
    return CreditCard(someName, cardNumber,
                      MonthYear(expirationDate.year, expirationDate.month))
Пример #15
0
 def create_account(self, line):
     add, given_name, card_number, limit = line
     # limit is still a "$XXXX" we need to change it to an integer
     limit = int(limit[1:])
     # add a person to the map, where their name is the key and the value it holds is their credit card info
     self.card_book[given_name] = CreditCard(given_name, card_number, limit)
Пример #16
0
def main():
    # begin PERSON_TEST
    print("\nPerson Test")
    bob = Person()
    marge = Person("Marge", "Inovera", "321 Stats Lane")

    print("Displaying Bob (all should be blank)")
    print(" First Name: " + bob.getFirstName(), end=", ")
    print("Last Name: " + bob.getLastName(), end=", ")
    print("Address: " + bob.getAddress())

    print("\nMarge, expected output is")
    print(" First Name: Marge, Last Name: Inovera, Address: 321 Stats Lane")
    print("Actual Result")
    print(" First Name: " + marge.getFirstName(), end=", ")
    print("Last Name: " + marge.getLastName(), end=", ")
    print("Address: " + marge.getAddress())

    # end PERSON_TEST

    # begin CC_TEST
    print("\n\nCredit Card Test")
    try:
        discover = CreditCard("Lou", "Pole", "456 Haven Ave", 8675309, 5000)
        print("Card Number - Expected: 8675309, Actual: " + str(discover.getCardNumber()))
        print("Card Holder Name - Expected: Lou Pole, Actual: " + discover.getOwnerName())
        print("Address - Expected: 456 Haven Ave, Actual: " + discover.getAddress())
        print("Credit Limit - Expected: 5000, Actual: " + str(discover.getCreditLimit()))
        print("Balance - Expected: 0, Actual: " + str(discover.getBalance()))

        if discover.makeCharge(3000):
            print("\nCharge of 3000 applied correctly")
        else:
            print("\nCharge failed")
        print("Balance - Expected: 3000, Actual: " + str(discover.getBalance()))

        if discover.makeCharge(4000):
            print("\nAdditional Charge of 4000 allowed in error")
        else:
            print("\nCard declined correctly")
        print("Balance - Expected: 3000, Actual: " + str(discover.getBalance()))

        if discover.makeCharge(-500):
            print("\nNegative charge allowed in error")
        else:
            print("\nNegative charge denied correctly")
        print("Balance - Expected: 3000, Actual: " + str(discover.getBalance()))

        if discover.payBalance(400):
            print("\nPayment of 400 accepted correctly")
        else:
            print("\nPayment denied in error")
        print("Balance - Expected: 2600, Actual: " + str(discover.getBalance()))

        if discover.payBalance(-500):
            print("\nNegative payment accepted in error")
        else:
            print("\nNegative payment denied correctly")
        print("Balance - Expected: 2600, Actual: " + str(discover.getBalance()))

        print("\nNow setting credit limit to 10000")
        discover.setCreditLimit(10000)
        print("Credit Limit - Expected: 10000, Actual: " + str(discover.getCreditLimit()))

        if discover.makeCharge(4000):
            print("\nAdditional charge of 4000 applied correctly")
        else:
            print("\nCharge denied in error")
        print("Balance - Expected: 6600, Actual: " + str(discover.getBalance()))

        if discover.setCreditLimit(5000):
            print("\nCredit Limit reduced below current balance correctly.")
        else:
            print("Balance modification failed in error")
        print("Credit Limit - Expected: 5000, Actual: " + str(discover.getCreditLimit()))
        print("Balance - Expected: 6600, Actual: " + str(discover.getBalance()))

        if discover.makeCharge(5):
            print("\nAdditional Charge of 5 allowed in error")
        else:
            print("\nCard declined correctly")
        print("Balance - Expected: 6600, Actual: " + str(discover.getBalance()))

        if discover.payBalance(7000):
            print("\nPayment of 7000 accepted correctly")
        else:
            print("\nPayment denied in error")
        print("Balance - Expected: -400, Actual: " + str(discover.getBalance()))
    except NameError:
        print("Credit Card not implemented")
Пример #17
0
 def test_valid_ID1(self):
     card_number = "5454545454545454"
     self.card = CreditCard("Kshitij", "5454545454545454", 5000)
     self.assertEqual(self.card.valid_card(card_number), True)
Пример #18
0
from CreditCard import CreditCard

if __name__ == '__main__':
    wallet = []
    wallet.append(
        CreditCard('John Bowman', 'California Savings', '5391 0375 9387 5309',
                   2500))
    wallet.append(
        CreditCard('John Bowman', 'California Federal', '3485 0399 3395 1954',
                   3500))
    wallet.append(
        CreditCard('John Bowman', 'California Finance', '5391 0375 9387 5309',
                   5000))

    for val in range(1, 17):
        wallet[0].charge(val)
        wallet[1].charge(2 * val)
        wallet[2].charge(3 * val)

    for c in range(3):
        print('Customer =', wallet[c].get_customer())
        print('Bank =', wallet[c].get_bank())
        print('Account =', wallet[c].get_account())
        print('Limit =', wallet[c].get_limit())
        print('Balance =', wallet[c].get_balance())

        while wallet[c].get_balance() > 100:
            wallet[c].make_payment(100)
            print('New Balance =', wallet[c].get_balance())
        print()
Пример #19
0

def test_creditcard_class(cc, pay=0):
    # Tests the CreditCard class

    print("Current CC details:")
    print(cc.to_string())

    print("Getting class attributes using methods...")
    print("Getting customer name...\n" + cc.get_customer())
    print("Getting bank...\n" + cc.get_bank())
    print("Getting accnt number...\n" + cc.get_account())
    print("Getting balance...\n" + str(cc.get_balance()))
    print("Getting limit...\n" + str(cc.get_limit()) + "\n")

    print("Making payment of " + str(pay) + "...")
    cc.make_payment(pay)


if __name__ == "__main__":

    test_flower_class("Rose", 20, 4)

    #Card instance with no initial balance
    card = CreditCard("Chezka", "WF", "1111 2222 3333 4444", 10000)
    test_creditcard_class(card)

    #Card instance with initial balance
    card_init_balance = CreditCard("Franchezka", "WF", "1234 1234 1234 1234",
                                   10000, 500)
    test_creditcard_class(card_init_balance, -15)
Пример #20
0
from CreditCard import CreditCard

c1 = CreditCard("Brian", "The Bank", 12345, 7)
print(c1.get_customer())
c1.charge(1.5)
print(c1.get_balance())
c1.make_payment(.6)
print(c1.get_balance())
Пример #21
0
from CreditCard import CreditCard

wallet = []
wallet.append(CreditCard('Ankur Raina', 'CITI', '111122223333', 100000))
wallet.append(CreditCard('Ravi', 'AXIS', '222333444', 100000))
wallet.append(CreditCard('Vivek', 'KOTAK', '555666777', 120000))
wallet.append(CreditCard('Manish', 'UNION', '999777888', 150000))

for val in range(1, 18):
    wallet[0].charge(val)
    wallet[1].charge(2 * val)
    wallet[2].charge(3 * val)

for c in range(3):
    print('Customer =', wallet[c].get_customer())
    print('Bank =', wallet[c].get_bank())
    print('Account =', wallet[c].get_account())
    print('Limit =', wallet[c].get_limit())
    print('Balance =', wallet[c].get_liability())
    while wallet[c].get_liability() > 100:
        wallet[c].make_payment(100)
        print('New balance =', wallet[c].get_liability())
    print()
Пример #22
0
def classtest(val):
    cc = CreditCard('John','1st bank','345 333 5566',1000)
    cc.charge(345)
    val = cc.get_balance()
    print(val)
Пример #23
0
    def validCard(self):
        someName = self.validCardOwner()
        cardNumber = self.validCardNumber()
        month_year = self.validCardExpirationDate()

        return CreditCard(someName, cardNumber, month_year)
Пример #24
0
 def test_valid_ID2(self):
     card_number = "1234567890123456"
     self.card = CreditCard("Quincy", "1234567890123456", 8000)
     self.assertEqual(self.card.valid_card(card_number), False)
Пример #25
0
 def test_valid_ID3(self):
     card_number = "2128529407"
     self.card = CreditCard("Braintree", "2128529407", 9000)
     self.assertEqual(self.card.valid_card(card_number), True)
 def collectPaymentDetails(self):
     num = input("Digite o número do cartão: ")
     date = input("Digite a data de experição do cartão mm/yy: ")
     cvv = input("Digite o código de segurança no verso do cartão (CVV): ")
     self.creditCard = CreditCard(num, date, cvv)