def post(self): if "content" not in request.form.keys(): return redirect(url_for('index')) content = request.form['content'] p = Paste(content) db_session.add(p) db_session.commit() extension = language_detect(content)[1] return url_for('view', id=encode_id(p.id), extension=extension)
def get(self, token): checkout_response = paypal.get_express_checkout_details(token=token) if checkout_response['CHECKOUTSTATUS'] == 'PaymentActionCompleted': p = Purchase.query.filter_by(token=token).one() u = User.query.get(p.uid) p.confirm_payment() u.activated = True db_session.commit() return render_template("confirm.html") else: return render_template("paypal_error.html", message=checkout_response['CHECKOUTSTATUS'])
def post(self): if not "amt" in request.form: flash("You must specify the amount to pay", "error") return render_template("checkout.html") kw = { 'amt': request.form['amt'], 'currencycode': 'USD', 'returnurl': url_for('paypal_confirm', _external=True), 'cancelurl': url_for('index', _external=True), 'paymentaction': 'Sale' } setexp_response = paypal.set_express_checkout(**kw) if setexp_response['ACK'] == 'Success': p = Purchase(session['payment_target_id'], setexp_response.token, kw['amt']) db_session.add(p) db_session.commit() return redirect(paypal.generate_express_checkout_redirect_url(setexp_response.token)) else: flash("Sorry, something went wrong. Try again.", "error") return render_template("checkout.html")
def post(self): if "username" not in request.form or "password" not in request.form: return redirect(url_for('register')) username = request.form['username'] password = request.form['password'] if len(password) < 4: flash("Password must be greater than 4 characters", "error") return redirect(url_for('register')) try: u = User(username, password, using_paypal) db_session.add(u) db_session.commit() except sqlalchemy.exc.IntegrityError: flash("Username taken", "error") return redirect(url_for('register')) if using_paypal: session['payment_target_id'] = u.id return render_template("checkout.html") else: return render_template("confirm.html")