Ejemplo n.º 1
0
def generate_card_with_four_end(num):
    card_generator = CreditCard.completed_number(list(str(num)), 16)
    card_generator = card_generator[-4:] + card_generator[
        4:-4] + card_generator[:4]
    while not is_luhn_valid(card_generator):
        card_generator = CreditCard.completed_number(list(str(num)), 16)
        card_generator = card_generator[-4:] + card_generator[
            4:-4] + card_generator[:4]
    return card_generator
Ejemplo n.º 2
0
 def test06_check_out_is_stopped_when_merchant_processor_rejects_payment(
         self):
     try:
         self.cashier.check_out(
             self.shopping_cart_with_a_book,
             CreditCard(
                 "hola",
                 self._test_objects_factory.a_stolen_credit_card_number(),
                 MonthOfYear(6,
                             datetime.now().year + 1)))
         self.fail()
     except Exception as thrown_exception:
         self.assertEqual(
             str(thrown_exception),
             MockMerchantProcessor.generic_rejected_payment_error_message())
         self.assertFalse(self.ledger)
def test_object_creation_non_default_paremeters():
    card = CreditCard.CreditCard('Jane Doe', 10000, 0.16)
    assert card.get_name() == 'Jane Doe'
    assert card.get_limit() == 10000
    assert card.get_balance() == 0.16
 def an_expired_credit_card(self):
     june_last_year = MonthOfYear(6, self.now().year - 1)
     return CreditCard('Juan Perez', "1234567891234567", june_last_year)
 def a_valid_credit_card(self):
     june_next_year = MonthOfYear(6, self.now().year + 1)
     return CreditCard('Juan Perez', "1234567891234567", june_next_year)
Ejemplo n.º 6
0
import CreditCard as CC
"""
The Constructor
"""

cc = CC.CreditCard('John Doe', '1st Bank', '5391 0375 9387 5309', 1000)

print("Second Module's Name: {}".format(__name__))
print(cc.get_balance())
Ejemplo n.º 7
0
def generate_card_with_prefix(num):
    card_generator = CreditCard.completed_number(num, 16)
    return card_generator
Ejemplo n.º 8
0
 def creditCard(self, account):
     LoginSupport.destroy_window()
     CreditCard.vp_start_gui(account, accountid)
Ejemplo n.º 9
0
 def getCardInfo(self, BookTicket):
     print("Enter the card number(16)")
     cnum = input()
     self.creditCard = CreditCard.CreditCard(cnum)
     self.getOrderInfo(BookTicket)
Ejemplo n.º 10
0
 def setUp(self) -> None:
     self.cc1 = cc.CreditCard()
     self.cc2 = cc.CreditCard(10.0, 5.0, 0.2)
import CreditCard as cc
import re

number = input('Enter a credit card number: ')
while re.search('[\D]', number):
    print('Enter digits only. No spaces or nondigit Characters')
    number = input('Enter a correct credit card number: ')

while len(str(number)) not in range(12,20):
    print('Your number is either too short or too long')
    number = input('Enter another credit card number: ')
    
    
card = cc.credit_card(int(number))

if not card.usable:
    print('Sorry! Your card cannot be used to make purchase')
    print('Try another card!')
else:
    if not card.valid:
        print('That is incorrect card number!')
    elif card.valid:
        print('{} detected!'.format(card.card_type))
        print('Proceed with transaction!')
        
Ejemplo n.º 12
0
import CreditCard as cc

cc.remove_ban()
Ejemplo n.º 13
0
cardCount = int(ih.handleInput(MSG_HOW_MANY_CARDS))
cards = []
print("==================================\n")

# todo nice error handling for illegal inputs
for i in range(cardCount):
	name = ih.handleInput(MSG_CARD_NAME)
	principal = 0
	while ih.validatePricipal(principal) == False:
		principal = float(ih.handleInput(MSG_CARD_PRINCIPAL))
	rate = float(ih.handleInput(MSG_CARD_APR)) #todo check format
	months = 0
	while ih.validateMonths(months) == False:
		months = int(ih.handleInput(MSG_CARD_TIME))
	timeYears = float(months / 12.0)
	cards.append(CC.CreditCard(principal, rate, timeYears, name))
	print("==================================\n")

grandTotal = 0
for card in cards:
	# check format of rate - we want it to be a decimal i.e. 50% == .5
	# card.interest = float(card.principal * card.rate * card.timeYears)
	card = ic.calculateInterest(card)
	print("For card "+card.name+", you will pay this amount in interest:$ " + MONEY_FORMAT.format(card.interest))

	total = ic.calculateTotal(card)
	print("\tand you will pay this amount in total:$ " + MONEY_FORMAT.format(total))
	grandTotal += total
	print()

print("For all " + str(cardCount) + " cards, you will pay:$ " + MONEY_FORMAT.format(grandTotal))
def test_object_creation_default_parameters():
    card = CreditCard.CreditCard()
    assert card.get_name() == 'John Doe'
Ejemplo n.º 15
0
import CreditCard
from random import Random
from pwn import *
import re
import time

generator = Random()
generator.seed()

mastercard = CreditCard.credit_card_number(generator,
                                           CreditCard.mastercardPrefixList, 16,
                                           10)

visa16 = CreditCard.credit_card_number(generator, CreditCard.visaPrefixList,
                                       16, 10)

visa13 = CreditCard.credit_card_number(generator, CreditCard.visaPrefixList,
                                       13, 5)

amex = CreditCard.credit_card_number(generator, CreditCard.amexPrefixList, 15,
                                     5)

discover = CreditCard.credit_card_number(generator,
                                         CreditCard.discoverPrefixList, 16, 3)


def luhn_checksum(card_number):
    def digits_of(n):
        return [int(d) for d in str(n)]

    digits = digits_of(card_number)
def test_object_creation_non_default_position_parameters():
    card = CreditCard.CreditCard(name='Sudeep Hazra')
    assert card.get_name() == 'Sudeep Hazra'
    assert card.get_balance() == 0.0
    assert card.get_limit() == 0.0
import CreditCard as cc

cc.ban_cards()