Skip to main content

killbill xml builder

Project description

killbill-xml-builder

Installation

pip install killbill-xml-builder

Usage

Import the required classes and create the catalog

from killbill_xml_builder.enums import (
    PhaseType,
    TimeUnit,
    BillingPeriod,
    BillingMode,
    ProductCategory,
    BillingPolicy,
    EntitlementPolicy,
)

from killbill_xml_builder import (
    Currencies,
    Product,
    Phase,
    Price,
    Duration,
    FixedPrice,
    RecurringPrice,
    Plan,
    Catalog,
    Rules,
    ChangePolicyCase,
    CancelPolicyCase,
)

Create currencies

currencies = Currencies(["USD", "GBP"])

Create add-on

oil_slick = Product("OilSlick", ProductCategory.ADD_ON)

remote_control = Product("RemoteControl", ProductCategory.ADD_ON)

Create products

standard = Product("Standard")

sports = Product("Sports", available=[oil_slick, remote_control])

super = Product("Super", included=[oil_slick], available=[remote_control])

Create products phases

Phase trial

phase_trial = Phase(
    type=PhaseType.TRIAL,
    duration=Duration(length=30, time_unit=TimeUnit.DAYS),
    fixed_price=FixedPrice(),
)

Phase standard evergreen

standard_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 75.00), Price("USD", 100.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)

Phase sports evergreen

sports_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 375.00), Price("USD", 500.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)

Phase super evergreen

super_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 750.00), Price("USD", 1000.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)

Phase ADD-ON

add_on_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 15.00), Price("USD", 20.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)

Create rules (change and cancel rules are required)

default_change_policy = ChangePolicyCase(policy=BillingPolicy.END_OF_TERM)

default_cancel_policy = CancelPolicyCase(policy=EntitlementPolicy.END_OF_TERM)

rules = Rules(
    change_policy_cases=[default_change_policy],
    cancel_policy_cases=[default_cancel_policy],
)

Create plans

oil_slick_monthly = Plan(
    name="oil-slick-monthly",
    product=oil_slick,
    initial_phases=[],
    final_phase=add_on_evergreen,
)

remote_control_monthly = Plan(
    name="remote-control-monthly",
    product=remote_control,
    initial_phases=[],
    final_phase=add_on_evergreen,
)


standard_monthly = Plan(
    name="standard-monthly",
    product=standard,
    initial_phases=[phase_trial],
    final_phase=standard_evergreen,
)


sports_monthly = Plan(
    name="sports-monthly",
    product=sports,
    initial_phases=[phase_trial],
    final_phase=sports_evergreen,
)


super_monthly = Plan(
    name="super-monthly",
    product=super,
    initial_phases=[phase_trial],
    final_phase=super_evergreen,
)

Create catalog

catalog = Catalog(
    name="SpyCarBasic",
    billing_mode=BillingMode.IN_ADVANCE,
    currencies=currencies,
    products=[standard, sports, super, oil_slick, remote_control],
    rules=rules,
    plans=[
        standard_monthly,
        sports_monthly,
        super_monthly,
        oil_slick_monthly,
        remote_control_monthly,
    ],
)

Get xml content

print(catalog)

Save catalog as file

catalog.write()

TODO

Plans

  • Usage

Rules

  • billingAlignment
  • createAlignment
  • changeAlignment
  • priceList

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

killbill_xml_builder-0.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

killbill_xml_builder-0.0.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file killbill_xml_builder-0.0.3.tar.gz.

File metadata

  • Download URL: killbill_xml_builder-0.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for killbill_xml_builder-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d1369f63317a96d037137448eb1e3102f0bf422a2803b3e7ed8c429adbf6535b
MD5 8a58f97a8171f2fddf92eab30d24f09d
BLAKE2b-256 d584f01fad8116252faf485d59b1251de220bcf0cb691c7273426924c05bce0b

See more details on using hashes here.

File details

Details for the file killbill_xml_builder-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for killbill_xml_builder-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b10087566e4443165c0cbe907616ae62b79b987f9e4a3d3086ce0996a58c78cf
MD5 757361973d06d21ffab5c5d2b726976b
BLAKE2b-256 d64c363f96b2b711760dae135508ed9cc89da22be9d8f247a0075b6b215fda05

See more details on using hashes here.

Supported by

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