当前位置: 首页>>代码示例>>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;未经允许,请勿转载。