Skip to main content

pyinapp

travis pypi

In-app purchase validation has never been so friendly and convenient!

Installation

pip install pyinapp

Usage

Currently pyinapp supports Google Play and App Store receipts validation.

Google Play:

from pyinapp import GooglePlayValidator, InAppValidationError


bundle_id = 'com.yourcompany.yourapp'
api_key = 'API key from the developer console'
validator = GooglePlayValidator(bundle_id, api_key)

try:
    purchases = validator.validate('receipt', 'signature')
    process_purchases(purchases)
except InAppValidationError:
    """ handle validation error """

App Store:

from pyinapp import AppStoreValidator, InAppValidationError


bundle_id = 'com.yourcompany.yourapp'
validator = AppStoreValidator(bundle_id)

try:
    purchases = validator.validate('receipt')
    process_purchases(purchases)
except InAppValidationError:
    """ handle validation error """

Important! If your version is under 0.1.3, you need to check the type of purchases. For the sake of convenience you can process purchases this way:

def process_purchases(purchases):
    process(*purchases) if isinstance(purchases, list) else process(purchases)


def process(*purchases):
    for p in purchases:
        """ for instance, save p to db and add a player some coins for it """

This approach allows to process both Google Play and App Store purchases the same way.

Purchase

Purchase is a universal wrapper for Google Play and App Store receipts. It contains the following fields:

  • transaction_id: id of the purchase (transaction_id for App Store and orderId for Google Play);

  • product_id: what product has been purchased (product_id for App Store and productId for Google Play);

  • quantity: how many products have been purchased (quantity for App Store and always 1 for Google Play - there’s no such field in Google Play receipt);

  • purchased_at: when the product has been purchased, UNIX timestamp (purchase_date for App Store and purchaseTime for Google Play).

  • response: (App Store only) the response (in JSON format) from the App Store.

Contributing

To run tests, you’ll need tox. After installing, simply run it:

tox

Metadata

Release files for pyinapp 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyinapp 0.1.5
File Size Uploaded Provenance
pyinapp-0.1.5.tar.gz 3.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyinapp 0.1.5
File Interpreter ABI Platform
pyinapp-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / pyinapp-0.1.5.tar.gz

Download URL pyinapp-0.1.5.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
60e573ac96b720eeabd4df1583beeb99f5b4f0b09dab042b128ea4cf7104ad22
BLAKE2b-256 checksum
How to use checksums
579cf7fa3a8c7e875c53dcf5fe9201292e11e75df7f7a50fa39369fecb82ce28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3

Release files / pyinapp-0.1.5-py3-none-any.whl

Download URL pyinapp-0.1.5-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
902a0c2529005f877ea57f1b9b6eab503003e5f42c3e1f6ba73604d41acc2dff
BLAKE2b-256 checksum
How to use checksums
01026e86f951a45ae3cc52fa6620bc1d3818826a583411ac6a209b6edf578686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3

Security for pyinapp 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page