Commit 85d05558 by Michael Frey Committed by GitHub

Merge pull request #14948 from edx/revert-14939-mjfrey/LEARNER-616

Revert "Only use ecommerce hosted receipt page"
parents 73833e41 b2dcc9c4
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('commerce', '0005_commerceconfiguration_enable_automatic_refund_approval'),
]
operations = [
migrations.RemoveField(
model_name='commerceconfiguration',
name='receipt_page',
),
]
...@@ -15,6 +15,7 @@ class CommerceConfiguration(ConfigurationModel): ...@@ -15,6 +15,7 @@ class CommerceConfiguration(ConfigurationModel):
API_NAME = 'commerce' API_NAME = 'commerce'
CACHE_KEY = 'commerce.api.data' CACHE_KEY = 'commerce.api.data'
DEFAULT_RECEIPT_PAGE_URL = '/commerce/checkout/receipt/?orderNum='
checkout_on_ecommerce_service = models.BooleanField( checkout_on_ecommerce_service = models.BooleanField(
default=False, default=False,
...@@ -33,6 +34,11 @@ class CommerceConfiguration(ConfigurationModel): ...@@ -33,6 +34,11 @@ class CommerceConfiguration(ConfigurationModel):
'Specified in seconds. Enable caching by setting this to a value greater than 0.' 'Specified in seconds. Enable caching by setting this to a value greater than 0.'
) )
) )
receipt_page = models.CharField(
max_length=255,
default=DEFAULT_RECEIPT_PAGE_URL,
help_text=_('Path to order receipt page.')
)
enable_automatic_refund_approval = models.BooleanField( enable_automatic_refund_approval = models.BooleanField(
default=True, default=True,
help_text=_('Automatically approve valid refund requests, without manual processing') help_text=_('Automatically approve valid refund requests, without manual processing')
......
...@@ -11,11 +11,16 @@ from openedx.core.lib.log_utils import audit_log ...@@ -11,11 +11,16 @@ from openedx.core.lib.log_utils import audit_log
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
TEST_SITE_CONFIGURATION = {
'ECOMMERCE_RECEIPT_PAGE_URL': '/checkout/receipt/?order_number='
}
def update_commerce_config(enabled=False, checkout_page='/test_basket/'):
def update_commerce_config(enabled=False, checkout_page='/test_basket/', receipt_page='/checkout/receipt/'):
""" Enable / Disable CommerceConfiguration model """ """ Enable / Disable CommerceConfiguration model """
CommerceConfiguration.objects.create( CommerceConfiguration.objects.create(
checkout_on_ecommerce_service=enabled, checkout_on_ecommerce_service=enabled,
receipt_page=receipt_page,
single_course_checkout_page=checkout_page, single_course_checkout_page=checkout_page,
) )
...@@ -78,7 +83,7 @@ class EcommerceServiceTests(TestCase): ...@@ -78,7 +83,7 @@ class EcommerceServiceTests(TestCase):
"""Verify that the proper Receipt page URL is returned.""" """Verify that the proper Receipt page URL is returned."""
order_number = 'ORDER1' order_number = 'ORDER1'
url = EcommerceService().get_receipt_page_url(order_number) url = EcommerceService().get_receipt_page_url(order_number)
expected_url = 'http://ecommerce_url/checkout/receipt/?order_number={}'.format(order_number) expected_url = '/checkout/receipt/{}'.format(order_number)
self.assertEqual(url, expected_url) self.assertEqual(url, expected_url)
@override_settings(ECOMMERCE_PUBLIC_URL_ROOT='http://ecommerce_url') @override_settings(ECOMMERCE_PUBLIC_URL_ROOT='http://ecommerce_url')
...@@ -87,3 +92,19 @@ class EcommerceServiceTests(TestCase): ...@@ -87,3 +92,19 @@ class EcommerceServiceTests(TestCase):
url = EcommerceService().checkout_page_url(self.SKU) url = EcommerceService().checkout_page_url(self.SKU)
expected_url = 'http://ecommerce_url/test_basket/?sku={}'.format(self.SKU) expected_url = 'http://ecommerce_url/test_basket/?sku={}'.format(self.SKU)
self.assertEqual(url, expected_url) self.assertEqual(url, expected_url)
@override_settings(ECOMMERCE_PUBLIC_URL_ROOT='http://ecommerce_url')
@with_site_configuration(configuration=TEST_SITE_CONFIGURATION)
def test_get_receipt_page_url_with_site_configuration(self):
order_number = 'ORDER1'
config = CommerceConfiguration.current()
config.use_ecommerce_receipt_page = True
config.save()
receipt_page_url = EcommerceService().get_receipt_page_url(order_number)
expected_url = '{ecommerce_root}{receipt_page_url}{order_number}'.format(
ecommerce_root=settings.ECOMMERCE_PUBLIC_URL_ROOT,
order_number=order_number,
receipt_page_url=TEST_SITE_CONFIGURATION['ECOMMERCE_RECEIPT_PAGE_URL']
)
self.assertEqual(receipt_page_url, expected_url)
...@@ -6,8 +6,6 @@ from django.conf import settings ...@@ -6,8 +6,6 @@ from django.conf import settings
from commerce.models import CommerceConfiguration from commerce.models import CommerceConfiguration
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
RECEIPT_PAGE_URL = '/checkout/receipt/?order_number='
class EcommerceService(object): class EcommerceService(object):
""" Helper class for ecommerce service integration. """ """ Helper class for ecommerce service integration. """
...@@ -40,8 +38,11 @@ class EcommerceService(object): ...@@ -40,8 +38,11 @@ class EcommerceService(object):
Returns: Returns:
Receipt page for the specified Order. Receipt page for the specified Order.
""" """
ecommerce_receipt_page_url = configuration_helpers.get_value('ECOMMERCE_RECEIPT_PAGE_URL')
return self.get_absolute_ecommerce_url(RECEIPT_PAGE_URL + order_number) if ecommerce_receipt_page_url:
return self.get_absolute_ecommerce_url(ecommerce_receipt_page_url + order_number)
return self.config.receipt_page + order_number
def is_enabled(self, user): def is_enabled(self, user):
""" """
......
...@@ -645,7 +645,7 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf ...@@ -645,7 +645,7 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf
'number': order['number'], 'number': order['number'],
'price': order['total_excl_tax'], 'price': order['total_excl_tax'],
'order_date': 'Jan 01, 2016', 'order_date': 'Jan 01, 2016',
'receipt_url': '/checkout/receipt/?order_number=' + order['number'], 'receipt_url': '/commerce/checkout/receipt/?orderNum=' + order['number'],
'lines': order['lines'], 'lines': order['lines'],
} }
self.assertEqual(order_detail[i], expected) self.assertEqual(order_detail[i], expected)
......
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