We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Implement "Apply" Promotional Code on event site itself
Our promotional code/discount gets applied only after the user advances to the next page.

Expected: 
* [x] There should be an "Apply" button on the right hand side of the promotion field (when it is expanded).
![screenshot from 2017-01-07 19-33-17](https://cloud.githubusercontent.com/assets/1583873/21744213/9ed3ba18-d511-11e6-9eef-06cb652f6cdf.png)

* [ ] After the user hits "Apply":
    * [ ] Display below the ticket type the applied discount, e.g. Discounted 50%
    * [ ] Display the new (discounted) ticket price in the price column and the old ticket price crossed

Compare:

![screenshot from 2017-01-07 19-41-23](https://cloud.githubusercontent.com/assets/1583873/21744210/93941abc-d511-11e6-987c-002254742874.png)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/views/public/ticketing.py`
Content:
```
1 from cStringIO import StringIO
2 
3 import pycountry
4 import requests
5 import stripe
6 from flask import Blueprint
7 from flask import redirect, url_for, request, jsonify, make_response, flash
8 from flask import render_template
9 from flask.ext.restplus import abort
10 from xhtml2pdf import pisa
11 
12 from app import get_settings
13 from app.helpers.data import save_to_db
14 from app.helpers.payment import PayPalPaymentsManager
15 from app.helpers.ticketing import TicketingManager
16 
17 
18 def create_pdf(pdf_data):
19     pdf = StringIO()
20     pisa.CreatePDF(StringIO(pdf_data.encode('utf-8')), pdf)
21     return pdf
22 
23 
24 ticketing = Blueprint('ticketing', __name__, url_prefix='/orders')
25 
26 
27 @ticketing.route('/', methods=('GET',))
28 def index():
29     return redirect("/")
30 
31 
32 @ticketing.route('/create/', methods=('POST',))
33 def create_order():
34     order = TicketingManager.create_order(request.form)
35     return redirect(url_for('.view_order', order_identifier=order.identifier))
36 
37 
38 @ticketing.route('/<order_identifier>/', methods=('GET',))
39 def view_order(order_identifier):
40     order = TicketingManager.get_and_set_expiry(order_identifier)
41     if not order or order.status == 'expired':
42         abort(404)
43     if order.status == 'completed' or order.status == 'placed':
44         return redirect(url_for('ticketing.view_order_after_payment', order_identifier=order_identifier))
45 
46     if order.event.stripe:
47         stripe_publishable_key = order.event.stripe.stripe_publishable_key
48     else:
49         stripe_publishable_key = "No Key Set"
50 
51     return render_template('gentelella/guest/ticketing/order_pre_payment.html', order=order, event=order.event,
52                            countries=list(pycountry.countries),
53                            stripe_publishable_key=stripe_publishable_key)
54 
55 
56 @ticketing.route('/<order_identifier>/view/', methods=('GET',))
57 def view_order_after_payment(order_identifier):
58     order = TicketingManager.get_and_set_expiry(order_identifier)
59     if not order or (order.status != 'completed' and order.status != 'placed'):
60         abort(404)
61     flash("An email with the ticket has also been sent to your email account.")
62     return render_template('gentelella/guest/ticketing/order_post_payment.html', order=order, event=order.event)
63 
64 
65 @ticketing.route('/<order_identifier>/view/pdf/', methods=('GET',))
66 def view_order_after_payment_pdf(order_identifier):
67     order = TicketingManager.get_and_set_expiry(order_identifier)
68     if not order or order.status != 'completed':
69         abort(404)
70     pdf = create_pdf(render_template('gentelella/guest/ticketing/invoice_pdf.html',
71                                      order=order, event=order.event))
72     response = make_response(pdf.getvalue())
73     response.headers['Content-Type'] = 'application/pdf'
74     response.headers['Content-Disposition'] = \
75         'inline; filename=%s.pdf' % order.get_invoice_number()
76     return response
77 
78 
79 @ticketing.route('/<order_identifier>/view/tickets/pdf/', methods=('GET',))
80 def view_order_tickets_after_payment_pdf(order_identifier):
81     order = TicketingManager.get_and_set_expiry(order_identifier)
82     if not order or order.status != 'completed':
83         abort(404)
84     pdf = create_pdf(render_template('gentelella/guest/ticketing/pdf/ticket.html', order=order))
85     response = make_response(pdf.getvalue())
86     response.headers['Content-Type'] = 'application/pdf'
87     response.headers['Content-Disposition'] = \
88         'inline; filename=%s.pdf' % "test"
89     return response
90 
91 
92 @ticketing.route('/initiate/payment/', methods=('POST',))
93 def initiate_order_payment():
94     paid_via = request.form.get('pay_via_service', 'stripe')
95     result = TicketingManager.initiate_order_payment(request.form, paid_via)
96     if result:
97         if request.form.get('pay_via_service', 'stripe') != 'paypal':
98             return jsonify({
99                 "status": "ok",
100                 "email": result.user.email,
101                 "action": "start_stripe"
102                 if result.status == 'initialized' and paid_via == 'stripe'
103                 else "show_completed"
104             })
105         else:
106             return jsonify({
107                 "status": "ok",
108                 "email": result.user.email,
109                 "action": "start_paypal",
110                 "redirect_url": PayPalPaymentsManager.get_checkout_url(result)
111             })
112     else:
113         return jsonify({
114             "status": "error"
115         })
116 
117 
118 @ticketing.route('/charge/payment/', methods=('POST',))
119 def charge_stripe_order_payment():
120     status, result = TicketingManager.charge_stripe_order_payment(request.form)
121     if status:
122         return jsonify({
123             "status": "ok",
124             "message": result.transaction_id
125         })
126     else:
127         return jsonify({
128             "status": "error",
129             "message": result
130         })
131 
132 
133 @ticketing.route('/expire/<order_identifier>/', methods=('POST',))
134 def expire_order(order_identifier):
135     TicketingManager.get_and_set_expiry(order_identifier)
136     return jsonify({
137         "status": "ok"
138     })
139 
140 
141 @ticketing.route('/stripe/callback/', methods=('GET',))
142 def stripe_callback():
143     code = request.args.get('code')
144     if code and code != "":
145         data = {
146             'client_secret': get_settings()['stripe_secret_key'],
147             'code': code,
148             'grant_type': 'authorization_code'
149         }
150         response = requests.post('https://connect.stripe.com/oauth/token', data=data)
151         if response.status_code == 200:
152             response_json = response.json()
153             stripe.api_key = response_json['access_token']
154             account = stripe.Account.retrieve(response_json['stripe_user_id'])
155             return render_template('gentelella/guest/ticketing/stripe_oauth_callback.html', response=response_json,
156                                    account=account)
157     return "Error"
158 
159 
160 @ticketing.route('/<order_identifier>/error/', methods=('GET', 'POST'))
161 def show_transaction_error(order_identifier):
162     order = TicketingManager.get_order_by_identifier(order_identifier)
163     return render_template('gentelella/guest/ticketing/order_post_payment_error.html', order=order,
164                            event=order.event)
165 
166 
167 @ticketing.route('/<order_identifier>/paypal/<function>/', methods=('GET',))
168 def paypal_callback(order_identifier, function):
169     order = TicketingManager.get_order_by_identifier(order_identifier)
170     if not order or order.status == 'expired':
171         abort(404)
172     if function == 'cancel':
173         order.status = 'expired'
174         save_to_db(order)
175         return redirect(url_for('event_detail.display_event_detail_home', identifier=order.event.identifier))
176     elif function == 'success':
177         status, result = TicketingManager.charge_paypal_order_payment(order)
178         if status:
179             return redirect(url_for('.view_order', order_identifier=order_identifier))
180         else:
181             flash("An error occurred while processing your transaction. " + str(result), "danger")
182             return redirect(url_for('.show_transaction_error', order_identifier=order_identifier))
183     abort(404)
184
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/views/public/ticketing.py b/app/views/public/ticketing.py
--- a/app/views/public/ticketing.py
+++ b/app/views/public/ticketing.py
@@ -35,6 +35,20 @@
     return redirect(url_for('.view_order', order_identifier=order.identifier))
 
 
+@ticketing.route('/apply_discount/', methods=('POST',))
+def apply_discount():
+    discount = TicketingManager.get_discount_code(request.form.get('event_id'), request.form.get('promo_code', ''))
+    if discount:
+        return jsonify({
+            'discount_type': discount.type,
+            'discount_amount': discount.value,
+            'discount_status': True
+        })
+    else:
+        return jsonify({
+            'discount_status': False
+        })
+
 @ticketing.route('/<order_identifier>/', methods=('GET',))
 def view_order(order_identifier):
     order = TicketingManager.get_and_set_expiry(order_identifier)

{"golden_diff": "diff --git a/app/views/public/ticketing.py b/app/views/public/ticketing.py\n--- a/app/views/public/ticketing.py\n+++ b/app/views/public/ticketing.py\n@@ -35,6 +35,20 @@\n     return redirect(url_for('.view_order', order_identifier=order.identifier))\n \n \n+@ticketing.route('/apply_discount/', methods=('POST',))\n+def apply_discount():\n+    discount = TicketingManager.get_discount_code(request.form.get('event_id'), request.form.get('promo_code', ''))\n+    if discount:\n+        return jsonify({\n+            'discount_type': discount.type,\n+            'discount_amount': discount.value,\n+            'discount_status': True\n+        })\n+    else:\n+        return jsonify({\n+            'discount_status': False\n+        })\n+\n @ticketing.route('/<order_identifier>/', methods=('GET',))\n def view_order(order_identifier):\n     order = TicketingManager.get_and_set_expiry(order_identifier)\n", "issue": "Implement \"Apply\" Promotional Code on event site itself\nOur promotional code/discount gets applied only after the user advances to the next page.\r\n\r\nExpected: \r\n* [x] There should be an \"Apply\" button on the right hand side of the promotion field (when it is expanded).\r\n![screenshot from 2017-01-07 19-33-17](https://cloud.githubusercontent.com/assets/1583873/21744213/9ed3ba18-d511-11e6-9eef-06cb652f6cdf.png)\r\n\r\n* [ ] After the user hits \"Apply\":\r\n    * [ ] Display below the ticket type the applied discount, e.g. Discounted 50%\r\n    * [ ] Display the new (discounted) ticket price in the price column and the old ticket price crossed\r\n\r\nCompare:\r\n\r\n![screenshot from 2017-01-07 19-41-23](https://cloud.githubusercontent.com/assets/1583873/21744210/93941abc-d511-11e6-987c-002254742874.png)\r\n\n", "before_files": [{"content": "from cStringIO import StringIO\n\nimport pycountry\nimport requests\nimport stripe\nfrom flask import Blueprint\nfrom flask import redirect, url_for, request, jsonify, make_response, flash\nfrom flask import render_template\nfrom flask.ext.restplus import abort\nfrom xhtml2pdf import pisa\n\nfrom app import get_settings\nfrom app.helpers.data import save_to_db\nfrom app.helpers.payment import PayPalPaymentsManager\nfrom app.helpers.ticketing import TicketingManager\n\n\ndef create_pdf(pdf_data):\n    pdf = StringIO()\n    pisa.CreatePDF(StringIO(pdf_data.encode('utf-8')), pdf)\n    return pdf\n\n\nticketing = Blueprint('ticketing', __name__, url_prefix='/orders')\n\n\n@ticketing.route('/', methods=('GET',))\ndef index():\n    return redirect(\"/\")\n\n\n@ticketing.route('/create/', methods=('POST',))\ndef create_order():\n    order = TicketingManager.create_order(request.form)\n    return redirect(url_for('.view_order', order_identifier=order.identifier))\n\n\n@ticketing.route('/<order_identifier>/', methods=('GET',))\ndef view_order(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status == 'expired':\n        abort(404)\n    if order.status == 'completed' or order.status == 'placed':\n        return redirect(url_for('ticketing.view_order_after_payment', order_identifier=order_identifier))\n\n    if order.event.stripe:\n        stripe_publishable_key = order.event.stripe.stripe_publishable_key\n    else:\n        stripe_publishable_key = \"No Key Set\"\n\n    return render_template('gentelella/guest/ticketing/order_pre_payment.html', order=order, event=order.event,\n                           countries=list(pycountry.countries),\n                           stripe_publishable_key=stripe_publishable_key)\n\n\n@ticketing.route('/<order_identifier>/view/', methods=('GET',))\ndef view_order_after_payment(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or (order.status != 'completed' and order.status != 'placed'):\n        abort(404)\n    flash(\"An email with the ticket has also been sent to your email account.\")\n    return render_template('gentelella/guest/ticketing/order_post_payment.html', order=order, event=order.event)\n\n\n@ticketing.route('/<order_identifier>/view/pdf/', methods=('GET',))\ndef view_order_after_payment_pdf(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status != 'completed':\n        abort(404)\n    pdf = create_pdf(render_template('gentelella/guest/ticketing/invoice_pdf.html',\n                                     order=order, event=order.event))\n    response = make_response(pdf.getvalue())\n    response.headers['Content-Type'] = 'application/pdf'\n    response.headers['Content-Disposition'] = \\\n        'inline; filename=%s.pdf' % order.get_invoice_number()\n    return response\n\n\n@ticketing.route('/<order_identifier>/view/tickets/pdf/', methods=('GET',))\ndef view_order_tickets_after_payment_pdf(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status != 'completed':\n        abort(404)\n    pdf = create_pdf(render_template('gentelella/guest/ticketing/pdf/ticket.html', order=order))\n    response = make_response(pdf.getvalue())\n    response.headers['Content-Type'] = 'application/pdf'\n    response.headers['Content-Disposition'] = \\\n        'inline; filename=%s.pdf' % \"test\"\n    return response\n\n\n@ticketing.route('/initiate/payment/', methods=('POST',))\ndef initiate_order_payment():\n    paid_via = request.form.get('pay_via_service', 'stripe')\n    result = TicketingManager.initiate_order_payment(request.form, paid_via)\n    if result:\n        if request.form.get('pay_via_service', 'stripe') != 'paypal':\n            return jsonify({\n                \"status\": \"ok\",\n                \"email\": result.user.email,\n                \"action\": \"start_stripe\"\n                if result.status == 'initialized' and paid_via == 'stripe'\n                else \"show_completed\"\n            })\n        else:\n            return jsonify({\n                \"status\": \"ok\",\n                \"email\": result.user.email,\n                \"action\": \"start_paypal\",\n                \"redirect_url\": PayPalPaymentsManager.get_checkout_url(result)\n            })\n    else:\n        return jsonify({\n            \"status\": \"error\"\n        })\n\n\n@ticketing.route('/charge/payment/', methods=('POST',))\ndef charge_stripe_order_payment():\n    status, result = TicketingManager.charge_stripe_order_payment(request.form)\n    if status:\n        return jsonify({\n            \"status\": \"ok\",\n            \"message\": result.transaction_id\n        })\n    else:\n        return jsonify({\n            \"status\": \"error\",\n            \"message\": result\n        })\n\n\n@ticketing.route('/expire/<order_identifier>/', methods=('POST',))\ndef expire_order(order_identifier):\n    TicketingManager.get_and_set_expiry(order_identifier)\n    return jsonify({\n        \"status\": \"ok\"\n    })\n\n\n@ticketing.route('/stripe/callback/', methods=('GET',))\ndef stripe_callback():\n    code = request.args.get('code')\n    if code and code != \"\":\n        data = {\n            'client_secret': get_settings()['stripe_secret_key'],\n            'code': code,\n            'grant_type': 'authorization_code'\n        }\n        response = requests.post('https://connect.stripe.com/oauth/token', data=data)\n        if response.status_code == 200:\n            response_json = response.json()\n            stripe.api_key = response_json['access_token']\n            account = stripe.Account.retrieve(response_json['stripe_user_id'])\n            return render_template('gentelella/guest/ticketing/stripe_oauth_callback.html', response=response_json,\n                                   account=account)\n    return \"Error\"\n\n\n@ticketing.route('/<order_identifier>/error/', methods=('GET', 'POST'))\ndef show_transaction_error(order_identifier):\n    order = TicketingManager.get_order_by_identifier(order_identifier)\n    return render_template('gentelella/guest/ticketing/order_post_payment_error.html', order=order,\n                           event=order.event)\n\n\n@ticketing.route('/<order_identifier>/paypal/<function>/', methods=('GET',))\ndef paypal_callback(order_identifier, function):\n    order = TicketingManager.get_order_by_identifier(order_identifier)\n    if not order or order.status == 'expired':\n        abort(404)\n    if function == 'cancel':\n        order.status = 'expired'\n        save_to_db(order)\n        return redirect(url_for('event_detail.display_event_detail_home', identifier=order.event.identifier))\n    elif function == 'success':\n        status, result = TicketingManager.charge_paypal_order_payment(order)\n        if status:\n            return redirect(url_for('.view_order', order_identifier=order_identifier))\n        else:\n            flash(\"An error occurred while processing your transaction. \" + str(result), \"danger\")\n            return redirect(url_for('.show_transaction_error', order_identifier=order_identifier))\n    abort(404)\n", "path": "app/views/public/ticketing.py"}], "after_files": [{"content": "from cStringIO import StringIO\n\nimport pycountry\nimport requests\nimport stripe\nfrom flask import Blueprint\nfrom flask import redirect, url_for, request, jsonify, make_response, flash\nfrom flask import render_template\nfrom flask.ext.restplus import abort\nfrom xhtml2pdf import pisa\n\nfrom app import get_settings\nfrom app.helpers.data import save_to_db\nfrom app.helpers.payment import PayPalPaymentsManager\nfrom app.helpers.ticketing import TicketingManager\n\n\ndef create_pdf(pdf_data):\n    pdf = StringIO()\n    pisa.CreatePDF(StringIO(pdf_data.encode('utf-8')), pdf)\n    return pdf\n\n\nticketing = Blueprint('ticketing', __name__, url_prefix='/orders')\n\n\n@ticketing.route('/', methods=('GET',))\ndef index():\n    return redirect(\"/\")\n\n\n@ticketing.route('/create/', methods=('POST',))\ndef create_order():\n    order = TicketingManager.create_order(request.form)\n    return redirect(url_for('.view_order', order_identifier=order.identifier))\n\n\n@ticketing.route('/apply_discount/', methods=('POST',))\ndef apply_discount():\n    discount = TicketingManager.get_discount_code(request.form.get('event_id'), request.form.get('promo_code', ''))\n    if discount:\n        return jsonify({\n            'discount_type': discount.type,\n            'discount_amount': discount.value,\n            'discount_status': True\n        })\n    else:\n        return jsonify({\n            'discount_status': False\n        })\n\n@ticketing.route('/<order_identifier>/', methods=('GET',))\ndef view_order(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status == 'expired':\n        abort(404)\n    if order.status == 'completed' or order.status == 'placed':\n        return redirect(url_for('ticketing.view_order_after_payment', order_identifier=order_identifier))\n\n    if order.event.stripe:\n        stripe_publishable_key = order.event.stripe.stripe_publishable_key\n    else:\n        stripe_publishable_key = \"No Key Set\"\n\n    return render_template('gentelella/guest/ticketing/order_pre_payment.html', order=order, event=order.event,\n                           countries=list(pycountry.countries),\n                           stripe_publishable_key=stripe_publishable_key)\n\n\n@ticketing.route('/<order_identifier>/view/', methods=('GET',))\ndef view_order_after_payment(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or (order.status != 'completed' and order.status != 'placed'):\n        abort(404)\n    flash(\"An email with the ticket has also been sent to your email account.\")\n    return render_template('gentelella/guest/ticketing/order_post_payment.html', order=order, event=order.event)\n\n\n@ticketing.route('/<order_identifier>/view/pdf/', methods=('GET',))\ndef view_order_after_payment_pdf(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status != 'completed':\n        abort(404)\n    pdf = create_pdf(render_template('gentelella/guest/ticketing/invoice_pdf.html',\n                                     order=order, event=order.event))\n    response = make_response(pdf.getvalue())\n    response.headers['Content-Type'] = 'application/pdf'\n    response.headers['Content-Disposition'] = \\\n        'inline; filename=%s.pdf' % order.get_invoice_number()\n    return response\n\n\n@ticketing.route('/<order_identifier>/view/tickets/pdf/', methods=('GET',))\ndef view_order_tickets_after_payment_pdf(order_identifier):\n    order = TicketingManager.get_and_set_expiry(order_identifier)\n    if not order or order.status != 'completed':\n        abort(404)\n    pdf = create_pdf(render_template('gentelella/guest/ticketing/pdf/ticket.html', order=order))\n    response = make_response(pdf.getvalue())\n    response.headers['Content-Type'] = 'application/pdf'\n    response.headers['Content-Disposition'] = \\\n        'inline; filename=%s.pdf' % \"test\"\n    return response\n\n\n@ticketing.route('/initiate/payment/', methods=('POST',))\ndef initiate_order_payment():\n    paid_via = request.form.get('pay_via_service', 'stripe')\n    result = TicketingManager.initiate_order_payment(request.form, paid_via)\n    if result:\n        if request.form.get('pay_via_service', 'stripe') != 'paypal':\n            return jsonify({\n                \"status\": \"ok\",\n                \"email\": result.user.email,\n                \"action\": \"start_stripe\"\n                if result.status == 'initialized' and paid_via == 'stripe'\n                else \"show_completed\"\n            })\n        else:\n            return jsonify({\n                \"status\": \"ok\",\n                \"email\": result.user.email,\n                \"action\": \"start_paypal\",\n                \"redirect_url\": PayPalPaymentsManager.get_checkout_url(result)\n            })\n    else:\n        return jsonify({\n            \"status\": \"error\"\n        })\n\n\n@ticketing.route('/charge/payment/', methods=('POST',))\ndef charge_stripe_order_payment():\n    status, result = TicketingManager.charge_stripe_order_payment(request.form)\n    if status:\n        return jsonify({\n            \"status\": \"ok\",\n            \"message\": result.transaction_id\n        })\n    else:\n        return jsonify({\n            \"status\": \"error\",\n            \"message\": result\n        })\n\n\n@ticketing.route('/expire/<order_identifier>/', methods=('POST',))\ndef expire_order(order_identifier):\n    TicketingManager.get_and_set_expiry(order_identifier)\n    return jsonify({\n        \"status\": \"ok\"\n    })\n\n\n@ticketing.route('/stripe/callback/', methods=('GET',))\ndef stripe_callback():\n    code = request.args.get('code')\n    if code and code != \"\":\n        data = {\n            'client_secret': get_settings()['stripe_secret_key'],\n            'code': code,\n            'grant_type': 'authorization_code'\n        }\n        response = requests.post('https://connect.stripe.com/oauth/token', data=data)\n        if response.status_code == 200:\n            response_json = response.json()\n            stripe.api_key = response_json['access_token']\n            account = stripe.Account.retrieve(response_json['stripe_user_id'])\n            return render_template('gentelella/guest/ticketing/stripe_oauth_callback.html', response=response_json,\n                                   account=account)\n    return \"Error\"\n\n\n@ticketing.route('/<order_identifier>/error/', methods=('GET', 'POST'))\ndef show_transaction_error(order_identifier):\n    order = TicketingManager.get_order_by_identifier(order_identifier)\n    return render_template('gentelella/guest/ticketing/order_post_payment_error.html', order=order,\n                           event=order.event)\n\n\n@ticketing.route('/<order_identifier>/paypal/<function>/', methods=('GET',))\ndef paypal_callback(order_identifier, function):\n    order = TicketingManager.get_order_by_identifier(order_identifier)\n    if not order or order.status == 'expired':\n        abort(404)\n    if function == 'cancel':\n        order.status = 'expired'\n        save_to_db(order)\n        return redirect(url_for('event_detail.display_event_detail_home', identifier=order.event.identifier))\n    elif function == 'success':\n        status, result = TicketingManager.charge_paypal_order_payment(order)\n        if status:\n            return redirect(url_for('.view_order', order_identifier=order_identifier))\n        else:\n            flash(\"An error occurred while processing your transaction. \" + str(result), \"danger\")\n            return redirect(url_for('.show_transaction_error', order_identifier=order_identifier))\n    abort(404)\n", "path": "app/views/public/ticketing.py"}]}