diff --git a/lms/djangoapps/commerce/urls.py b/lms/djangoapps/commerce/urls.py index 3fa815adc8..711a69d44d 100644 --- a/lms/djangoapps/commerce/urls.py +++ b/lms/djangoapps/commerce/urls.py @@ -4,9 +4,10 @@ Defines the URL routes for this app. from django.conf.urls import patterns, url -from .views import OrdersView +from .views import OrdersView, checkout_cancel urlpatterns = patterns( '', url(r'^orders/$', OrdersView.as_view(), name="orders"), + url(r'^checkout/cancel/$', checkout_cancel, name="checkout_cancel"), ) diff --git a/lms/djangoapps/commerce/views.py b/lms/djangoapps/commerce/views.py index 44b17efaa1..c80daf7229 100644 --- a/lms/djangoapps/commerce/views.py +++ b/lms/djangoapps/commerce/views.py @@ -1,6 +1,9 @@ """ Commerce views. """ import logging +from django.conf import settings +from django.views.decorators.cache import cache_page + from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from rest_framework.permissions import IsAuthenticated @@ -13,7 +16,9 @@ from commerce.exceptions import ApiError, InvalidConfigurationError from commerce.http import DetailResponse, InternalRequestErrorResponse from course_modes.models import CourseMode from courseware import courses +from edxmako.shortcuts import render_to_response from enrollment.api import add_enrollment +from microsite_configuration import microsite from student.models import CourseEnrollment from openedx.core.lib.api.authentication import SessionAuthenticationAllowInactiveUser @@ -123,3 +128,10 @@ class OrdersView(APIView): except ApiError as err: # The API will handle logging of the error. return InternalRequestErrorResponse(err.message) + + +@cache_page(1800) +def checkout_cancel(_request): + """ Checkout/payment cancellation view. """ + context = {'payment_support_email': microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)} + return render_to_response("commerce/checkout_cancel.html", context) diff --git a/lms/templates/commerce/checkout_cancel.html b/lms/templates/commerce/checkout_cancel.html new file mode 100644 index 0000000000..d2f03e07d0 --- /dev/null +++ b/lms/templates/commerce/checkout_cancel.html @@ -0,0 +1,12 @@ +<%! from django.utils.translation import ugettext as _ %> + +<%inherit file="../main.html" /> + +<%block name="pagetitle">${_("Checkout Cancelled")} + + +
+

${_("Checkout Cancelled")}

+ ${ _(u"Your transaction has been cancelled. If you feel an error has occurred, contact {email}.").format( + email="{email}".format(email=payment_support_email)) } +