killbill

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTO_PAY_OFF               = "00000000-0000-0000-0000-000000000001"
	AUTO_INVOICING_OFF         = "00000000-0000-0000-0000-000000000002"
	OVERDUE_ENFORCEMENT_OFF    = "00000000-0000-0000-0000-000000000003"
	WRITTEN_OFF                = "00000000-0000-0000-0000-000000000004"
	MANUAL_PAY                 = "00000000-0000-0000-0000-000000000005"
	TEST                       = "00000000-0000-0000-0000-000000000006"
	PARTNER                    = "00000000-0000-0000-0000-000000000007"
	AUTO_INVOICING_DRAFT       = "00000000-0000-0000-0000-000000000008"
	AUTO_INVOICING_REUSE_DRAFT = "00000000-0000-0000-0000-000000000009"
)

Kill Bill Control Tag

View Source
const (
	SUB_CREATE_BP_EXISTS           = 1015
	ACCOUNT_ALREADY_EXISTS         = 3000
	ACCOUNT_DOES_NOT_EXIST_FOR_KEY = 3003
)

Kill Bill Error Codes

View Source
const Comment = ""
View Source
const CreatedBy = "go-client"
View Source
const DebugHttpRequests = false
View Source
const KB_PROFILING_RESP = "X-Killbill-Profiling-Resp"

Variables

View Source
var NullDate = strfmt.Date(time.Time{})

Functions

func CreateAuthInfo

func CreateAuthInfo(apiKey, apiSecret, user, pwd string) runtime.ClientAuthInfoWriter

func GetProfilingRes

func GetProfilingRes(pctx context.Context) string

Caller retrieves the profiling result through this method

func IsCriticalError

func IsCriticalError(err error, kbCodeIgnore int, ignrDup bool, logger Logger) error

Because of Kill Bill not always correctly returning the right error code on duplicate entry we need to add some dirty band-aid and specify 'ignrDup', 'logger' args to this function See https://github.com/killbill/killbill/issues/1344

func NewClientTransport

func NewClientTransport(url string) *transport.Runtime

Technically this could be shared across clients if needs to be

func NewKillbillClient

func NewKillbillClient(trp *transport.Runtime, apiKey, apiSecret, user, pwd string) *kbclient.KillBill

func WithProfilingInfo

func WithProfilingInfo(parent context.Context, profInfo string) context.Context

Caller specifies profiling info (request) through a new context

Types

type Config

type Config struct {
	Url        string
	Username   string
	Password   string
	ApiKey     string
	ApiSecret  string
	TimeoutSec int64
}

func (*Config) GetApiKey

func (k *Config) GetApiKey() string

func (*Config) GetApiSecret

func (k *Config) GetApiSecret() string

func (*Config) GetPassword

func (k *Config) GetPassword() string

func (*Config) GetTimeout

func (k *Config) GetTimeout() time.Duration

func (*Config) GetUrl

func (k *Config) GetUrl() string

func (*Config) GetUsername

func (k *Config) GetUsername() string

type KillbillConfig

type KillbillConfig interface {
	GetUrl() string
	GetUsername() string
	GetPassword() string
	GetApiKey() string
	GetApiSecret() string
	GetTimeout() time.Duration
}

type KillbillPolicy

type KillbillPolicy string
const (
	NONE KillbillPolicy = ""
	IMM  KillbillPolicy = "IMMEDIATE"
	EOT  KillbillPolicy = "END_OF_TERM"
	SOT  KillbillPolicy = "START_OF_TERM"
)

type Logger

type Logger interface {
	LogError(err error, format string, a ...interface{})
}

type PlanDescr

type PlanDescr struct {
	ExtKey string
	PlanId string
	Bcd    int
}

type ProfCtxValue

type ProfCtxValue struct {
	// contains filtered or unexported fields
}

type RawClient

type RawClient struct {
	// Low level transport
	Trp *transport.Runtime
	// Cross tenant operations (e.g Create tenant)
	CrossTenantClient *kbclient.KillBill
	// Per-tenant client
	ApiKey       string
	ApiSecret    string
	TenantClient *kbclient.KillBill
	// Default timeout
	Timeout time.Duration
}

func NewKBClient

func NewKBClient(conf KillbillConfig) *RawClient

func (*RawClient) AddAccountCustomFields

func (cli *RawClient) AddAccountCustomFields(ctx context.Context, accountId strfmt.UUID, fields map[string]string) error

func (*RawClient) AddAccountTags

func (cli *RawClient) AddAccountTags(ctx context.Context, accountId strfmt.UUID, tags ...string) error

func (*RawClient) AddSubscriptionCustomFields

func (cli *RawClient) AddSubscriptionCustomFields(ctx context.Context, subscriptionId strfmt.UUID, fields map[string]string) error

func (*RawClient) CancelSubscription

func (cli *RawClient) CancelSubscription(ctx context.Context, subscriptionId strfmt.UUID, date *strfmt.Date) error

func (*RawClient) ChangePlan

func (cli *RawClient) ChangePlan(ctx context.Context, subscriptionId strfmt.UUID, planName, billingPeriod, priceList string, requestedDate *strfmt.Date) error

func (*RawClient) CommitInvoice

func (cli *RawClient) CommitInvoice(ctx context.Context, invoiceID strfmt.UUID) (*kbmodel.Invoice, error)

CommitInvoice commits an invoice. If the current invoice status is different from DRAFT, it returns an error.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) CreateAccount

func (cli *RawClient) CreateAccount(ctx context.Context, extKey string, currency string, locale string, bcd int32) (strfmt.UUID, error)

func (*RawClient) CreateAccountFromBody

func (cli *RawClient) CreateAccountFromBody(ctx context.Context, body *kbmodel.Account) (strfmt.UUID, error)

func (*RawClient) CreateSubscription

func (cli *RawClient) CreateSubscription(ctx context.Context, accountId strfmt.UUID, extKey string, entitlementDate *strfmt.Date, billingDate *strfmt.Date, planId string, bcd int, follow bool) (strfmt.UUID, error)

func (*RawClient) CreateSubscriptions

func (cli *RawClient) CreateSubscriptions(pctx context.Context, accountId strfmt.UUID, date *strfmt.Date, planDescs []PlanDescr, follow bool) ([]*kbmodel.Bundle, error)

func (*RawClient) CreateTenant

func (cli *RawClient) CreateTenant(ctx context.Context, apiKey string, apiSecret string, extKey string) (*strfmt.UUID, error)

func (*RawClient) DeleteAccountTags

func (cli *RawClient) DeleteAccountTags(ctx context.Context, accountId strfmt.UUID, tags ...string) error

func (*RawClient) GetAccount

func (cli *RawClient) GetAccount(ctx context.Context, accountId strfmt.UUID, withBalance bool) (*kbmodel.Account, error)

func (*RawClient) GetAccountByKey

func (cli *RawClient) GetAccountByKey(ctx context.Context, externalKey string) (*kbmodel.Account, error)

func (*RawClient) GetAccountTags

func (cli *RawClient) GetAccountTags(ctx context.Context, accountId strfmt.UUID) ([]*kbmodel.Tag, error)

func (*RawClient) GetAllInvoices

func (cli *RawClient) GetAllInvoices(ctx context.Context, accountID strfmt.UUID) ([]*kbmodel.Invoice, error)

GetAllInvoices fetchs all invoice for the given account.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) GetBundle

func (cli *RawClient) GetBundle(ctx context.Context, bundleId strfmt.UUID) (*kbmodel.Bundle, error)

func (*RawClient) GetBundleByKey

func (cli *RawClient) GetBundleByKey(ctx context.Context, extKey string) (*kbmodel.Bundle, error)

func (*RawClient) GetInvoice

func (cli *RawClient) GetInvoice(ctx context.Context, invoiceID strfmt.UUID) (*kbmodel.Invoice, error)

GetInvoice fetch an invoice using the given invoiceID.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) GetInvoicesBetweenDates

func (cli *RawClient) GetInvoicesBetweenDates(ctx context.Context, accountID strfmt.UUID, from *strfmt.Date, to *strfmt.Date) ([]*kbmodel.Invoice, error)

GetInvoicesBetweenDates returns all invoices belonging to an account, whose invoice date is in between the given arguments.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) GetMonthlyInvoice

func (cli *RawClient) GetMonthlyInvoice(ctx context.Context, accountID strfmt.UUID, targetDt strfmt.Date) (*kbmodel.Invoice, error)

GetMonthlyInvoice returns the invoice matching the given target

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) GetSubscription

func (cli *RawClient) GetSubscription(ctx context.Context, subId strfmt.UUID) (*kbmodel.Subscription, error)

func (*RawClient) GetSubscriptionByKey

func (cli *RawClient) GetSubscriptionByKey(ctx context.Context, extKey string) (*kbmodel.Subscription, error)

func (*RawClient) GetTenant

func (cli *RawClient) GetTenant(ctx context.Context, apiKey string) (*strfmt.UUID, error)

func (*RawClient) InvalidateTenantCache

func (cli *RawClient) InvalidateTenantCache(ctx context.Context) error

func (*RawClient) IsInvoiceWrittenOff

func (cli *RawClient) IsInvoiceWrittenOff(ctx context.Context, invoiceID strfmt.UUID) (bool, string, error)

IsInvoiceWrittenOff checks if the given invoice is written-off, returning true or false

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) PauseSubscription

func (cli *RawClient) PauseSubscription(ctx context.Context, subscriptionId strfmt.UUID, service string, state string, date *strfmt.Date) error

func (*RawClient) PayInvoice

func (cli *RawClient) PayInvoice(ctx context.Context, invoiceID strfmt.UUID, accountID strfmt.UUID, amount float64, externalPayment bool) error

PayInvoice adds a full-amount payment to the given invoice.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) ResumeSubscription

func (cli *RawClient) ResumeSubscription(ctx context.Context, subscriptionId strfmt.UUID, service string, state string, date *strfmt.Date) error

func (*RawClient) TransferBundle

func (cli *RawClient) TransferBundle(ctx context.Context, bundleId strfmt.UUID, destAccountId strfmt.UUID, requestedDate *strfmt.Date, subExtkeys map[string]string, follow bool) (strfmt.UUID, error)

func (*RawClient) TriggerDryRunCancelSubscription

func (cli *RawClient) TriggerDryRunCancelSubscription(ctx context.Context, accountId strfmt.UUID, bundleId strfmt.UUID, subscriptionId strfmt.UUID, effDt strfmt.Date, targetDt strfmt.Date) (*kbmodel.Invoice, error)

func (*RawClient) TriggerDryRunChangePlan

func (cli *RawClient) TriggerDryRunChangePlan(ctx context.Context, accountId strfmt.UUID, bundleId strfmt.UUID, subscriptionId strfmt.UUID, product string, priceList string, effDt strfmt.Date, targetDt strfmt.Date) (*kbmodel.Invoice, error)

func (*RawClient) TriggerDryRunCreateSubscription

func (cli *RawClient) TriggerDryRunCreateSubscription(ctx context.Context, accountId strfmt.UUID, product string, priceList string, effDt strfmt.Date, targetDt strfmt.Date) (*kbmodel.Invoice, error)

func (*RawClient) TriggerTargetInvoice

func (cli *RawClient) TriggerTargetInvoice(ctx context.Context, accountID strfmt.UUID, targetDate strfmt.Date) (*kbmodel.Invoice, error)

TriggerTargetInvoice creates a DRAFT invoice for the given account, using the given target date.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) UpdateSubscriptionBCD

func (cli *RawClient) UpdateSubscriptionBCD(ctx context.Context, subscriptionId strfmt.UUID, bcd int, requestedDate *strfmt.Date) error

func (*RawClient) UploadCatalogXML

func (cli *RawClient) UploadCatalogXML(ctx context.Context, path string) error

func (*RawClient) VoidInvoice

func (cli *RawClient) VoidInvoice(ctx context.Context, invoiceID strfmt.UUID) (*kbmodel.Invoice, error)

VoidInvoice voids an invoice. If the invoice was already paid, voiding it fails.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

func (*RawClient) WriteOffInvoice

func (cli *RawClient) WriteOffInvoice(ctx context.Context, invoiceID strfmt.UUID, reason string) error

WriteOffInvoice writes-off the given invoice.

In case of connection errors, the underlying error is returned. For other cases (HTTP status >= 400), a kbcommon.KillbillError is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL