Environment¶
Environment
is designed to pass pre-defined policies in easy way.
The major use cases are provided as pre-defined constants.
How to use environments¶
The default policy is default and it is the same to production. When your development lifecycle is proceed, you want to change it to sandbox or review.
The recommended way to use environments is passing the value to
itunesiap.verify()
function as keyword argument env.
>>> itunesiap.verify(receipt, env=itunesiap.env.production)
>>> itunesiap.verify(receipt, env=itunesiap.env.sandbox)
>>> itunesiap.verify(receipt, env=itunesiap.env.review)
Review mode¶
This is useful when your server is being used both for real users and Apple reviewers. Using review mode for a real service is possible, but be aware of: it is not 100% safe. Your testers can getting advantage of free IAP in production version. A rough solution what I suggest is:
>>> if client_version == review_version:
>>> env = itunesiap.env.review
>>> else:
>>> env = itunesiap.env.production
>>>
>>> itunesiap.verify(receipt, env=env)
Environment¶
-
class
itunesiap.environment.
Environment
(**kwargs)¶ Environment provides option preset for Request. default is default.
By passing an environment object to
itunesiap.verify()
oritunesiap.request.Request.verify()
function, it replaces verifying policies.-
clone
(**kwargs)¶ Clone the environment with additional parameter override
-
extract
()¶ Extract options from self and merge to kwargs then return a new dictionary with the values.
-
override
(**kwargs)¶ Override options in kwargs to given object self.
-
-
itunesiap.environment.
default
= <Environment use_production=True use_sandbox=False timeout=30.0 exclude_old_transactions=False verify_ssl=True>¶ Use only production server with 30 seconds of timeout.
-
itunesiap.environment.
production
= <Environment use_production=True use_sandbox=False timeout=30.0 exclude_old_transactions=False verify_ssl=True>¶ Use only production server with 30 seconds of timeout.
-
itunesiap.environment.
sandbox
= <Environment use_production=False use_sandbox=True timeout=30.0 exclude_old_transactions=False verify_ssl=True>¶ Use only sandbox server with 30 seconds of timeout.
-
itunesiap.environment.
review
= <Environment use_production=True use_sandbox=True timeout=30.0 exclude_old_transactions=False verify_ssl=True>¶ Environment provides option preset for Request. default is default.
By passing an environment object to
itunesiap.verify()
oritunesiap.request.Request.verify()
function, it replaces verifying policies.
-
itunesiap.environment.
unsafe
= <Environment use_production=True use_sandbox=True timeout=None exclude_old_transactions=False verify_ssl=False>¶ Environment provides option preset for Request. default is default.
By passing an environment object to
itunesiap.verify()
oritunesiap.request.Request.verify()
function, it replaces verifying policies.