Changeset View
Changeset View
Standalone View
Standalone View
looper/views/checkout/existing_order.py
| from typing import Optional | from typing import Optional | ||||
| from django.conf import settings | |||||
| from django.contrib.auth.decorators import login_required | from django.contrib.auth.decorators import login_required | ||||
| from django.core.exceptions import PermissionDenied | from django.core.exceptions import PermissionDenied | ||||
| from django.http.request import HttpRequest | from django.http.request import HttpRequest | ||||
| from django.http.response import HttpResponse | from django.http.response import HttpResponse | ||||
| from django.shortcuts import get_object_or_404 | from django.shortcuts import get_object_or_404 | ||||
| from django.views.decorators.http import require_http_methods | from django.views.decorators.http import require_http_methods | ||||
| from looper import checkout_logic, permissions | from looper import checkout_logic, permissions | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | try: | ||||
| payment_result = checkout_logic.charge_existing_order( | payment_result = checkout_logic.charge_existing_order( | ||||
| order, customer, customer_ip_address, new_address, gateway, payment_method_nonce, | order, customer, customer_ip_address, new_address, gateway, payment_method_nonce, | ||||
| ) | ) | ||||
| except checkout_logic.PaymentMethodCreationError as e: | except checkout_logic.PaymentMethodCreationError as e: | ||||
| payment_method_form.add_error( | payment_method_form.add_error( | ||||
| field=None, | field=None, | ||||
| error=( | error=( | ||||
| f'Error from the payment gateway: {e.message} ' | f'Error from the payment gateway: {e.message} ' | ||||
| 'Please refresh the page and try again.' | f'Please try to submit the form again and if the issue persists contact ' | ||||
| f'{settings.EMAIL_SUPPORT}.' | |||||
| ), | ), | ||||
| ) | ) | ||||
| return render.existing_order( | return render.existing_order( | ||||
| request, address_form, payment_method_form, plan, subscription, order, | request, address_form, payment_method_form, plan, subscription, order, | ||||
| ) | ) | ||||
| except checkout_logic.PaymentFailedError as e: | except checkout_logic.PaymentFailedError as e: | ||||
| payment_method_form.add_error( | payment_method_form.add_error( | ||||
| field=None, error=e.message, | field=None, error=e.message, | ||||
| Show All 15 Lines | |||||