Пример #1
0
def process_payment():
    # Get POST data
    try:
        basket = json.loads(request.data)
    except JSONDecodeError as e:
        return abort(403)

    if 'api_secret' not in basket or config_file['API_SECRET'] != basket[
            'api_secret']:
        return abort(403)

    # Initilialize webpay
    configure_webpay()

    result = Transaction.create(buy_order=basket['order_number'],
                                session_id=basket['order_number'],
                                amount=float(basket['total_incl_tax']),
                                return_url=basket['notify_url'])

    return {"token": result.token, "url": result.url}
Пример #2
0
def webpay_plus_create():
    print("Webpay Plus Transaction.create")
    buy_order = str(random.randrange(1000000, 99999999))
    session_id = str(random.randrange(1000000, 99999999))
    amount = random.randrange(10000, 1000000)
    return_url = request.url_root + 'webpay-plus/commit'

    create_request = {
        "buy_order": buy_order,
        "session_id": session_id,
        "amount": amount,
        "return_url": return_url
    }

    response = Transaction.create(buy_order, session_id, amount, return_url)

    print(response)

    return render_template('webpay/plus/create.html',
                           request=create_request,
                           response=response)