Skip to content

Commit

Permalink
fix: Added ios inapp price check
Browse files Browse the repository at this point in the history
  • Loading branch information
jawad-khan committed Aug 6, 2024
1 parent ca5f812 commit 5736a9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ecommerce/extensions/iap/api/v1/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,25 @@ def test_create_ios_product(self, _, __, ___, ____, _____, ______, _______):
course = {
'key': 'test',
'name': 'test',
'price': '123'
'price': 123
}
error_msg = create_ios_product(course, self.ios_seat, self.configuration)
self.assertEqual(error_msg, None)

# @mock.patch('ecommerce.extensions.iap.api.v1.utils.create_inapp_purchase')
def test_error_on_ios_product_price_threshhold(self, _,):
course = {
'key': 'test',
'name': 'test',
'price': 1001
}
error_msg = create_ios_product(course, self.ios_seat, self.configuration)
self.assertEqual(error_msg, 'Error: Appstore does not allow price> 1000')

def test_create_ios_product_with_failure(self, _):
course = {
'key': 'test',
'name': 'test',
'price': '123'
'price': 123
}
error_msg = create_ios_product(course, self.ios_seat, self.configuration)
expected_msg = "[Couldn't create inapp purchase id] for course [{}] with sku [{}]".format(
Expand All @@ -110,7 +118,7 @@ def test_create_inapp_purchase(self, _):
course = {
'key': 'test',
'name': 'test',
'price': '123'
'price': 123
}
headers = get_auth_headers(self.configuration)
create_inapp_purchase(course, 'test.sku', '123', headers)
Expand Down
3 changes: 3 additions & 0 deletions ecommerce/extensions/iap/api/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def create_ios_product(course, ios_product, configuration):
Create in app ios product on connect store.
return error message in case of failure.
"""
if course['price'] > 1000:
return 'Error: Appstore does not allow price> 1000'

headers = get_auth_headers(configuration)
try:
in_app_purchase_id = get_or_create_inapp_purchase(ios_product, course, configuration, headers)
Expand Down

0 comments on commit 5736a9b

Please sign in to comment.