Commit 484f13c3 by Diana Huang

Merge pull request #5154 from edx/diana/pass-along-course-id

Pass along course id to CyberSource
parents 4596e8c2 c47673bb
...@@ -683,6 +683,9 @@ class TestCreateOrder(ModuleStoreTestCase): ...@@ -683,6 +683,9 @@ class TestCreateOrder(ModuleStoreTestCase):
data = json.loads(response.content) data = json.loads(response.content)
self.assertEqual(data['override_custom_receipt_page'], "http://testserver/shoppingcart/postpay_callback/") 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): def test_create_order_set_donation_amount(self):
# Verify the student so we don't need to submit photos # Verify the student so we don't need to submit photos
self._verify_student() self._verify_student()
......
...@@ -34,7 +34,7 @@ from verify_student.models import ( ...@@ -34,7 +34,7 @@ from verify_student.models import (
from reverification.models import MidcourseReverificationWindow from reverification.models import MidcourseReverificationWindow
import ssencrypt import ssencrypt
from xmodule.modulestore.exceptions import ItemNotFoundError 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 .exceptions import WindowExpiredException
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -59,7 +59,7 @@ class VerifyView(View): ...@@ -59,7 +59,7 @@ class VerifyView(View):
""" """
upgrade = request.GET.get('upgrade', False) 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, # If the user has already been verified within the given time period,
# redirect straight to the payment -- no need to verify again. # redirect straight to the payment -- no need to verify again.
if SoftwareSecurePhotoVerification.user_has_valid_or_pending(request.user): if SoftwareSecurePhotoVerification.user_has_valid_or_pending(request.user):
...@@ -133,7 +133,7 @@ class VerifiedView(View): ...@@ -133,7 +133,7 @@ class VerifiedView(View):
Handle the case where we have a get request Handle the case where we have a get request
""" """
upgrade = request.GET.get('upgrade', False) 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): if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == ('verified', True):
return redirect(reverse('dashboard')) return redirect(reverse('dashboard'))
...@@ -195,7 +195,7 @@ def create_order(request): ...@@ -195,7 +195,7 @@ def create_order(request):
attempt.save() attempt.save()
course_id = request.POST['course_id'] 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', {}) donation_for_course = request.session.get('donation_for_course', {})
current_donation = donation_for_course.get(unicode(course_id), decimal.Decimal(0)) 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)) contribution = request.POST.get("contribution", donation_for_course.get(unicode(course_id), 0))
...@@ -239,10 +239,13 @@ def create_order(request): ...@@ -239,10 +239,13 @@ def create_order(request):
callback_url = request.build_absolute_uri( callback_url = request.build_absolute_uri(
reverse("shoppingcart.views.postpay_callback") reverse("shoppingcart.views.postpay_callback")
) )
params = get_signed_purchase_params( params = get_signed_purchase_params(
cart, callback_url=callback_url cart, callback_url=callback_url
) )
params['success'] = True params['success'] = True
params['merchant_defined_data1'] = unicode(course_id)
return HttpResponse(json.dumps(params), content_type="text/json") return HttpResponse(json.dumps(params), content_type="text/json")
...@@ -331,7 +334,7 @@ def show_requirements(request, course_id): ...@@ -331,7 +334,7 @@ def show_requirements(request, course_id):
Show the requirements necessary for the verification flow. 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 # 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) upgrade = request.GET.get('upgrade', False)
if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == ('verified', True): if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == ('verified', True):
return redirect(reverse('dashboard')) return redirect(reverse('dashboard'))
...@@ -430,7 +433,7 @@ class MidCourseReverifyView(View): ...@@ -430,7 +433,7 @@ class MidCourseReverifyView(View):
""" """
display this 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 = modulestore().get_course(course_id)
course_enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_id) course_enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_id)
course_enrollment.update_enrollment(mode="verified") course_enrollment.update_enrollment(mode="verified")
...@@ -454,7 +457,7 @@ class MidCourseReverifyView(View): ...@@ -454,7 +457,7 @@ class MidCourseReverifyView(View):
""" """
try: try:
now = datetime.datetime.now(UTC) 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) window = MidcourseReverificationWindow.get_window(course_id, now)
if window is None: if window is None:
raise WindowExpiredException raise WindowExpiredException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment