Skip to content

Commit

Permalink
Update receipt #13
Browse files Browse the repository at this point in the history
  • Loading branch information
nnsnodnb committed Jun 5, 2018
1 parent 1dcdc5b commit 94cd29b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def run_tests(base_dir=None, apps=None, verbosity=1, interavtive=False):
sys.path.insert(0, os.path.join(base_dir, 'tests'))

import django
if django.VERSION >= (1,7):
if django.VERSION >= (1, 7):
django.setup()

from django.conf import settings
Expand Down
70 changes: 28 additions & 42 deletions storekit/receipt.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
from django.conf import settings
from .appstore import AppStoreValidator
from .errors import AppValidationError
import logging


def normal_receipt(receipt, sandbox):
try:
validator = AppStoreValidator(
bundle_id=settings.STOREKIT_APP_BUNDLE_ID,
sandbox=sandbox
)
storekit_bundle_id = settings.STOREKIT_APP_BUNDLE_ID
except AttributeError:
raise AttributeError('Please set "STOREKIT_APP_BUNDLE_ID" in your settings.py')

try:
return validator.validate(
receipt=receipt
)
validator = AppStoreValidator(
bundle_id=storekit_bundle_id,
sandbox=sandbox
)

except AppValidationError as e:
logging.error(e)
raise

except AttributeError as e:
# NotFound STOREKIT_APP_BUNDLE_ID
logging.error(e)
raise
return validator.validate(
receipt=receipt
)


def subscribe_receipt(receipt, sandbox):
try:
validator = AppStoreValidator(
bundle_id=settings.STOREKIT_APP_BUNDLE_ID,
sandbox=sandbox
)

try:
return validator.validate(
receipt=receipt,
password=settings.STOREKIT_PURCHASED_SECRET
)

except AppValidationError as e:
logging.error(e)
raise

except AttributeError as e:
# NotFound STOREKIT_PURCHASED_SECRET
logging.error(e)
raise

except AttributeError as e:
# NotFound STOREKIT_APP_BUNDLE_ID
logging.error(e)
raise
storekit_app_bundle_id = settings.STOREKIT_APP_BUNDLE_ID
except AttributeError:
raise AttributeError('Please set "STOREKIT_APP_BUNDLE_ID" in your settings.py')

try:
storekit_purchased_secret = settings.STOREKIT_PURCHASED_SECRET
except AttributeError:
raise AttributeError('Please set "STOREKIT_PURCHASED_SECRET" in your settings.py')

validator = AppStoreValidator(
bundle_id=storekit_app_bundle_id,
sandbox=sandbox
)

return validator.validate(
receipt=receipt,
password=storekit_purchased_secret
)

0 comments on commit 94cd29b

Please sign in to comment.