示例#1
0
def order_page(order_id):
    """
    Page for managing a initiated order. No authentication performed. This page shows a mix of what should be
    accessible to the merchant and costumer.

    :param order_id: The ID for the order that are to be managed.
    :return: A render of the manage order page.
    """
    form = OrderPage(request.form)
    access_token = token_request()["access_token"]
    if request.method == 'POST':
        if form.cancel_order.data:
            cancel_order(order_id, access_token, "User canceled order")
        elif form.capture_order.data:
            capture_payment(order_id, access_token)
        elif form.refund_order.data:
            refund_payment(order_id, access_token)
    if session.get("order_id") == order_id:
        payment_url = session["payment_url"]
    else:
        payment_url = ""
    order_status_string = str(order_status(order_id, access_token))
    history = order_details(order_id, access_token)["transactionLogHistory"]
    return render_template("order_page.html",
                           form=form,
                           payment_url=payment_url,
                           order_status=order_status_string,
                           order_id=order_id,
                           order_history=history)
示例#2
0
def callback_route(order_id):
    """
    Endpoint for Vipps to provide transaction updates.

    :param order_id: The ID for the order there is updated information about.
    :return: Vipps requires no return for callback.
    """
    response = request.get_json()
    if response["transactionInfo"]["status"] == "Reserved":
        access_token = token_request()["access_token"]
        capture_payment(order_id, access_token)
示例#3
0
def callback_route(order_id):
    """
    Endpoint for Vipps to provide transaction updates.

    :param order_id: The ID for the order there is updated information about.
    :return: Vipps requires no return for callback.
    """
    callback_msg = request.get_json()
    log_callback(__name__ + ".callback_route", callback_msg=callback_msg, path_var=order_id)
    if callback_msg["transactionInfo"]["status"] == "RESERVE":
        access_token = token_request()["access_token"]
        capture_payment(order_id, access_token)
    return ""