diff --git a/lms/djangoapps/shoppingcart/tests/test_views.py b/lms/djangoapps/shoppingcart/tests/test_views.py index d7d7e935b8..287a858b44 100644 --- a/lms/djangoapps/shoppingcart/tests/test_views.py +++ b/lms/djangoapps/shoppingcart/tests/test_views.py @@ -1217,7 +1217,14 @@ class ReceiptRedirectTest(UrlResetMixin, ModuleStoreTestCase): @patch.dict(settings.FEATURES, {'SEPARATE_VERIFICATION_FROM_PAYMENT': True}) def test_show_receipt_redirect_to_verify_student(self): + # Create other carts first + # This ensures that the order ID and order item IDs do not match + Order.get_cart_for_user(self.user).start_purchase() + Order.get_cart_for_user(self.user).start_purchase() + Order.get_cart_for_user(self.user).start_purchase() + # Purchase a verified certificate + self.cart = Order.get_cart_for_user(self.user) CertificateItem.add_to_order( self.cart, self.course_key, diff --git a/lms/djangoapps/shoppingcart/views.py b/lms/djangoapps/shoppingcart/views.py index 1da5c24bfc..f2a54457f5 100644 --- a/lms/djangoapps/shoppingcart/views.py +++ b/lms/djangoapps/shoppingcart/views.py @@ -818,7 +818,7 @@ def _show_receipt_html(request, order): # Add a query string param for the order ID # This allows the view to query for the receipt information later. url += '?payment-order-num={order_num}'.format( - order_num=order_items[0].id + order_num=order_items[0].order.id ) return HttpResponseRedirect(url)