Skip to main content

killbill client

Project description

python-killbill-client

Installation

pip install python-killbill-client

Guide

Frist step create client

from killbill import KillBillClient

killbill = KillBillClient("admin", "password")

Table of contents :

Tenant

Create a tenant

killbill.tenant.create(api_key="bob", api_secret="lazar", created_by="demo")

And use api_key and api_secret to create header

from killbill import Header

header = Header(api_key="bob", api_secret="lazar", created_by="demo")

Catalog

Create a simple catalog

from killbill.enums import ProductCategory, BillingPeriod, TrialTimeUnit

killbill.catalog.add_simple_plan(
    header=header, # pass header
    plan_id="standard-monthly",
    product_name="Standard",
    product_category=ProductCategory.BASE,
    currency="USD",
    amount=24.95,
    billing_period=BillingPeriod.MONTHLY,
    trial_length=0,
    trial_time_unit=TrialTimeUnit.UNLIMITED,
)

Create a catalog from file

# first get text content
xml_file = open("SpyCarBasic.xml", "r", encoding="utf-8").read()

killbill.catalog.create(header=header, catalog_xml=xml_file)

Account

Create account

# return account id
account_id = killbill.account.create(
    header=header,
    name="Customer 1",
    first_name_length=10,
)

List accounts

import json

accounts = killbill.account.list(header=header)

print(json.dumps(accounts, indent=4))

Add a payment method to the account

Note: Replace 3d52ce98-104e-4cfe-af7d-732f9a264a9a below with the ID of your account.

killbill.account.add_payment_method(
    header=header,
    account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a",
    plugin_name="__EXTERNAL_PAYMENT__",
    is_default=True,
)

Subscription

Set Up a Subscription for the Account

Note: Replace 3d52ce98-104e-4cfe-af7d-732f9a264a9a below with the ID of your account.

subscription_id = killbill.subscription.create(
    header=header,
    account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a",
    plan_name="standard-monthly",
)

Create suscription with add-ons

Note: Replace 3d52ce98-104e-4cfe-af7d-732f9a264a9a below with the ID of your account.

bundle_id = killbill.subscription.create_with_add_ons(
    header=header,
    account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a",
    plan_name="standard-monthly",
    add_ons_name=["standard-monthly-add-on"],
)

Create multiple suscriptions with add-ons

Note: Replace 3d52ce98-104e-4cfe-af7d-732f9a264a9a below with the ID of your account.

killbill.subscription.create_multiple_with_add_ons(
    header,
    account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a",
    bundles=[
        ["standard-monthly", "standard-monthly-add-on"],
        ["sport-monthly", "sport-monthly-add-on-1", "sport-monthly-add-on-2"],
    ],
)

Invoices

Retrieve account invoices

Note: Replace 3d52ce98-104e-4cfe-af7d-732f9a264a9a below with the ID of your account.

invoices = killbill.account.invoices(
    header=header, account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a"
)

print(json.dumps(invoices, indent=4))

Overdue

Retrieve overdue config

overdue_config = killbill.overdue.retrieve(header=header)

print(overdue_config)

Upload overdue config

# first get text content
overdue_config_xml = open("Overdue.xml", "r", encoding="utf-8").read()

killbill.overdue.upload(header=header, overdue_config_xml=overdue_config_xml)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_killbill_client-0.3.8.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_killbill_client-0.3.8-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file python_killbill_client-0.3.8.tar.gz.

File metadata

  • Download URL: python_killbill_client-0.3.8.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for python_killbill_client-0.3.8.tar.gz
Algorithm Hash digest
SHA256 cba365dc98dc9180bed4c75ad32b671f754ce1569c96f71956823c86a988a190
MD5 d64f00350f1daa32a00adeb3b3d123e9
BLAKE2b-256 be0a680ee961c1f06e9fdcba10e0f7962c97ac4b74efd50e7839b379b3fedeae

See more details on using hashes here.

File details

Details for the file python_killbill_client-0.3.8-py3-none-any.whl.

File metadata

File hashes

Hashes for python_killbill_client-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e7889e43d96d613f4eee361d71bd4605d4d68a61dd3a317ea448e704bd0dc7d1
MD5 18e1547d94647b2893b7dd154c53de21
BLAKE2b-256 c9476da013417db19da5af9de2542953ef3d5b0bec8ce5345796c8d8d7e221b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page