We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Delete tpay payment if order is modified
### Summary
Right now it is possible to order a pizza, pay it with tpay, change the order to a pizza with a different price, and the payment will not match the order anymore.

### How to test
1. Order a pizza
2. Pay with tpay
3. Change the order
4. The payment should be deleted
5. If the event is over, or the payment is batched, then changing the order should crash

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `website/pizzas/views.py`
Content:
```
1 """Views provided by the pizzas package."""
2 from django.contrib import messages
3 from django.contrib.auth.decorators import login_required
4 from django.http import Http404
5 from django.shortcuts import get_object_or_404, render, redirect
6 from django.utils.translation import gettext_lazy as _
7 from django.views.decorators.http import require_http_methods
8 
9 from payments.services import delete_payment
10 from .models import FoodOrder, FoodEvent, Product
11 
12 
13 @login_required
14 def index(request):
15     """Overview of user order for a pizza event."""
16     products = Product.available_products.order_by("name")
17     if not request.user.has_perm("pizzas.order_restricted_products"):
18         products = products.exclude(restricted=True)
19     event = FoodEvent.current()
20     try:
21         obj = FoodOrder.objects.get(food_event=event, member=request.member)
22     except FoodOrder.DoesNotExist:
23         obj = None
24     context = {"event": event, "products": products, "order": obj}
25     return render(request, "pizzas/index.html", context)
26 
27 
28 @require_http_methods(["POST"])
29 def cancel_order(request):
30     """View that cancels a user's order."""
31     if "order" in request.POST:
32         try:
33             order = get_object_or_404(FoodOrder, pk=int(request.POST["order"]))
34             if not order.can_be_changed:
35                 messages.error(request, _("You can no longer cancel."))
36             elif order.member == request.member:
37                 order.delete()
38                 messages.success(request, _("Your order has been cancelled."))
39         except Http404:
40             messages.error(request, _("Your order could not be found."))
41     return redirect("pizzas:index")
42 
43 
44 @login_required
45 def place_order(request):
46     """View that shows the detail of the current order."""
47     event = FoodEvent.current()
48     if not event:
49         return redirect("pizzas:index")
50 
51     try:
52         obj = FoodOrder.objects.get(food_event=event, member=request.member)
53         current_order_locked = not obj.can_be_changed
54     except FoodOrder.DoesNotExist:
55         obj = None
56         current_order_locked = False
57 
58     if "product" in request.POST and not current_order_locked:
59         productset = Product.available_products.all()
60         if not request.user.has_perm("pizzas.order_restricted_products"):
61             productset = productset.exclude(restricted=True)
62         try:
63             product = productset.get(pk=int(request.POST["product"]))
64         except Product.DoesNotExist as e:
65             raise Http404("Pizza does not exist") from e
66         if not obj:
67             obj = FoodOrder(food_event=event, member=request.member)
68         obj.product = product
69         if obj.payment:
70             delete_payment(obj.payment)
71         obj.save()
72     return redirect("pizzas:index")
73
```
--- 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/website/pizzas/views.py b/website/pizzas/views.py
--- a/website/pizzas/views.py
+++ b/website/pizzas/views.py
@@ -67,6 +67,6 @@
             obj = FoodOrder(food_event=event, member=request.member)
         obj.product = product
         if obj.payment:
-            delete_payment(obj.payment)
+            delete_payment(obj)
         obj.save()
     return redirect("pizzas:index")

{"golden_diff": "diff --git a/website/pizzas/views.py b/website/pizzas/views.py\n--- a/website/pizzas/views.py\n+++ b/website/pizzas/views.py\n@@ -67,6 +67,6 @@\n             obj = FoodOrder(food_event=event, member=request.member)\n         obj.product = product\n         if obj.payment:\n-            delete_payment(obj.payment)\n+            delete_payment(obj)\n         obj.save()\n     return redirect(\"pizzas:index\")\n", "issue": "Delete tpay payment if order is modified\n### Summary\r\nRight now it is possible to order a pizza, pay it with tpay, change the order to a pizza with a different price, and the payment will not match the order anymore.\r\n\r\n### How to test\r\n1. Order a pizza\r\n2. Pay with tpay\r\n3. Change the order\r\n4. The payment should be deleted\r\n5. If the event is over, or the payment is batched, then changing the order should crash\n", "before_files": [{"content": "\"\"\"Views provided by the pizzas package.\"\"\"\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404, render, redirect\nfrom django.utils.translation import gettext_lazy as _\nfrom django.views.decorators.http import require_http_methods\n\nfrom payments.services import delete_payment\nfrom .models import FoodOrder, FoodEvent, Product\n\n\n@login_required\ndef index(request):\n    \"\"\"Overview of user order for a pizza event.\"\"\"\n    products = Product.available_products.order_by(\"name\")\n    if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n        products = products.exclude(restricted=True)\n    event = FoodEvent.current()\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n    except FoodOrder.DoesNotExist:\n        obj = None\n    context = {\"event\": event, \"products\": products, \"order\": obj}\n    return render(request, \"pizzas/index.html\", context)\n\n\n@require_http_methods([\"POST\"])\ndef cancel_order(request):\n    \"\"\"View that cancels a user's order.\"\"\"\n    if \"order\" in request.POST:\n        try:\n            order = get_object_or_404(FoodOrder, pk=int(request.POST[\"order\"]))\n            if not order.can_be_changed:\n                messages.error(request, _(\"You can no longer cancel.\"))\n            elif order.member == request.member:\n                order.delete()\n                messages.success(request, _(\"Your order has been cancelled.\"))\n        except Http404:\n            messages.error(request, _(\"Your order could not be found.\"))\n    return redirect(\"pizzas:index\")\n\n\n@login_required\ndef place_order(request):\n    \"\"\"View that shows the detail of the current order.\"\"\"\n    event = FoodEvent.current()\n    if not event:\n        return redirect(\"pizzas:index\")\n\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n        current_order_locked = not obj.can_be_changed\n    except FoodOrder.DoesNotExist:\n        obj = None\n        current_order_locked = False\n\n    if \"product\" in request.POST and not current_order_locked:\n        productset = Product.available_products.all()\n        if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n            productset = productset.exclude(restricted=True)\n        try:\n            product = productset.get(pk=int(request.POST[\"product\"]))\n        except Product.DoesNotExist as e:\n            raise Http404(\"Pizza does not exist\") from e\n        if not obj:\n            obj = FoodOrder(food_event=event, member=request.member)\n        obj.product = product\n        if obj.payment:\n            delete_payment(obj.payment)\n        obj.save()\n    return redirect(\"pizzas:index\")\n", "path": "website/pizzas/views.py"}], "after_files": [{"content": "\"\"\"Views provided by the pizzas package.\"\"\"\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404, render, redirect\nfrom django.utils.translation import gettext_lazy as _\nfrom django.views.decorators.http import require_http_methods\n\nfrom payments.services import delete_payment\nfrom .models import FoodOrder, FoodEvent, Product\n\n\n@login_required\ndef index(request):\n    \"\"\"Overview of user order for a pizza event.\"\"\"\n    products = Product.available_products.order_by(\"name\")\n    if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n        products = products.exclude(restricted=True)\n    event = FoodEvent.current()\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n    except FoodOrder.DoesNotExist:\n        obj = None\n    context = {\"event\": event, \"products\": products, \"order\": obj}\n    return render(request, \"pizzas/index.html\", context)\n\n\n@require_http_methods([\"POST\"])\ndef cancel_order(request):\n    \"\"\"View that cancels a user's order.\"\"\"\n    if \"order\" in request.POST:\n        try:\n            order = get_object_or_404(FoodOrder, pk=int(request.POST[\"order\"]))\n            if not order.can_be_changed:\n                messages.error(request, _(\"You can no longer cancel.\"))\n            elif order.member == request.member:\n                order.delete()\n                messages.success(request, _(\"Your order has been cancelled.\"))\n        except Http404:\n            messages.error(request, _(\"Your order could not be found.\"))\n    return redirect(\"pizzas:index\")\n\n\n@login_required\ndef place_order(request):\n    \"\"\"View that shows the detail of the current order.\"\"\"\n    event = FoodEvent.current()\n    if not event:\n        return redirect(\"pizzas:index\")\n\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n        current_order_locked = not obj.can_be_changed\n    except FoodOrder.DoesNotExist:\n        obj = None\n        current_order_locked = False\n\n    if \"product\" in request.POST and not current_order_locked:\n        productset = Product.available_products.all()\n        if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n            productset = productset.exclude(restricted=True)\n        try:\n            product = productset.get(pk=int(request.POST[\"product\"]))\n        except Product.DoesNotExist as e:\n            raise Http404(\"Pizza does not exist\") from e\n        if not obj:\n            obj = FoodOrder(food_event=event, member=request.member)\n        obj.product = product\n        if obj.payment:\n            delete_payment(obj)\n        obj.save()\n    return redirect(\"pizzas:index\")\n", "path": "website/pizzas/views.py"}]}