Skip to main content

IABwrapper

Wrapper around anjlab's Android In-app Billing Version 3 to be used in Kivy apps

Build Status Python 3.6 PyPI format downloads code size repo size

Install

pip install iabwrapper

or add it in buildozer.spec requirements

requirements = ..., iabwrapper==0.0.5

Important ( Add these into your buildozer.spec )

  • android.gradle_repositories = "mavenCentral()"
    
  • android.gradle_dependencies = com.anjlab.android.iab.v3:library:2.0.0,
    
  • android.meta_data = billing_pubkey = "Your License Key from Play Console"
    
  • Necessary permissions:

    android.permissions = INTERNET,ACCESS_NETWORK_STATE,com.android.vending.BILLING
    

Usage

  • Import
    from iabwrapper import BillingProcessor
    
  • Create an Instance
    bp = BillingProcessor(
        license_key,
        onProductPurchasedMethod,
        onBillingErrorMethod,
        onPurchaseHistoryRestoredMethod=None,
        onBillingInitializedMethod=None,
    )
    
    # license_key is the license key string from Google Play Console
    
    # onProductPurchasedMethod expects two arguments: productId and purchaseInfo
    
    # onBillingErrorMethod expects two arguments: errorCode and error (use error.message to get the error message)
    
    # onPurchaseHistoryRestoredMethod does not expect any arguments
    
    # onBillingInitializedMethod does not expect any arguments
    

Useful Methods

  • Purchase a product

    purchase_product(product_id)
    
  • Consume a product(non-subscription)

    consume_purchase_async(product_id, success_listener=None, error_listener=None)
    
    # Both success_listener and error_listener doesn't take any arguments
    
  • Get details about a product (non-subscription)

    get_purchase_listing_async(product_id, success_listener=None, error_listener=None)
    
    # Both success_listener and error_listener expects a single argument.
    
    # success_listener gets a list with one element. Following details are available:
    if product_info.size() != 0:
        product_info = product_info[0]
        details= {
            "productId":        product_info.productId,
            "title":            product_info.title,
            "description":      product_info.description,
            "isSubscription":   product_info.isSubscription,
            "currency":         product_info.currency,
            "priceValue":       product_info.priceValue,
            "priceText":        product_info.priceText,
        }
    
    # error_listener gets a string with error message.
    
  • Subscribe to a product

    subscribe_product(product_id)
    
  • Get details about a subscription

    get_subscription_listing_async(product_id, success_listener=None, error_listener=None)
    
    # Both success_listener and error_listener expects a single argument.
    
    # Same as get_purchase_listing_async
    
  • Update information about users owned purchases/subscriptions. Use it to restore Purchases & Subscriptions.

    load_owned_purchases_async(success_listener=None, error_listener=None)
    
    # Both success_listener and error_listener doesn't take any arguments.
    
  • Check if service is initialized

    is_initialized()
    
  • Check if a product is already purchased(non-subscription)

    is_purchased(product_id)
    
  • Check if a product is already subscribed

    is_subscribed(product_id)
    
  • Before any usage it's good practice to check in-app billing services availability. In some older devices or chinese ones it may happen that Play Market is unavailable or is deprecated and doesn't support in-app billing.

    is_iab_service_available()
    
  • Please notice that calling BillingProcessor.isIabServiceAvailable() (only checks Play Market app installed or not) is not enough because there might be a case when it returns true but still payment won't succeed. Therefore, it's better to call bp.isConnected() after initializing BillingProcessor

    is_connected()
    
  • List owned products(non-subscription)

    list_owned_products()
    
    # Returns a list of product ids
    
  • List owned subscriptions

    list_owned_subscriptions()
    
    # Returns a list of product ids
    
  • Get very detailed info about a product(non-subscription)

    get_purchase_info(product_id)
    
    # Returns a `PurchaseInfo` object. Following details are available:
    purchase_info = bp.get_purchase_info(product_id)
    details = {
        "responseData": purchase_info.responseData,
        "signature": purchase_info.signature,
        "purchaseData":{
            "orderId": purchase_info.purchaseData.orderId,
            "productId": purchase_info.purchaseData.productId,
            "purchaseTime": purchase_info.purchaseData.purchaseTime,
            "purchaseToken": purchase_info.purchaseData.purchaseToken,
            "purchaseState": purchase_info.purchaseData.purchaseState,
            "autoRenewing": purchase_info.purchaseData.autoRenewing,
        }
    }
    
  • Get very detailed info about a subscription

    get_subscription_purchase_info(product_id)
    
    # Returns a `PurchaseInfo` object. Same as get_purchase_info
    

Example

See available demo application

More

To know more about what a method does, please see anjlab's android-inapp-billing-v3 docs for reference.

Release files for IABwrapper 1.0.0

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

Source distribution (sdist)

Source distribution for IABwrapper 1.0.0
File Size Uploaded
IABwrapper-1.0.0.tar.gz 4.8 kB Details

Built distribution (wheel)

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

Total release size: 10.0 kB

Release files / IABwrapper-1.0.0.tar.gz

Download URL IABwrapper-1.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4fa8798c709ef16e6d581d406a3437854bf4142b7567085856c9ebbc2655ebf3
BLAKE2b-256 checksum
How to use checksums
177afb651dda710bbb015bd394ff758b8d250a02e4bf324176c945869156cec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.6

Release files / IABwrapper-1.0.0-py3-none-any.whl

Download URL IABwrapper-1.0.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5ff2954dbefd9f2fb158246e5066a31fea04697f3dc68aabcc00b452d4d650a
BLAKE2b-256 checksum
How to use checksums
49a2a19bb0967cd8366b8486e820e7ba027d995b32974b8d9f605efd6fd68b36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

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