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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_killbill_client-0.2.0.tar.gz.
File metadata
- Download URL: python_killbill_client-0.2.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
461e0f34e6d359369d4ace5acc4d6790788bfa359be7836d4e3960984d0fb93f
|
|
| MD5 |
25ccea6a8d054537008686928e7cdd6a
|
|
| BLAKE2b-256 |
2a7d5616e263ec3254e1914f5e05f5dbcfe22b4f0d9811e86e6d22f9152a7813
|
File details
Details for the file python_killbill_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: python_killbill_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b12c5e627aec4c9157c9160b26d890e1f0ef243f0be29aa6af28ddbb5803c2c
|
|
| MD5 |
330eb61e5a71e448886e35af1ce17939
|
|
| BLAKE2b-256 |
5bbd0e1f649eff5cb0419489678f3849e4a2c557735dd34f94600d7f9e33108c
|