Quickstart¶
Create request to create a request to itunes verify api.
>>> import itunesiap
>>> try:
>>> response = itunesiap.verify(raw_data) # base64-encoded data
>>> except itunesiap.exc.InvalidReceipt as e:
>>> print('invalid receipt')
>>> print response.receipt.last_in_app.product_id
>>> # other values are also available as properties!
Practically useful attributes are: product_id, original_transaction_id, quantity and unique_identifier.
See the full document in itunesiap.receipt.InApp
.
For asyncio
, replace itunesiap.verify()
funciton to
itunesiap.aioverify()
. That’s all.
>>> response = itunesiap.aioverify(raw_data)
itunesiap.verify()¶
Note that most of the use cases are covered by the itunesiap.verify()
function.
-
itunesiap.
verify
(receipt_data, password=None, exclude_old_transactions=False, **kwargs)¶ Shortcut API for
itunesiap.request.Request
.- See also:
Parameters: - receipt_data (str) –
itunesiap.request.Request
variable. An iTunes receipt data as Base64 encoded string. - password (str) –
itunesiap.request.Request
variable. Optional. Only used for receipts that contain auto-renewable subscriptions. Your app’s shared secret (a hexadecimal string). - exclude_old_transactions (bool) –
itunesiap.request.Request
variable. Optional. Only used for iOS7 style app receipts that contain auto-renewable or non-renewing subscriptions. If value is true, response includes only the latest renewal transaction for any subscriptions. - env (itunesiap.environment.Environment) – Set base environment value.
See
itunesiap.environment
for detail. - timeout (float) –
itunesiap.request.Request.verify()
variable. Keyword-only optional. The value is connection timeout of the verifying request. The default value is 30.0 when no env is given. - use_production (bool) –
itunesiap.request.Request.verify()
variable. Keyword-only optional. The value is weather verifying in production server or not. The default value isbool
True when no env is given. - use_sandbox (bool) –
itunesiap.request.Request.verify()
variable. Keyword-only optional. The value is weather verifying in sandbox server or not. The default value isbool
False when no env is given. - verify_ssl (bool) –
itunesiap.request.Request.verify()
variable. Keyword-only optional. The value is weather enabling SSL verification or not. WARNING: DO NOT TURN IT OFF WITHOUT A PROPER REASON. IF YOU DON’T UNDERSTAND WHAT IT MEANS, NEVER SET IT YOURSELF. - proxy_url (str) – Keyword-only optional. A proxy url to access the iTunes validation url.
Returns: itunesiap.receipt.Receipt
object if succeed.Raises: Otherwise raise a request exception in
itunesiap.exceptions
.
-
itunesiap.
aioverify
(receipt_data, password=None, exclude_old_transactions=False, **kwargs)¶ Shortcut API for
itunesiap.request.Request
.For params and returns, see
itunesiap.verify()
.
Apple in-review mode¶
In review mode, your actual users who use older versions want to verify in production server but the reviewers in Apple office want to verify in sandbox server.
Note: The default env is production mode which doesn’t allow any sandbox verifications.
You can change the verifying mode by specifying env.
>>> # review mode
>>> itunesiap.verify(raw_data, env=itunesiap.env.review)
>>> # sandbox mode
>>> itunesiap.verify(raw_data, env=itunesiap.env.sandbox)
Also directly passing arguments are accepted:
>>> # review mode
>>> itunesiap.verify(raw_data, use_production=True, use_sandbox=True)