diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index fd35621d0d..6ce29b5d08 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -683,6 +683,9 @@ class TestCreateOrder(ModuleStoreTestCase): data = json.loads(response.content) self.assertEqual(data['override_custom_receipt_page'], "http://testserver/shoppingcart/postpay_callback/") + # Verify that the course ID is included in "merchant-defined data" + self.assertEqual(data['merchant_defined_data1'], unicode(self.course.id)) + def test_create_order_set_donation_amount(self): # Verify the student so we don't need to submit photos self._verify_student() diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index a854b9346c..f055fea197 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -34,7 +34,7 @@ from verify_student.models import ( from reverification.models import MidcourseReverificationWindow import ssencrypt from xmodule.modulestore.exceptions import ItemNotFoundError -from opaque_keys.edx.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey from .exceptions import WindowExpiredException from xmodule.modulestore.django import modulestore @@ -59,7 +59,7 @@ class VerifyView(View): """ upgrade = request.GET.get('upgrade', False) - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) # If the user has already been verified within the given time period, # redirect straight to the payment -- no need to verify again. if SoftwareSecurePhotoVerification.user_has_valid_or_pending(request.user): @@ -133,7 +133,7 @@ class VerifiedView(View): Handle the case where we have a get request """ upgrade = request.GET.get('upgrade', False) - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == ('verified', True): return redirect(reverse('dashboard')) @@ -195,7 +195,7 @@ def create_order(request): attempt.save() course_id = request.POST['course_id'] - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) donation_for_course = request.session.get('donation_for_course', {}) current_donation = donation_for_course.get(unicode(course_id), decimal.Decimal(0)) contribution = request.POST.get("contribution", donation_for_course.get(unicode(course_id), 0)) @@ -239,10 +239,13 @@ def create_order(request): callback_url = request.build_absolute_uri( reverse("shoppingcart.views.postpay_callback") ) + params = get_signed_purchase_params( cart, callback_url=callback_url ) + params['success'] = True + params['merchant_defined_data1'] = unicode(course_id) return HttpResponse(json.dumps(params), content_type="text/json") @@ -331,7 +334,7 @@ def show_requirements(request, course_id): Show the requirements necessary for the verification flow. """ # TODO: seems borked for professional; we're told we need to take photos even if there's a pending verification - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) upgrade = request.GET.get('upgrade', False) if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == ('verified', True): return redirect(reverse('dashboard')) @@ -430,7 +433,7 @@ class MidCourseReverifyView(View): """ display this view """ - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) course = modulestore().get_course(course_id) course_enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_id) course_enrollment.update_enrollment(mode="verified") @@ -454,7 +457,7 @@ class MidCourseReverifyView(View): """ try: now = datetime.datetime.now(UTC) - course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course_id = CourseKey.from_string(course_id) window = MidcourseReverificationWindow.get_window(course_id, now) if window is None: raise WindowExpiredException