diff --git a/common/djangoapps/course_modes/models.py b/common/djangoapps/course_modes/models.py index d76823e9bb..e92657f956 100644 --- a/common/djangoapps/course_modes/models.py +++ b/common/djangoapps/course_modes/models.py @@ -126,6 +126,16 @@ class CourseMode(models.Model): self.currency = self.currency.lower() super(CourseMode, self).save(force_insert, force_update, using) + @property + def slug(self): + """ + Returns mode_slug + + NOTE (CCB): This is a silly hack needed because all of the class methods use tuples + with a property named slug instead of mode_slug. + """ + return self.mode_slug + @classmethod def all_modes_for_courses(cls, course_id_list): """Find all modes for a list of course IDs, including expired modes. diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index ea89f8828c..819d7ecac5 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -766,13 +766,22 @@ def create_order(request): return HttpResponseBadRequest(_("Selected price is not valid number.")) current_mode = None - paid_modes = CourseMode.paid_modes_for_course(course_id) - # Check if there are more than 1 paid(mode with min_price>0 e.g verified/professional/no-id-professional) modes - # for course exist then choose the first one - if paid_modes: - if len(paid_modes) > 1: - log.warn(u"Multiple paid course modes found for course '%s' for create order request", course_id) - current_mode = paid_modes[0] + sku = request.POST.get('sku', None) + + if sku: + try: + current_mode = CourseMode.objects.get(sku=sku) + except CourseMode.DoesNotExist: + log.exception(u'Failed to find CourseMode with SKU [%s].', sku) + + if not current_mode: + # Check if there are more than 1 paid(mode with min_price>0 e.g verified/professional/no-id-professional) modes + # for course exist then choose the first one + paid_modes = CourseMode.paid_modes_for_course(course_id) + if paid_modes: + if len(paid_modes) > 1: + log.warn(u"Multiple paid course modes found for course '%s' for create order request", course_id) + current_mode = paid_modes[0] # Make sure this course has a paid mode if not current_mode: diff --git a/lms/static/js/spec/verify_student/make_payment_step_view_spec.js b/lms/static/js/spec/verify_student/make_payment_step_view_spec.js index c63915c780..7e59684588 100644 --- a/lms/static/js/spec/verify_student/make_payment_step_view_spec.js +++ b/lms/static/js/spec/verify_student/make_payment_step_view_spec.js @@ -66,7 +66,8 @@ define([ var params = { contribution: kwargs.amount || "", course_id: kwargs.courseId || "", - processor: kwargs.processor || "" + processor: kwargs.processor || "", + sku: kwargs.sku || "" }; // Click the "go to payment" button diff --git a/lms/static/js/verify_student/pay_and_verify.js b/lms/static/js/verify_student/pay_and_verify.js index 3503afc7db..3e989f80f9 100644 --- a/lms/static/js/verify_student/pay_and_verify.js +++ b/lms/static/js/verify_student/pay_and_verify.js @@ -55,6 +55,7 @@ var edx = edx || {}; ), upgrade: el.data('msg-key') === 'upgrade', minPrice: el.data('course-mode-min-price'), + sku: el.data('course-mode-sku'), contributionAmount: el.data('contribution-amount'), suggestedPrices: _.filter( (el.data('course-mode-suggested-prices').toString()).split(","), diff --git a/lms/static/js/verify_student/views/make_payment_step_view.js b/lms/static/js/verify_student/views/make_payment_step_view.js index 20f56c03a9..9aee49a7b4 100644 --- a/lms/static/js/verify_student/views/make_payment_step_view.js +++ b/lms/static/js/verify_student/views/make_payment_step_view.js @@ -17,6 +17,7 @@ var edx = edx || {}; isActive: true, suggestedPrices: [], minPrice: 0, + sku: '', currency: 'usd', upgrade: false, verificationDeadline: '', @@ -133,7 +134,8 @@ var edx = edx || {}; postData = { 'processor': event.target.id, 'contribution': paymentAmount, - 'course_id': this.stepData.courseKey + 'course_id': this.stepData.courseKey, + 'sku': this.templateContext().sku }; // Disable the payment button to prevent multiple submissions diff --git a/lms/static/sass/views/_verification.scss b/lms/static/sass/views/_verification.scss index 979c5cf956..bb4c32f847 100644 --- a/lms/static/sass/views/_verification.scss +++ b/lms/static/sass/views/_verification.scss @@ -263,7 +263,8 @@ @include text-align(center); .provider-logo img { - width: 100px; + max-width: 160px; + margin-bottom: $baseline * 0.5; } .complete-order { diff --git a/lms/templates/verify_student/make_payment_step.underscore b/lms/templates/verify_student/make_payment_step.underscore index 06094a2997..4f572426c1 100644 --- a/lms/templates/verify_student/make_payment_step.underscore +++ b/lms/templates/verify_student/make_payment_step.underscore @@ -100,6 +100,7 @@ <% if ( isActive ) { %>