# python-killbill-client
### Installation
```bash
pip install python-killbill-client
```
### Guide
Frist step create client
```python
from killbill import KillBillClient
killbill = KillBillClient("admin", "password")
```
Table of contents :
- [Tenant](#tenant)
- [Create a tenant](#create-a-tenant)
- [Catalog](#catalog)
- [Create a simple catalog](#create-a-simple-catalog)
- [Create a catalog from file](#create-a-catalog-from-file)
- [Account](#account)
- [Create account](#create-account)
- [List accounts](#list-accounts)
- [Add payment method](#add-a-payment-method-to-the-account)
- [Subscription](#subscription)
- [Create subscription](#set-up-a-subscription-for-the-account)
- [Create suscription with add-ons](#create-suscription-with-add-ons)
- [Create multiple suscriptions with add-ons](#create-multiple-suscriptions-with-add-ons)
- [Invoices](#invoices)
- [Retrieve Invoices](#retrieve-account-invoices)
- [Overdue](#overdue)
- [Retrieve config](#retrieve-overdue-config)
- [Upload config](#upload-overdue-config)
## Tenant
#### Create a tenant
```python
killbill.tenant.create(api_key="bob", api_secret="lazar", created_by="demo")
```
And use `api_key` and `api_secret` to create header
```python
from killbill import Header
header = Header(api_key="bob", api_secret="lazar", created_by="demo")
```
## Catalog
#### Create a simple catalog
```python
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
```python
# first get text content
xml_file = open("SpyCarBasic.xml", "r", encoding="utf-8").read()
killbill.catalog.create(header=header, catalog_xml=xml_file)
```
## <a name="account"></a> Account
#### Create account
```python
# return account id
account_id = killbill.account.create(
header=header,
name="Customer 1",
first_name_length=10,
)
```
#### List accounts
```python
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.
```python
killbill.account.add_payment_method(
header=header,
account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a",
plugin_name="__EXTERNAL_PAYMENT__",
is_default=True,
)
```
## <a name="subscription"></a> Subscription
#### Set Up a Subscription for the Account
Note: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.
```python
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.
```python
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.
```python
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"],
],
)
```
## <a name="invoices"></a> Invoices
#### Retrieve account invoices
Note: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.
```python
invoices = killbill.account.invoices(
header=header, account_id="3d52ce98-104e-4cfe-af7d-732f9a264a9a"
)
print(json.dumps(invoices, indent=4))
```
## <a name="overdue"></a> Overdue
#### Retrieve overdue config
```python
overdue_config = killbill.overdue.retrieve(header=header)
print(overdue_config)
```
#### Upload overdue config
```python
# 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)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "python-killbill-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "bill, kill, killbill",
"author": null,
"author_email": "Raul Cobiellas <raulodev@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ce/19/488a79dc3b24410417dce241a530a36bd0ac6de19ad9d6d16c0cb1eb6df2/python_killbill_client-0.3.3.tar.gz",
"platform": null,
"description": "# python-killbill-client\n\n### Installation\n\n```bash\npip install python-killbill-client\n```\n\n### Guide\n\nFrist step create client\n\n```python\nfrom killbill import KillBillClient\n\nkillbill = KillBillClient(\"admin\", \"password\")\n```\n\nTable of contents :\n\n- [Tenant](#tenant)\n\n - [Create a tenant](#create-a-tenant)\n\n- [Catalog](#catalog)\n\n - [Create a simple catalog](#create-a-simple-catalog)\n - [Create a catalog from file](#create-a-catalog-from-file)\n\n- [Account](#account)\n\n - [Create account](#create-account)\n - [List accounts](#list-accounts)\n - [Add payment method](#add-a-payment-method-to-the-account)\n\n- [Subscription](#subscription)\n\n - [Create subscription](#set-up-a-subscription-for-the-account)\n - [Create suscription with add-ons](#create-suscription-with-add-ons)\n - [Create multiple suscriptions with add-ons](#create-multiple-suscriptions-with-add-ons)\n\n- [Invoices](#invoices)\n\n - [Retrieve Invoices](#retrieve-account-invoices)\n\n- [Overdue](#overdue)\n\n - [Retrieve config](#retrieve-overdue-config)\n - [Upload config](#upload-overdue-config)\n\n## Tenant\n\n#### Create a tenant\n\n```python\nkillbill.tenant.create(api_key=\"bob\", api_secret=\"lazar\", created_by=\"demo\")\n```\n\nAnd use `api_key` and `api_secret` to create header\n\n```python\nfrom killbill import Header\n\nheader = Header(api_key=\"bob\", api_secret=\"lazar\", created_by=\"demo\")\n```\n\n## Catalog\n\n#### Create a simple catalog\n\n```python\nfrom killbill.enums import ProductCategory, BillingPeriod, TrialTimeUnit\n\nkillbill.catalog.add_simple_plan(\n header=header, # pass header\n plan_id=\"standard-monthly\",\n product_name=\"Standard\",\n product_category=ProductCategory.BASE,\n currency=\"USD\",\n amount=24.95,\n billing_period=BillingPeriod.MONTHLY,\n trial_length=0,\n trial_time_unit=TrialTimeUnit.UNLIMITED,\n)\n```\n\n#### Create a catalog from file\n\n```python\n# first get text content\nxml_file = open(\"SpyCarBasic.xml\", \"r\", encoding=\"utf-8\").read()\n\nkillbill.catalog.create(header=header, catalog_xml=xml_file)\n```\n\n## <a name=\"account\"></a> Account\n\n#### Create account\n\n```python\n# return account id\naccount_id = killbill.account.create(\n header=header,\n name=\"Customer 1\",\n first_name_length=10,\n)\n```\n\n#### List accounts\n\n```python\nimport json\n\naccounts = killbill.account.list(header=header)\n\nprint(json.dumps(accounts, indent=4))\n```\n\n#### Add a payment method to the account\n\nNote: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.\n\n```python\nkillbill.account.add_payment_method(\n header=header,\n account_id=\"3d52ce98-104e-4cfe-af7d-732f9a264a9a\",\n plugin_name=\"__EXTERNAL_PAYMENT__\",\n is_default=True,\n)\n```\n\n## <a name=\"subscription\"></a> Subscription\n\n#### Set Up a Subscription for the Account\n\nNote: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.\n\n```python\nsubscription_id = killbill.subscription.create(\n header=header,\n account_id=\"3d52ce98-104e-4cfe-af7d-732f9a264a9a\",\n plan_name=\"standard-monthly\",\n)\n```\n\n#### Create suscription with add-ons\n\nNote: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.\n\n```python\nbundle_id = killbill.subscription.create_with_add_ons(\n header=header,\n account_id=\"3d52ce98-104e-4cfe-af7d-732f9a264a9a\",\n plan_name=\"standard-monthly\",\n add_ons_name=[\"standard-monthly-add-on\"],\n)\n```\n\n#### Create multiple suscriptions with add-ons\n\nNote: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.\n\n```python\nkillbill.subscription.create_multiple_with_add_ons(\n header,\n account_id=\"3d52ce98-104e-4cfe-af7d-732f9a264a9a\",\n bundles=[\n [\"standard-monthly\", \"standard-monthly-add-on\"],\n [\"sport-monthly\", \"sport-monthly-add-on-1\", \"sport-monthly-add-on-2\"],\n ],\n)\n```\n\n## <a name=\"invoices\"></a> Invoices\n\n#### Retrieve account invoices\n\nNote: Replace `3d52ce98-104e-4cfe-af7d-732f9a264a9a` below with the ID of your account.\n\n```python\ninvoices = killbill.account.invoices(\n header=header, account_id=\"3d52ce98-104e-4cfe-af7d-732f9a264a9a\"\n)\n\nprint(json.dumps(invoices, indent=4))\n```\n\n## <a name=\"overdue\"></a> Overdue\n\n#### Retrieve overdue config\n\n```python\noverdue_config = killbill.overdue.retrieve(header=header)\n\nprint(overdue_config)\n```\n\n#### Upload overdue config\n\n```python\n# first get text content\noverdue_config_xml = open(\"Overdue.xml\", \"r\", encoding=\"utf-8\").read()\n\nkillbill.overdue.upload(header=header, overdue_config_xml=overdue_config_xml)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "killbill client",
"version": "0.3.3",
"project_urls": {
"Homepage": "https://github.com/raulodev/python-killbill-client",
"Issues": "https://github.com/raulodev/python-killbill-client/issues"
},
"split_keywords": [
"bill",
" kill",
" killbill"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "af97174bbd514a6ef845fb8e0cc8cf8248bf69a4207675914a414a0e59573c66",
"md5": "3cf151c8a48e76e3afcaf5eea946b314",
"sha256": "242b5bc323f332710f3e134c54ff5e2dd710249ba4a256d7a30d0b1a67beb66b"
},
"downloads": -1,
"filename": "python_killbill_client-0.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3cf151c8a48e76e3afcaf5eea946b314",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 17126,
"upload_time": "2024-12-11T18:49:26",
"upload_time_iso_8601": "2024-12-11T18:49:26.076468Z",
"url": "https://files.pythonhosted.org/packages/af/97/174bbd514a6ef845fb8e0cc8cf8248bf69a4207675914a414a0e59573c66/python_killbill_client-0.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce19488a79dc3b24410417dce241a530a36bd0ac6de19ad9d6d16c0cb1eb6df2",
"md5": "7fcdfa61f13b36f263eb5ec3ae1ee42b",
"sha256": "c8e4f91239d8c4c399e4f219c81504067fbd2178497acc440609954396044136"
},
"downloads": -1,
"filename": "python_killbill_client-0.3.3.tar.gz",
"has_sig": false,
"md5_digest": "7fcdfa61f13b36f263eb5ec3ae1ee42b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11139,
"upload_time": "2024-12-11T18:49:27",
"upload_time_iso_8601": "2024-12-11T18:49:27.018010Z",
"url": "https://files.pythonhosted.org/packages/ce/19/488a79dc3b24410417dce241a530a36bd0ac6de19ad9d6d16c0cb1eb6df2/python_killbill_client-0.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 18:49:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "raulodev",
"github_project": "python-killbill-client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
}
],
"lcname": "python-killbill-client"
}