from flask import Flask, session, request, redirect, render_template
from flaskext.payments import Payments, Transaction

app = Flask(__name__)
app.config.from_pyfile('hello.cfg')
app.config.from_pyfile('../yourpaypal.settings')

payments = Payments(app)

@app.route('/')
def show_all():
    return render_template('checkout.html')

@app.route('/paypal-express')
def paypal_express_checkout():
    trans = Transaction()
    trans.type = 'Express'
    trans.amount = 100
    trans.return_url = 'http://localhost:5000/paypal-express-complete'
    trans.cancel_url = 'http://localhost:5000/paypal-express-cancel'

    trans = payments.setupRedirect(trans)
    session['trans'] = trans
    
    return redirect(trans.redirect_url)

@app.route('/paypal-express-complete')
def paypal_express_complete():
    trans = session['trans']
    payerid = request.values['PayerID'] 
    trans.pay_id = payerid

    trans = payments.authorise(trans)
    session['trans'] = trans

    return redirect('/confirm')

@app.route('/paypal-direct-payments')
def paypal_direct_payments():
    return render_template('fill_in_details.html')

@app.route('/confirm')
def confirm():
    trans = session['trans']
    return render_template('confirmation.html', trans=trans)

if __name__ == '__main__':
    app.run()

@@ -61,16 +61,25 @@
 template
+, url_for
 %0Afrom fl
@@ -499,46 +499,32 @@
 l = 
-'http://localhost:5000/
+url_for('
 paypal
--
+_
 express
--
+_
 comp
@@ -528,16 +528,33 @@
 omplete'
+, _external=True)
 %0A    tra
@@ -573,53 +573,42 @@
 l = 
-'http://localhost:5000/paypal-express-cancel'
+url_for('confirm', _external=True)
 %0A%0A  

use external url_for instead of hardcoded url in example