From 12fec6c918862101a65d536546743e4f008287f4 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 10 Nov 2014 16:40:37 -0500 Subject: [PATCH] Send transaction type for donations and verified certificates to CyberSource --- .../shoppingcart/tests/test_views.py | 10 ++++++++ lms/djangoapps/shoppingcart/views.py | 8 ++++++- .../verify_student/tests/test_views.py | 24 ++++++++++++++++++- lms/djangoapps/verify_student/views.py | 2 +- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/shoppingcart/tests/test_views.py b/lms/djangoapps/shoppingcart/tests/test_views.py index aed264158f..96db9e0e51 100644 --- a/lms/djangoapps/shoppingcart/tests/test_views.py +++ b/lms/djangoapps/shoppingcart/tests/test_views.py @@ -1246,6 +1246,16 @@ class DonationViewTest(ModuleStoreTestCase): payment_info["payment_params"]["merchant_defined_data1"], unicode(course_id) ) + self.assertEqual( + payment_info["payment_params"]["merchant_defined_data2"], + "donation_course" + ) + else: + self.assertEqual(payment_info["payment_params"]["merchant_defined_data1"], "") + self.assertEqual( + payment_info["payment_params"]["merchant_defined_data2"], + "donation_general" + ) processor_response_params = PaymentFakeView.response_post_params(payment_info["payment_params"]) diff --git a/lms/djangoapps/shoppingcart/views.py b/lms/djangoapps/shoppingcart/views.py index fc7eab58cd..806a2d6a97 100644 --- a/lms/djangoapps/shoppingcart/views.py +++ b/lms/djangoapps/shoppingcart/views.py @@ -490,6 +490,12 @@ def donate(request): reverse("shoppingcart.views.postpay_callback") ) + # Add extra to make it easier to track transactions + extra_data = [ + unicode(course_id) if course_id else "", + "donation_course" if course_id else "donation_general" + ] + response_params = json.dumps({ # The HTTP end-point for the payment processor. "payment_url": get_purchase_endpoint(), @@ -498,7 +504,7 @@ def donate(request): "payment_params": get_signed_purchase_params( cart, callback_url=callback_url, - extra_data=([unicode(course_id)] if course_id else None) + extra_data=extra_data ), }) diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index 20933bd689..73151aee17 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -697,8 +697,30 @@ 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" + # Verify that the course ID and transaction type are included in "merchant-defined data" self.assertEqual(data['merchant_defined_data1'], unicode(self.course.id)) + self.assertEqual(data['merchant_defined_data2'], "verified") + + def test_create_order_already_verified_prof_ed(self): + # Verify the student so we don't need to submit photos + self._verify_student() + + # Create a prof ed course + course = CourseFactory.create() + CourseModeFactory(mode_slug="professional", course_id=course.id) + + # Create an order for a prof ed course + url = reverse('verify_student_create_order') + params = { + 'course_id': unicode(course.id) + } + response = self.client.post(url, params) + self.assertEqual(response.status_code, 200) + + # Verify that the course ID and transaction type are included in "merchant-defined data" + data = json.loads(response.content) + self.assertEqual(data['merchant_defined_data1'], unicode(course.id)) + self.assertEqual(data['merchant_defined_data2'], "professional") def test_create_order_set_donation_amount(self): # Verify the student so we don't need to submit photos diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index c5bbda25cc..e181687edd 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -238,7 +238,7 @@ def create_order(request): params = get_signed_purchase_params( cart, callback_url=callback_url, - extra_data=[unicode(course_id)] + extra_data=[unicode(course_id), current_mode.slug] ) params['success'] = True