Beispiel #1
0
def buyCards():
    cards = database.getCardTypes()
    cardTypes = []
    for i in cards:
        cardTypes.append(i[0])
    return render_template('buyCard.html',
                           year=datetime.now().year,
                           cards=cardTypes,
                           balance=database.getBalance(session['user']))
Beispiel #2
0
def redeemCard():
    for i in request.form.items():
        id = i[0]
    card = database.getCard(id)
    if not card:
        return redirect('/myCards')
    return render_template('redeemCard.html',
                           card=id,
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #3
0
def myCards():
    userCards = database.getCards(session['user'])
    for i in userCards:
        i[1] = i[1][0:i[1].find('.')]
        i[1] = datetime.strptime(
            i[1], "%Y-%m-%d %H:%M:%S").strftime("%d-%m-%y %H:%M")

    return render_template('myCards.html',
                           title='ClickNWin',
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']),
                           cards=userCards)
Beispiel #4
0
def paypalStoreReturn():
    data = {}
    data['transactionID'] = session['transactionID']
    session['transactionID'] = ""
    data['user'] = session['user']
    data['amount'] = session['amount']
    session['amount'] = ""
    database.addFunds(data['user'], data['amount'])
    return render_template('paypalStoreReturn.html',
                           data=data,
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #5
0
def topUp():
    paymentCards = database.getPaymentCards(session['user'])
    formatCards = []
    index = 0
    for i in paymentCards:
        temp = ''
        formatCards.append({'id': i[0]})
        temp = i[1][12:]
        formatCards[index]['endNo'] = temp
        formatCards[index]['cardType'] = i[2]
        index = index + 1
    return render_template('topUp.html',
                           payCards=formatCards,
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #6
0
def cardsBought():
    price = request.form['price']
    if float(price[1:]) > float(database.getBalance(session['user'])):
        flash(
            "You do not have enough funds in your account to buy these cards",
            "error")
        return redirect("/buyCards")
    sCards = {}

    if request.form['selectedUser'] == "":
        sCards['user'] = session['user']
    else:
        sCards['user'] = request.form['selectedUser']
    sCards['type'] = request.form['types']
    sCards['quantity'] = request.form['quantity']
    sCards['boughtBy'] = session['user']
    sCards['boughtOn'] = str(datetime.now())
    utils.newCards(sCards)
    database.reduceBalance(session['user'], price)
    return redirect("/myCards")
Beispiel #7
0
def balanceRedeemed():
    amount = request.form['amount']
    email = request.form['email']
    password = request.form['password']
    success = database.login(session['user'], password)
    if not success:
        flash("Incorrect password.  Try again", "error")
        return redirect('/redeemBalance')
    amount = utils.formatCurrency(amount)
    if float(amount) > float(database.getBalance(session['user'])):
        flash("you do not have enough funds in your balance.", "error")
        return redirect('/redeemBalance')
    payoutSuccess = paypalAPI.balanceRedeem(email, amount)
    if payoutSuccess:
        database.reduceBalance(session['user'], amount)
        flash(
            "Your payout was successful.  The requested funds will be available in your account shortly."
        )
        return redirect("/loginHome")
    else:
        flash("Payout Error.  Please check your details and try again",
              "error")
        return redirect('/redeemBalance')
Beispiel #8
0
def loginHome():
    return render_template('loginHome.html',
                           title='ClickNWin',
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #9
0
def receipt():
    data = session['paymentData']
    return render_template('fundsAdded.html',
                           data=data,
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #10
0
def redeemBalance():
    return render_template('redeemBalance.html',
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))
Beispiel #11
0
def addPaymentCard():
    return render_template('addPaymentCard.html',
                           year=datetime.now().year,
                           balance=database.getBalance(session['user']))