示例#1
0
async def api_paywal_check_invoice(paywall_id):
    paywall = get_paywall(paywall_id)

    if not paywall:
        return jsonify({"message":
                        "Paywall does not exist."}), HTTPStatus.NOT_FOUND

    try:
        is_paid = not check_invoice_status(paywall.wallet,
                                           g.data["payment_hash"]).pending
    except Exception:
        return jsonify({"paid": False}), HTTPStatus.OK

    if is_paid:
        wallet = get_wallet(paywall.wallet)
        payment = wallet.get_payment(g.data["payment_hash"])
        payment.set_pending(False)

        return jsonify({
            "paid": True,
            "url": paywall.url,
            "remembers": paywall.remembers
        }), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
示例#2
0
def api_ticket_send_ticket(payment_hash):
    ticket = get_ticket(payment_hash)
    try:
        is_paid = not check_invoice_status(ticket.wallet, payment_hash).pending
    except Exception:
        return jsonify({"message": "Not paid."}), HTTPStatus.NOT_FOUND

    if is_paid:
        wallet = get_wallet(ticket.wallet)
        payment = wallet.get_payment(payment_hash)
        payment.set_pending(False)
        ticket = update_ticket(paid=True, payment_hash=payment_hash)
        return jsonify({"paid": True, "ticket_id": ticket.id}), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
示例#3
0
def api_ticket_send_ticket(checking_id):
    theticket = get_ticket(checking_id)
    try:
        is_paid = not WALLET.get_invoice_status(checking_id).pending
    except Exception:
        return jsonify({"message": "Not paid."}), HTTPStatus.NOT_FOUND

    if is_paid:
        wallet = get_wallet(theticket.wallet)
        payment = wallet.get_payment(checking_id)
        payment.set_pending(False)
        ticket = update_ticket(paid=True, checking_id=checking_id)

        return jsonify({"paid": True, "ticket_id": ticket.id}), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
示例#4
0
def api_tpos_check_invoice(tpos_id, checking_id):
    tpos = get_tpos(tpos_id)

    if not tpos:
        return jsonify({"message": "TPoS does not exist."}), Status.NOT_FOUND

    try:
        is_paid = not WALLET.get_invoice_status(checking_id).pending
    except Exception:
        return jsonify({"paid": False}), Status.OK

    if is_paid:
        wallet = get_wallet(tpos.wallet)
        payment = wallet.get_payment(checking_id)
        payment.set_pending(False)

        return jsonify({"paid": True}), Status.OK

    return jsonify({"paid": False}), Status.OK
示例#5
0
def api_ticket_send_ticket(checking_id):

    form = get_form(g.data['form'])
    if not form:
        return jsonify({"message": "LNTicket does not exist."}), HTTPStatus.NOT_FOUND
    try:
        is_paid = not WALLET.get_invoice_status(checking_id).pending
    except Exception:
        return jsonify({"message": "Not paid."}), HTTPStatus.NOT_FOUND

    if is_paid:
        wallet = get_wallet(form.wallet)
        payment = wallet.get_payment(checking_id)
        payment.set_pending(False)
        create_ticket(wallet=form.wallet, **g.data)

        return jsonify({"paid": True}), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
示例#6
0
async def api_tpos_check_invoice(tpos_id, payment_hash):
    tpos = get_tpos(tpos_id)

    if not tpos:
        return jsonify({"message": "TPoS does not exist."}), HTTPStatus.NOT_FOUND

    try:
        is_paid = not check_invoice_status(tpos.wallet, payment_hash).pending
    except Exception as exc:
        print(exc)
        return jsonify({"paid": False}), HTTPStatus.OK

    if is_paid:
        wallet = get_wallet(tpos.wallet)
        payment = wallet.get_payment(payment_hash)
        payment.set_pending(False)

        return jsonify({"paid": True}), HTTPStatus.OK

    return jsonify({"paid": False}), HTTPStatus.OK
示例#7
0
def api_paywal_check_invoice(paywall_id):
    paywall = get_paywall(paywall_id)

    if not paywall:
        return jsonify({"message":
                        "Paywall does not exist."}), Status.NOT_FOUND

    try:
        is_paid = not WALLET.get_invoice_status(g.data["checking_id"]).pending
    except Exception:
        return jsonify({"paid": False}), Status.OK

    if is_paid:
        wallet = get_wallet(paywall.wallet)
        payment = wallet.get_payment(g.data["checking_id"])
        payment.set_pending(False)

        return jsonify({
            "paid": True,
            "key": paywall.key_for(g.data["fingerprint"]),
            "url": paywall.url
        }), Status.OK

    return jsonify({"paid": False}), Status.OK