當前位置: 首頁>>代碼示例>>Python>>正文


Python Ticket.settled_currency方法代碼示例

本文整理匯總了Python中models.Ticket.settled_currency方法的典型用法代碼示例。如果您正苦於以下問題:Python Ticket.settled_currency方法的具體用法?Python Ticket.settled_currency怎麽用?Python Ticket.settled_currency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Ticket的用法示例。


在下文中一共展示了Ticket.settled_currency方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ticket_buy

# 需要導入模塊: from models import Ticket [as 別名]
# 或者: from models.Ticket import settled_currency [as 別名]
def ticket_buy(tariff_id):
    if request.method == 'POST' and int(tariff_id) in [20, 29]:
    # HOTFIX - umoznuje to volat i GETem
    # if int(tariff_id) in [20, 29]:
        phone = request.form['phone']

        ticket = Ticket(tariff=tariff_id, phone=phone)

        d = {}
        d["settled_currency"] = "CZK"
        d["return_url"] = "http://%s/notification" % request.host
        d["notify_url"] = "http://%s/notification" % request.host
        d["notify_email"] = "%s" % settings.bitcoinPayOwnerEmail
        d["price"] = tariff_id
        d["currency"] = "CZK"

        ref = {}
        ref["phone_number"] = phone
        ref["tariff"] = tariff_id
        d["reference"] = ref

        headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Token %s' % settings.bitcoinPayAuthToken
        }
        request_payment = Request('https://www.bitcoinpay.com/api/v1/payment/btc', data=json.dumps(d), headers=headers)

        response_body = urlopen(request_payment).read()

        data = json.loads(response_body)["data"]

        ticket.payment_id = data["payment_id"]
        ticket.status = data["status"]
        ticket.settled_amount = data["settled_amount"]
        ticket.settled_currency = data["settled_currency"]
        ticket.payment_response = json.dumps(data)

        db_session.add(ticket)
        db_session.commit()

        # ulozime payment id v session
        session["last_payment_id"] = ticket.payment_id
        # saving user's phone to be able to retrieve tickets overview
        session[PHONE_SESSION_KEY] = int(phone)

        return redirect(data["payment_url"], code=302)

    phone = session.get(PHONE_SESSION_KEY)
    tariff = get_tariffs(tariff_id)

    # return redirect(url_for('index'))
    return render_template('ticket_buy.html', tariff=tariff, phone=phone)
開發者ID:pavelkraleu,項目名稱:bit-brno,代碼行數:54,代碼來源:bitbrno.py


注:本文中的models.Ticket.settled_currency方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。