Example #1
0
def post_handler():
    uri = request.form['paytoken']
    if apini.is_payed(uri):
        return render_template('resultpage.html', paid=True, good=False)
    else:
        result = braintree.Transaction.sale({
            "amount":
            apini.get_amount(uri),
            "payment_method_nonce":
            request.form['payment_method_nonce'],
            "options": {
                "submit_for_settlement": True
            }
        })
        if result.is_success:
            apini.mark_as_payed(uri)
            parts = apini.get_transaction_parts(uri)
            sender = parts[0]
            recipient = parts[1]
            amount = parts[2]
            elks.has_payed(recipient, sender, amount)
            return render_template('resultpage.html', good=True, paid=False)
        else:
            return render_template('resultpage.html',
                                   good=False,
                                   paid=False,
                                   uri=uri)
Example #2
0
def pay(payid):
    if apini.is_payed(payid):
        return render_template('resultpage.html', paid=True, good=False)
    braintree.Configuration.configure(braintree.Environment.Sandbox,
                                      merchant_id=os.environ['BT_MERCHANT_ID'],
                                      public_key=os.environ['BT_PUBLIC_KEY'],
                                      private_key=os.environ['BT_PRIVATE_KEY'])
    token = braintree.ClientToken.generate()
    amount = apini.get_amount(payid)
    return render_template('payform.html',
                           amount=amount,
                           token=token,
                           uri=payid)
Example #3
0
def pay(payid):
    if apini.is_payed(payid):
        return render_template('resultpage.html', paid=True, good=False)
    braintree.Configuration.configure(braintree.Environment.Sandbox,
        merchant_id=os.environ['BT_MERCHANT_ID'],
        public_key=os.environ['BT_PUBLIC_KEY'],
        private_key=os.environ['BT_PRIVATE_KEY'])
    token = braintree.ClientToken.generate()
    amount = apini.get_amount(payid)
    return render_template('payform.html',
                           amount=amount,
                           token=token,
                           uri=payid)
Example #4
0
def post_handler():
    uri = request.form['paytoken']
    if apini.is_payed(uri):
        return render_template('resultpage.html', paid=True, good=False)
    else:
        result = braintree.Transaction.sale({
            "amount": apini.get_amount(uri),
            "payment_method_nonce": request.form['payment_method_nonce'],
            "options": {
                "submit_for_settlement": True
            }
        })
        if result.is_success:
            apini.mark_as_payed(uri)
            parts = apini.get_transaction_parts(uri)
            sender = parts[0]
            recipient = parts[1]
            amount = parts[2]
            elks.has_payed(recipient, sender, amount)
            return render_template('resultpage.html', good=True, paid=False)
        else:
            return render_template('resultpage.html', good=False, paid=False, uri=uri)