def checkvat(vat): valid, info = get_vat_info(vat) if not valid: return jsonify({"valid": False}) return jsonify({"valid": True, "name": info.name, "country": info.countryCode, "vatNumber": info.vatNumber, "address": info.address })
def confirm(): order = Order(user_id=current_user.id, state="to_confirm") if request.form.get("bill-selector") == "vat": valid, info = get_vat_info(request.form.get("vat-nr")) if not valid: return redirect(url_for(".checkout")) order.address = "{0}\n{1}".format(info.name, info.address) order.vat_addr = "{0}{1}".format(info.countryCode, info.vatNumber) elif request.form.get("address"): order.address = request.form.get("address") else: # FIXME: give good user message return redirect(url_for(".checkout")) if check_domain_available(request.form.get("domain")): order.domain = request.form.get("domain") else: # FIXME: give good user message return redirect(url_for(".checkout")) ctx = session["checkout_context"] sum_total = _total_price(ctx) order.currency = ctx["currency"]["label"] if order.vat_addr: order.total = sum_total else: order.total_vat = math.ceil(sum_total * 19) / 100.0 order.total = sum_total + order.total_vat order.details = json.dumps(ctx) db_session.add(order) db_session.commit() return render_template("confirm.html", order=order, upgrade_names=_upgrade_names(), **ctx)