-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |