Changeset View
Changeset View
Standalone View
Standalone View
looper/views/add_payment_method.py
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | ) -> HttpResponse: | ||||
| gateway = form.cleaned_gateway() | gateway = form.cleaned_gateway() | ||||
| payment_method_nonce = form.cleaned_payment_method_nonce() | payment_method_nonce = form.cleaned_payment_method_nonce() | ||||
| try: | try: | ||||
| checkout_logic.create_payment_method(customer, gateway, payment_method_nonce) | checkout_logic.create_payment_method(customer, gateway, payment_method_nonce) | ||||
| except checkout_logic.PaymentMethodCreationError as e: | except checkout_logic.PaymentMethodCreationError as e: | ||||
| form.add_error( | 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}.' | |||||
| ), | ), | ||||
sybren: Constructing the error message from a gateway error should be a separate function.
Probably… | |||||
| ) | ) | ||||
| return render.add_payment_method(request, form) | return render.add_payment_method(request, form) | ||||
| tokens.clear_client_tokens(request) | tokens.clear_client_tokens(request) | ||||
| return HttpResponseRedirect(next_url) | return HttpResponseRedirect(next_url) | ||||
Constructing the error message from a gateway error should be a separate function.
Probably something for a future cleanup commit, though.