advancedbilling

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 10 Imported by: 1

README

Getting Started with Maxio Advanced Billing

Introduction

Maxio Advanced Billing (formerly Chargify) provides an HTTP-based API that conforms to the principles of REST. One of the many reasons to use Advanced Billing is the immense feature set and surrounding community client libraries. The Maxio API returns JSON responses as the primary and recommended format, but XML is also provided as a backwards compatible option for Merchants who require it.

Steps to make your first Maxio Advanced Billing API call
  1. Sign-up or log-in to your test site account.
  2. Setup and configure authentication credentials.
  3. Submit your API request and try it out.
  4. Verify results through response.
  5. Test our integrations.

We strongly suggest exploring the developer portal, our integrations and the API guide, as well as the entire set of application-based documentation to aid in your discovery of the product.

Example

The following example uses the curl command-line tool to execute API requests.

Request

curl -u <api_key>:x -H Accept:application/json -H Content-Type:application/json https://acme.chargify.com/subscriptions.json

Requirements

The SDK requires Go version 1.18 or above.

Installation

The following section explains how to use the advancedbilling library in a new project.

1. Install the Package

To use the package in your application, you can install the package from pkg.go.dev using the following command:

$ go get github.com/maxio-com/ab-golang-sdk@v0.2.1

You can also view the package at: https://pkg.go.dev/github.com/maxio-com/ab-golang-sdk@v0.2.1

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
subdomain string The subdomain for your Chargify site.
Default: "subdomain"
domain string The Chargify server domain.
Default: "chargify.com"
environment Environment The API environment.
Default: Environment.PRODUCTION
httpConfiguration HttpConfiguration Configurable http client options like timeout and retries.
basicAuthCredentials BasicAuthCredentials The Credentials Setter for Basic Authentication

The API client can be initialized as follows:

client := advancedbilling.NewClient(
    advancedbilling.CreateConfiguration(
        advancedbilling.WithHttpConfiguration(
            advancedbilling.CreateHttpConfiguration(
                advancedbilling.WithTimeout(30),
            ),
        ),
        advancedbilling.WithEnvironment(advancedbilling.PRODUCTION),
        advancedbilling.WithBasicAuthCredentials(
            advancedbilling.NewBasicAuthCredentials(
                "BasicAuthUserName",
                "BasicAuthPassword",
            ),
        ),
        advancedbilling.WithSubdomain("subdomain"),
        advancedbilling.WithDomain("chargify.com"),
    ),
)

Environments

The SDK can be configured to use a different environment for making API calls. Available environments are:

Fields
Name Description
production Default Production server
environment2 Production server

Authorization

This API uses the following authentication schemes.

List of APIs

Classes Documentation

Documentation

Overview

Package advancedbilling

This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).

Index

Constants

This section is empty.

Variables

View Source
var NewAndAuth = https.NewAndAuth

NewAndAuth creates a new AndAuth.

View Source
var NewAuth = https.NewAuth

NewAuth creates a new Auth.

View Source
var NewHttpConfiguration = https.NewHttpConfiguration

NewHttpConfiguration creates a new HttpConfiguration.

View Source
var NewOrAuth = https.NewOrAuth

NewOrAuth creates a new OrAuth.

View Source
var NewRetryConfiguration = https.NewRetryConfiguration

NewRetryConfiguration creates a new RetryConfiguration.

View Source
var WithBackoffFactor = https.WithBackoffFactor

WithBackoffFactor sets the BackoffFactor.

View Source
var WithHttpMethodsToRetry = https.WithHttpMethodsToRetry

WithHttpMethodsToRetry sets the HttpMethodsToRetry.

View Source
var WithHttpStatusCodesToRetry = https.WithHttpStatusCodesToRetry

WithHttpStatusCodesToRetry sets the HttpStatusCodesToRetry.

View Source
var WithMaxRetryAttempts = https.WithMaxRetryAttempts

WithMaxRetryAttempts sets the MaxRetryAttempts.

View Source
var WithMaximumRetryWaitTime = https.WithMaximumRetryWaitTime

WithMaximumRetryWaitTime sets the MaximumRetryWaitTime.

View Source
var WithRetryConfiguration = https.WithRetryConfiguration

WithRetryConfiguration sets the RetryConfiguration.

View Source
var WithRetryInterval = https.WithRetryInterval

WithRetryInterval sets the RetryInterval.

View Source
var WithRetryOnTimeout = https.WithRetryOnTimeout

WithRetryOnTimeout sets the RetryOnTimeout.

View Source
var WithTimeout = https.WithTimeout

WithTimeout sets the Timeout.

View Source
var WithTransport = https.WithTransport

WithTransport sets the Transport.

Functions

func NewBaseController

func NewBaseController(cb callBuilderFactory) *baseController

NewBaseController creates a new instance of baseController. It takes a callBuilderFactory as a parameter and returns a pointer to the baseController.

Types

type APIExportsController

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

APIExportsController represents a controller struct.

func NewAPIExportsController

func NewAPIExportsController(baseController baseController) *APIExportsController

NewAPIExportsController creates a new instance of APIExportsController. It takes a baseController as a parameter and returns a pointer to the APIExportsController.

func (*APIExportsController) ExportInvoices

ExportInvoices takes context as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API creates an invoices export and returns a batchjob object.

func (*APIExportsController) ExportProformaInvoices

func (a *APIExportsController) ExportProformaInvoices(ctx context.Context) (
	models.ApiResponse[models.BatchJobResponse],
	error)

ExportProformaInvoices takes context as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API creates a proforma invoices export and returns a batchjob object. It is only available for Relationship Invoicing architecture.

func (*APIExportsController) ExportSubscriptions

ExportSubscriptions takes context as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API creates a subscriptions export and returns a batchjob object.

func (*APIExportsController) ListExportedInvoices

ListExportedInvoices takes context, batchId, perPage, page as parameters and returns an models.ApiResponse with []models.Invoice data and an error if there was an issue with the request or response. This API returns an array of exported invoices for a provided `batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://{subdomain}.chargify.com/api_exports/invoices/123/rows?per_page=10000&page=1`.

func (*APIExportsController) ListExportedProformaInvoices

ListExportedProformaInvoices takes context, batchId, perPage, page as parameters and returns an models.ApiResponse with []models.ProformaInvoice data and an error if there was an issue with the request or response. This API returns an array of exported proforma invoices for a provided `batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://{subdomain}.chargify.com/api_exports/proforma_invoices/123/rows?per_page=10000&page=1`.

func (*APIExportsController) ListExportedSubscriptions

ListExportedSubscriptions takes context, batchId, perPage, page as parameters and returns an models.ApiResponse with []models.Subscription data and an error if there was an issue with the request or response. This API returns an array of exported subscriptions for a provided `batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://{subdomain}.chargify.com/api_exports/subscriptions/123/rows?per_page=200&page=1`.

func (*APIExportsController) ReadInvoicesExport

func (a *APIExportsController) ReadInvoicesExport(
	ctx context.Context,
	batchId string) (
	models.ApiResponse[models.BatchJobResponse],
	error)

ReadInvoicesExport takes context, batchId as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API returns a batchjob object for invoices export.

func (*APIExportsController) ReadProformaInvoicesExport

func (a *APIExportsController) ReadProformaInvoicesExport(
	ctx context.Context,
	batchId string) (
	models.ApiResponse[models.BatchJobResponse],
	error)

ReadProformaInvoicesExport takes context, batchId as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API returns a batchjob object for proforma invoices export.

func (*APIExportsController) ReadSubscriptionsExport

func (a *APIExportsController) ReadSubscriptionsExport(
	ctx context.Context,
	batchId string) (
	models.ApiResponse[models.BatchJobResponse],
	error)

ReadSubscriptionsExport takes context, batchId as parameters and returns an models.ApiResponse with models.BatchJobResponse data and an error if there was an issue with the request or response. This API returns a batchjob object for subscriptions export.

type AdvanceInvoiceController

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

AdvanceInvoiceController represents a controller struct.

func NewAdvanceInvoiceController

func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceController

NewAdvanceInvoiceController creates a new instance of AdvanceInvoiceController. It takes a baseController as a parameter and returns a pointer to the AdvanceInvoiceController.

func (*AdvanceInvoiceController) IssueAdvanceInvoice

func (a *AdvanceInvoiceController) IssueAdvanceInvoice(
	ctx context.Context,
	subscriptionId int,
	body *models.IssueAdvanceInvoiceRequest) (
	models.ApiResponse[models.Invoice],
	error)

IssueAdvanceInvoice takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404811062541-Issue-Invoice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error. That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated. We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it.

func (*AdvanceInvoiceController) ReadAdvanceInvoice

func (a *AdvanceInvoiceController) ReadAdvanceInvoice(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.Invoice],
	error)

ReadAdvanceInvoice takes context, subscriptionId as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. Once an advance invoice has been generated for a subscription's upcoming renewal, it can be viewed through this endpoint. There can only be one advance invoice per subscription per billing cycle.

func (*AdvanceInvoiceController) VoidAdvanceInvoice

func (a *AdvanceInvoiceController) VoidAdvanceInvoice(
	ctx context.Context,
	subscriptionId int,
	body *models.VoidInvoiceRequest) (
	models.ApiResponse[models.Invoice],
	error)

VoidAdvanceInvoice takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired. A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs]($m/Invoice).

type BasicAuthCredentials added in v0.1.0

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

BasicAuthCredentials represents the credentials required for `BasicAuth` authentication.

func NewBasicAuthCredentials added in v0.1.0

func NewBasicAuthCredentials(
	username string,
	password string) BasicAuthCredentials

NewBasicAuthCredentials creates a new instance of BasicAuthCredentials with provided parameters.

func (BasicAuthCredentials) Authenticator added in v0.1.0

func (b BasicAuthCredentials) Authenticator() https.HttpInterceptor

Authenticator function returns HttpInterceptor function that provides authentication for API calls.

func (BasicAuthCredentials) Password added in v0.1.0

func (b BasicAuthCredentials) Password() string

Password returns the password associated with the BasicAuthCredentials.

func (BasicAuthCredentials) Username added in v0.1.0

func (b BasicAuthCredentials) Username() string

Username returns the username associated with the BasicAuthCredentials.

func (BasicAuthCredentials) Validate added in v0.1.0

func (b BasicAuthCredentials) Validate() error

Validate function returns validation error associated with the BasicAuthCredentials.

func (BasicAuthCredentials) WithPassword added in v0.1.0

func (b BasicAuthCredentials) WithPassword(password string) BasicAuthCredentials

WithPassword sets password in BasicAuthCredentials.

func (BasicAuthCredentials) WithUsername added in v0.1.0

func (b BasicAuthCredentials) WithUsername(username string) BasicAuthCredentials

WithUsername sets username in BasicAuthCredentials.

type BillingPortalController

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

BillingPortalController represents a controller struct.

func NewBillingPortalController

func NewBillingPortalController(baseController baseController) *BillingPortalController

NewBillingPortalController creates a new instance of BillingPortalController. It takes a baseController as a parameter and returns a pointer to the BillingPortalController.

func (*BillingPortalController) EnableBillingPortalForCustomer

func (b *BillingPortalController) EnableBillingPortalForCustomer(
	ctx context.Context,
	customerId int,
	autoInvite *models.AutoInvite) (
	models.ApiResponse[models.CustomerResponse],
	error)

EnableBillingPortalForCustomer takes context, customerId, autoInvite as parameters and returns an models.ApiResponse with models.CustomerResponse data and an error if there was an issue with the request or response. ## Billing Portal Documentation Full documentation on how the Billing Portal operates within the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407648972443). This documentation is focused on how the to configure the Billing Portal Settings, as well as Subscriber Interaction and Merchant Management of the Billing Portal. You can use this endpoint to enable Billing Portal access for a Customer, with the option of sending the Customer an Invitation email at the same time. ## Billing Portal Security If your customer has been invited to the Billing Portal, then they will receive a link to manage their subscription (the “Management URL”) automatically at the bottom of their statements, invoices, and receipts. **This link changes periodically for security and is only valid for 65 days.** If you need to provide your customer their Management URL through other means, you can retrieve it via the API. Because the URL is cryptographically signed with a timestamp, it is not possible for merchants to generate the URL without requesting it from Chargify. In order to prevent abuse & overuse, we ask that you request a new URL only when absolutely necessary. Management URLs are good for 65 days, so you should re-use a previously generated one as much as possible. If you use the URL frequently (such as to display on your website), please **do not** make an API request to Chargify every time.

func (b *BillingPortalController) ReadBillingPortalLink(
	ctx context.Context,
	customerId int) (
	models.ApiResponse[models.PortalManagementLink],
	error)

ReadBillingPortalLink takes context, customerId as parameters and returns an models.ApiResponse with models.PortalManagementLink data and an error if there was an issue with the request or response. This method will provide to the API user the exact URL required for a subscriber to access the Billing Portal. ## Rules for Management Link API + When retrieving a management URL, multiple requests for the same customer in a short period will return the **same** URL + We will not generate a new URL for 15 days + You must cache and remember this URL if you are going to need it again within 15 days + Only request a new URL after the `new_link_available_at` date + You are limited to 15 requests for the same URL. If you make more than 15 requests before `new_link_available_at`, you will be blocked from further Management URL requests (with a response code `429`)

func (*BillingPortalController) ResendBillingPortalInvitation

func (b *BillingPortalController) ResendBillingPortalInvitation(
	ctx context.Context,
	customerId int) (
	models.ApiResponse[models.ResentInvitation],
	error)

ResendBillingPortalInvitation takes context, customerId as parameters and returns an models.ApiResponse with models.ResentInvitation data and an error if there was an issue with the request or response. You can resend a customer's Billing Portal invitation. If you attempt to resend an invitation 5 times within 30 minutes, you will receive a `422` response with `error` message in the body. If you attempt to resend an invitation when the Billing Portal is already disabled for a Customer, you will receive a `422` error response. If you attempt to resend an invitation when the Billing Portal is already disabled for a Customer, you will receive a `422` error response. If you attempt to resend an invitation when the Customer does not exist a Customer, you will receive a `404` error response. ## Limitations This endpoint will only return a JSON response.

func (*BillingPortalController) RevokeBillingPortalAccess

func (b *BillingPortalController) RevokeBillingPortalAccess(
	ctx context.Context,
	customerId int) (
	models.ApiResponse[models.RevokedInvitation],
	error)

RevokeBillingPortalAccess takes context, customerId as parameters and returns an models.ApiResponse with models.RevokedInvitation data and an error if there was an issue with the request or response. You can revoke a customer's Billing Portal invitation. If you attempt to revoke an invitation when the Billing Portal is already disabled for a Customer, you will receive a 422 error response. ## Limitations This endpoint will only return a JSON response.

type ClientInterface

type ClientInterface interface {
	Configuration() Configuration
	CloneWithConfiguration(options ...ConfigurationOptions) ClientInterface
	APIExportsController() *APIExportsController
	AdvanceInvoiceController() *AdvanceInvoiceController
	BillingPortalController() *BillingPortalController
	CouponsController() *CouponsController
	ComponentsController() *ComponentsController
	CustomersController() *CustomersController
	CustomFieldsController() *CustomFieldsController
	EventsController() *EventsController
	EventsBasedBillingSegmentsController() *EventsBasedBillingSegmentsController
	InsightsController() *InsightsController
	InvoicesController() *InvoicesController
	OffersController() *OffersController
	PaymentProfilesController() *PaymentProfilesController
	ProductFamiliesController() *ProductFamiliesController
	ProductsController() *ProductsController
	ProductPricePointsController() *ProductPricePointsController
	ProformaInvoicesController() *ProformaInvoicesController
	ReasonCodesController() *ReasonCodesController
	ReferralCodesController() *ReferralCodesController
	SalesCommissionsController() *SalesCommissionsController
	SitesController() *SitesController
	SubscriptionsController() *SubscriptionsController
	SubscriptionComponentsController() *SubscriptionComponentsController
	SubscriptionGroupsController() *SubscriptionGroupsController
	SubscriptionGroupInvoiceAccountController() *SubscriptionGroupInvoiceAccountController
	SubscriptionGroupStatusController() *SubscriptionGroupStatusController
	SubscriptionInvoiceAccountController() *SubscriptionInvoiceAccountController
	SubscriptionNotesController() *SubscriptionNotesController
	SubscriptionProductsController() *SubscriptionProductsController
	SubscriptionStatusController() *SubscriptionStatusController
	WebhooksController() *WebhooksController
	UserAgent() *string
}

Client is an interface representing the main client for accessing configuration and controllers.

func NewClient

func NewClient(configuration Configuration) ClientInterface

NewClient is the constructor for creating a new client instance. It takes a Configuration object as a parameter and returns the Client interface.

type ComponentsController

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

ComponentsController represents a controller struct.

func NewComponentsController

func NewComponentsController(baseController baseController) *ComponentsController

NewComponentsController creates a new instance of ComponentsController. It takes a baseController as a parameter and returns a pointer to the ComponentsController.

func (*ComponentsController) ArchiveComponent

func (c *ComponentsController) ArchiveComponent(
	ctx context.Context,
	productFamilyId int,
	componentId string) (
	models.ApiResponse[models.Component],
	error)

ArchiveComponent takes context, productFamilyId, componentId as parameters and returns an models.ApiResponse with models.Component data and an error if there was an issue with the request or response. Sending a DELETE request to this endpoint will archive the component. All current subscribers will be unffected; their subscription/purchase will continue to be charged as usual.

func (*ComponentsController) ArchiveComponentPricePoint

func (c *ComponentsController) ArchiveComponentPricePoint(
	ctx context.Context,
	componentId int,
	pricePointId int) (
	models.ApiResponse[models.ComponentPricePointResponse],
	error)

ArchiveComponentPricePoint takes context, componentId, pricePointId as parameters and returns an models.ApiResponse with models.ComponentPricePointResponse data and an error if there was an issue with the request or response. A price point can be archived at any time. Subscriptions using a price point that has been archived will continue using it until they're moved to another price point.

func (*ComponentsController) BulkCreateComponentPricePoints added in v0.1.0

BulkCreateComponentPricePoints takes context, componentId, body as parameters and returns an models.ApiResponse with models.ComponentPricePointsResponse data and an error if there was an issue with the request or response. Use this endpoint to create multiple component price points in one request.

func (*ComponentsController) CreateComponentPricePoint

CreateComponentPricePoint takes context, componentId, body as parameters and returns an models.ApiResponse with models.ComponentPricePointResponse data and an error if there was an issue with the request or response. This endpoint can be used to create a new price point for an existing component.

func (*ComponentsController) CreateCurrencyPrices

CreateCurrencyPrices takes context, pricePointId, body as parameters and returns an models.ApiResponse with models.ComponentCurrencyPricesResponse data and an error if there was an issue with the request or response. This endpoint allows you to create currency prices for a given currency that has been defined on the site level in your settings. When creating currency prices, they need to mirror the structure of your primary pricing. For each price level defined on the component price point, there should be a matching price level created in the given currency. Note: Currency Prices are not able to be created for custom price points.

func (*ComponentsController) CreateEventBasedComponent added in v0.1.0

func (c *ComponentsController) CreateEventBasedComponent(
	ctx context.Context,
	productFamilyId int,
	body *models.CreateEBBComponent) (
	models.ApiResponse[models.ComponentResponse],
	error)

CreateEventBasedComponent takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will create a component definition of kind **event_based_component** under the specified product family. Event-based component can then be added and “allocated” for a subscription. Event-based components are similar to other component types, in that you define the component parameters (such as name and taxability) and the pricing. A key difference for the event-based component is that it must be attached to a metric. This is because the metric provides the component with the actual quantity used in computing what and how much will be billed each period for each subscription. So, instead of reporting usage directly for each component (as you would with metered components), the usage is derived from analysis of your events. For more information on components, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677).

func (*ComponentsController) CreateMeteredComponent added in v0.1.0

func (c *ComponentsController) CreateMeteredComponent(
	ctx context.Context,
	productFamilyId int,
	body *models.CreateMeteredComponent) (
	models.ApiResponse[models.ComponentResponse],
	error)

CreateMeteredComponent takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will create a component definition of kind **metered_component** under the specified product family. Metered component can then be added and “allocated” for a subscription. Metered components are used to bill for any type of unit that resets to 0 at the end of the billing period (think daily Google Adwords clicks or monthly cell phone minutes). This is most commonly associated with usage-based billing and many other pricing schemes. Note that this is different from recurring quantity-based components, which DO NOT reset to zero at the start of every billing period. If you want to bill for a quantity of something that does not change unless you change it, then you want quantity components, instead. For more information on components, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677).

func (*ComponentsController) CreateOnOffComponent added in v0.1.0

func (c *ComponentsController) CreateOnOffComponent(
	ctx context.Context,
	productFamilyId int,
	body *models.CreateOnOffComponent) (
	models.ApiResponse[models.ComponentResponse],
	error)

CreateOnOffComponent takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will create a component definition of kind **on_off_component** under the specified product family. On/Off component can then be added and “allocated” for a subscription. On/off components are used for any flat fee, recurring add on (think $99/month for tech support or a flat add on shipping fee). For more information on components, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677).

func (*ComponentsController) CreatePrepaidUsageComponent added in v0.1.0

func (c *ComponentsController) CreatePrepaidUsageComponent(
	ctx context.Context,
	productFamilyId int,
	body *models.CreatePrepaidComponent) (
	models.ApiResponse[models.ComponentResponse],
	error)

CreatePrepaidUsageComponent takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will create a component definition of kind **prepaid_usage_component** under the specified product family. Prepaid component can then be added and “allocated” for a subscription. Prepaid components allow customers to pre-purchase units that can be used up over time on their subscription. In a sense, they are the mirror image of metered components; while metered components charge at the end of the period for the amount of units used, prepaid components are charged for at the time of purchase, and we subsequently keep track of the usage against the amount purchased. For more information on components, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677).

func (*ComponentsController) CreateQuantityBasedComponent added in v0.1.0

func (c *ComponentsController) CreateQuantityBasedComponent(
	ctx context.Context,
	productFamilyId int,
	body *models.CreateQuantityBasedComponent) (
	models.ApiResponse[models.ComponentResponse],
	error)

CreateQuantityBasedComponent takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will create a component definition of kind **quantity_based_component** under the specified product family. Quantity Based component can then be added and “allocated” for a subscription. When defining Quantity Based component, You can choose one of 2 types: #### Recurring Recurring quantity-based components are used to bill for the number of some unit (think monthly software user licenses or the number of pairs of socks in a box-a-month club). This is most commonly associated with billing for user licenses, number of users, number of employees, etc. #### One-time One-time quantity-based components are used to create ad hoc usage charges that do not recur. For example, at the time of signup, you might want to charge your customer a one-time fee for onboarding or other services. The allocated quantity for one-time quantity-based components immediately gets reset back to zero after the allocation is made. For more information on components, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677).

func (*ComponentsController) FindComponent added in v0.1.0

FindComponent takes context, handle as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will return information regarding a component having the handle you provide. You can identify your components with a handle so you don't have to save or reference the IDs we generate.

func (*ComponentsController) ListAllComponentPricePoints

ListAllComponentPricePoints takes context, include, page, perPage, direction, filter as parameters and returns an models.ApiResponse with models.ListComponentsPricePointsResponse data and an error if there was an issue with the request or response. This method allows to retrieve a list of Components Price Points belonging to a Site.

func (*ComponentsController) ListComponentPricePoints

ListComponentPricePoints takes context, componentId, currencyPrices, page, perPage, filterType as parameters and returns an models.ApiResponse with models.ComponentPricePointsResponse data and an error if there was an issue with the request or response. Use this endpoint to read current price points that are associated with a component. You may specify the component by using either the numeric id or the `handle:gold` syntax. When fetching a component's price points, if you have defined multiple currencies at the site level, you can optionally pass the `?currency_prices=true` query param to include an array of currency price data in the response. If the price point is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency.

func (*ComponentsController) ListComponents

ListComponents takes context, dateField, startDate, endDate, startDatetime, endDatetime, includeArchived, page, perPage, filter as parameters and returns an models.ApiResponse with []models.ComponentResponse data and an error if there was an issue with the request or response. This request will return a list of components for a site.

func (*ComponentsController) ListComponentsForProductFamily

ListComponentsForProductFamily takes context, productFamilyId, includeArchived, page, perPage, filter, dateField, endDate, endDatetime, startDate, startDatetime as parameters and returns an models.ApiResponse with []models.ComponentResponse data and an error if there was an issue with the request or response. This request will return a list of components for a particular product family.

func (*ComponentsController) PromoteComponentPricePointToDefault added in v0.1.0

func (c *ComponentsController) PromoteComponentPricePointToDefault(
	ctx context.Context,
	componentId int,
	pricePointId int) (
	models.ApiResponse[models.ComponentResponse],
	error)

PromoteComponentPricePointToDefault takes context, componentId, pricePointId as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. Sets a new default price point for the component. This new default will apply to all new subscriptions going forward - existing subscriptions will remain on their current price point. See [Price Points Documentation](https://chargify.zendesk.com/hc/en-us/articles/4407755865883#price-points) for more information on price points and moving subscriptions between price points. Note: Custom price points are not able to be set as the default for a component.

func (*ComponentsController) ReadComponent added in v0.1.0

func (c *ComponentsController) ReadComponent(
	ctx context.Context,
	productFamilyId int,
	componentId string) (
	models.ApiResponse[models.ComponentResponse],
	error)

ReadComponent takes context, productFamilyId, componentId as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will return information regarding a component from a specific product family. You may read the component by either the component's id or handle. When using the handle, it must be prefixed with `handle:`.

func (*ComponentsController) UnarchiveComponentPricePoint

func (c *ComponentsController) UnarchiveComponentPricePoint(
	ctx context.Context,
	componentId int,
	pricePointId int) (
	models.ApiResponse[models.ComponentPricePointResponse],
	error)

UnarchiveComponentPricePoint takes context, componentId, pricePointId as parameters and returns an models.ApiResponse with models.ComponentPricePointResponse data and an error if there was an issue with the request or response. Use this endpoint to unarchive a component price point.

func (*ComponentsController) UpdateComponent

UpdateComponent takes context, componentId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will update a component. You may read the component by either the component's id or handle. When using the handle, it must be prefixed with `handle:`.

func (*ComponentsController) UpdateComponentPricePoint

func (c *ComponentsController) UpdateComponentPricePoint(
	ctx context.Context,
	componentId int,
	pricePointId int,
	body *models.UpdateComponentPricePointRequest) (
	models.ApiResponse[models.ComponentPricePointResponse],
	error)

UpdateComponentPricePoint takes context, componentId, pricePointId, body as parameters and returns an models.ApiResponse with models.ComponentPricePointResponse data and an error if there was an issue with the request or response. When updating a price point, it's prices can be updated as well by creating new prices or editing / removing existing ones. Passing in a price bracket without an `id` will attempt to create a new price. Including an `id` will update the corresponding price, and including the `_destroy` flag set to true along with the `id` will remove that price. Note: Custom price points cannot be updated directly. They must be edited through the Subscription.

func (*ComponentsController) UpdateCurrencyPrices

UpdateCurrencyPrices takes context, pricePointId, body as parameters and returns an models.ApiResponse with models.ComponentCurrencyPricesResponse data and an error if there was an issue with the request or response. This endpoint allows you to update currency prices for a given currency that has been defined on the site level in your settings. Note: Currency Prices are not able to be updated for custom price points.

func (*ComponentsController) UpdateProductFamilyComponent

func (c *ComponentsController) UpdateProductFamilyComponent(
	ctx context.Context,
	productFamilyId int,
	componentId string,
	body *models.UpdateComponentRequest) (
	models.ApiResponse[models.ComponentResponse],
	error)

UpdateProductFamilyComponent takes context, productFamilyId, componentId, body as parameters and returns an models.ApiResponse with models.ComponentResponse data and an error if there was an issue with the request or response. This request will update a component from a specific product family. You may read the component by either the component's id or handle. When using the handle, it must be prefixed with `handle:`.

type Configuration

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

Configuration holds configuration settings.

func CreateConfiguration

func CreateConfiguration(options ...ConfigurationOptions) Configuration

CreateConfiguration creates a new Configuration with the provided options.

func CreateConfigurationFromEnvironment

func CreateConfigurationFromEnvironment(options ...ConfigurationOptions) Configuration

CreateConfigurationFromEnvironment creates a new Configuration with default settings. It also configures various Configuration options.

func DefaultConfiguration

func DefaultConfiguration() Configuration

DefaultConfiguration returns the default Configuration.

func (Configuration) BasicAuthCredentials added in v0.1.0

func (c Configuration) BasicAuthCredentials() BasicAuthCredentials

BasicAuthCredentials returns the BasicAuthCredentials from the Configuration.

func (Configuration) Domain

func (c Configuration) Domain() string

Domain returns the Domain from the Configuration.

func (Configuration) Environment

func (c Configuration) Environment() Environment

Environment returns the Environment from the Configuration.

func (Configuration) HttpConfiguration

func (c Configuration) HttpConfiguration() HttpConfiguration

HttpConfiguration returns the HttpConfiguration from the Configuration.

func (Configuration) Subdomain

func (c Configuration) Subdomain() string

Subdomain returns the Subdomain from the Configuration.

type ConfigurationOptions

type ConfigurationOptions func(*Configuration)

ConfigurationOptions represents a function type that can be used to apply options to the Configuration struct.

func WithBasicAuthCredentials added in v0.1.0

func WithBasicAuthCredentials(basicAuthCredentials BasicAuthCredentials) ConfigurationOptions

WithBasicAuthCredentials is an option that sets the BasicAuthCredentials in the Configuration.

func WithDomain

func WithDomain(domain string) ConfigurationOptions

WithDomain is an option that sets the Domain in the Configuration.

func WithEnvironment

func WithEnvironment(environment Environment) ConfigurationOptions

WithEnvironment is an option that sets the Environment in the Configuration.

func WithHttpConfiguration

func WithHttpConfiguration(httpConfiguration HttpConfiguration) ConfigurationOptions

WithHttpConfiguration is an option that sets the HttpConfiguration in the Configuration.

func WithSubdomain

func WithSubdomain(subdomain string) ConfigurationOptions

WithSubdomain is an option that sets the Subdomain in the Configuration.

type CouponsController

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

CouponsController represents a controller struct.

func NewCouponsController

func NewCouponsController(baseController baseController) *CouponsController

NewCouponsController creates a new instance of CouponsController. It takes a baseController as a parameter and returns a pointer to the CouponsController.

func (*CouponsController) ArchiveCoupon

func (c *CouponsController) ArchiveCoupon(
	ctx context.Context,
	productFamilyId int,
	couponId int) (
	models.ApiResponse[models.CouponResponse],
	error)

ArchiveCoupon takes context, productFamilyId, couponId as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. You can archive a Coupon via the API with the archive method. Archiving makes that Coupon unavailable for future use, but allows it to remain attached and functional on existing Subscriptions that are using it. The `archived_at` date and time will be assigned.

func (*CouponsController) CreateCoupon

func (c *CouponsController) CreateCoupon(
	ctx context.Context,
	productFamilyId int,
	body *models.CreateOrUpdateCoupon) (
	models.ApiResponse[models.CouponResponse],
	error)

CreateCoupon takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. ## Coupons Documentation Coupons can be administered in the Chargify application or created via API. Please view our section on [creating coupons](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404742830733) for more information. Additionally, for documentation on how to apply a coupon to a subscription within the Chargify UI, please see our documentation [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404761012877). ## Create Coupon This request will create a coupon, based on the provided information. When creating a coupon, you must specify a product family using the `product_family_id`. If no `product_family_id` is passed, the first product family available is used. You will also need to formulate your URL to cite the Product Family ID in your request. You can restrict a coupon to only apply to specific products / components by optionally passing in hashes of `restricted_products` and/or `restricted_components` in the format: `{ "<product/component_id>": boolean_value }`

func (*CouponsController) CreateCouponSubcodes

func (c *CouponsController) CreateCouponSubcodes(
	ctx context.Context,
	couponId int,
	body *models.CouponSubcodes) (
	models.ApiResponse[models.CouponSubcodesResponse],
	error)

CreateCouponSubcodes takes context, couponId, body as parameters and returns an models.ApiResponse with models.CouponSubcodesResponse data and an error if there was an issue with the request or response. ## Coupon Subcodes Intro Coupon Subcodes allow you to create a set of unique codes that allow you to expand the use of one coupon. For example: Master Coupon Code: + SPRING2020 Coupon Subcodes: + SPRING90210 + DP80302 + SPRINGBALTIMORE Coupon subcodes can be administered in the Admin Interface or via the API. When creating a coupon subcode, you must specify a coupon to attach it to using the coupon_id. Valid coupon subcodes are all capital letters, contain only letters and numbers, and do not have any spaces. Lowercase letters will be capitalized before the subcode is created. ## Coupon Subcodes Documentation Full documentation on how to create coupon subcodes in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407755909531#coupon-codes). Additionally, for documentation on how to apply a coupon to a Subscription within the Chargify UI, please see our documentation [here](https://chargify.zendesk.com/hc/en-us/articles/4407884887835#coupon). ## Create Coupon Subcode This request allows you to create specific subcodes underneath an existing coupon code. *Note*: If you are using any of the allowed special characters ("%", "@", "+", "-", "_", and "."), you must encode them for use in the URL. % to %25 @ to %40 + to %2B - to %2D _ to %5F . to %2E So, if the coupon subcode is `20%OFF`, the URL to delete this coupon subcode would be: `https://<subdomain>.chargify.com/coupons/567/codes/20%25OFF.<format>`

func (*CouponsController) CreateOrUpdateCouponCurrencyPrices added in v0.1.0

func (c *CouponsController) CreateOrUpdateCouponCurrencyPrices(
	ctx context.Context,
	couponId int,
	body *models.CouponCurrencyRequest) (
	models.ApiResponse[models.CouponCurrencyResponse],
	error)

CreateOrUpdateCouponCurrencyPrices takes context, couponId, body as parameters and returns an models.ApiResponse with models.CouponCurrencyResponse data and an error if there was an issue with the request or response. This endpoint allows you to create and/or update currency prices for an existing coupon. Multiple prices can be created or updated in a single request but each of the currencies must be defined on the site level already and the coupon must be an amount-based coupon, not percentage. Currency pricing for coupons must mirror the setup of the primary coupon pricing - if the primary coupon is percentage based, you will not be able to define pricing in non-primary currencies.

func (*CouponsController) DeleteCouponSubcode

func (c *CouponsController) DeleteCouponSubcode(
	ctx context.Context,
	couponId int,
	subcode string) (
	*http.Response,
	error)

DeleteCouponSubcode takes context, couponId, subcode as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. ## Example Given a coupon with an ID of 567, and a coupon subcode of 20OFF, the URL to `DELETE` this coupon subcode would be: ``` http://subdomain.chargify.com/coupons/567/codes/20OFF.<format> ``` Note: If you are using any of the allowed special characters (“%”, “@”, “+”, “-”, “_”, and “.”), you must encode them for use in the URL. | Special character | Encoding | |-------------------|----------| | % | %25 | | @ | %40 | | + | %2B | | – | %2D | | _ | %5F | | . | %2E | ## Percent Encoding Example Or if the coupon subcode is 20%OFF, the URL to delete this coupon subcode would be: @https://<subdomain>.chargify.com/coupons/567/codes/20%25OFF.<format>

func (*CouponsController) FindCoupon added in v0.1.0

func (c *CouponsController) FindCoupon(
	ctx context.Context,
	productFamilyId *int,
	code *string) (
	models.ApiResponse[models.CouponResponse],
	error)

FindCoupon takes context, productFamilyId, code as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. You can search for a coupon via the API with the find method. By passing a code parameter, the find will attempt to locate a coupon that matches that code. If no coupon is found, a 404 is returned. If you have more than one product family and if the coupon you are trying to find does not belong to the default product family in your site, then you will need to specify (either in the url or as a query string param) the product family id.

func (*CouponsController) ListCouponSubcodes

ListCouponSubcodes takes context, couponId, page, perPage as parameters and returns an models.ApiResponse with models.CouponSubcodes data and an error if there was an issue with the request or response. This request allows you to request the subcodes that are attached to a coupon.

func (*CouponsController) ListCoupons

ListCoupons takes context, page, perPage, filter, currencyPrices as parameters and returns an models.ApiResponse with []models.CouponResponse data and an error if there was an issue with the request or response. You can retrieve a list of coupons. If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency.

func (*CouponsController) ListCouponsForProductFamily

ListCouponsForProductFamily takes context, productFamilyId, page, perPage, filter, currencyPrices as parameters and returns an models.ApiResponse with []models.CouponResponse data and an error if there was an issue with the request or response. List coupons for a specific Product Family in a Site. If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency.

func (*CouponsController) ReadCoupon

func (c *CouponsController) ReadCoupon(
	ctx context.Context,
	productFamilyId int,
	couponId int) (
	models.ApiResponse[models.CouponResponse],
	error)

ReadCoupon takes context, productFamilyId, couponId as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. You can retrieve the Coupon via the API with the Show method. You must identify the Coupon in this call by the ID parameter that Chargify assigns. If instead you would like to find a Coupon using a Coupon code, see the Coupon Find method. When fetching a coupon, if you have defined multiple currencies at the site level, you can optionally pass the `?currency_prices=true` query param to include an array of currency price data in the response. If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency.

func (*CouponsController) ReadCouponUsage

func (c *CouponsController) ReadCouponUsage(
	ctx context.Context,
	productFamilyId int,
	couponId int) (
	models.ApiResponse[[]models.CouponUsage],
	error)

ReadCouponUsage takes context, productFamilyId, couponId as parameters and returns an models.ApiResponse with []models.CouponUsage data and an error if there was an issue with the request or response. This request will provide details about the coupon usage as an array of data hashes, one per product.

func (*CouponsController) UpdateCoupon

func (c *CouponsController) UpdateCoupon(
	ctx context.Context,
	productFamilyId int,
	couponId int,
	body *models.CreateOrUpdateCoupon) (
	models.ApiResponse[models.CouponResponse],
	error)

UpdateCoupon takes context, productFamilyId, couponId, body as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. ## Update Coupon You can update a Coupon via the API with a PUT request to the resource endpoint. You can restrict a coupon to only apply to specific products / components by optionally passing in hashes of `restricted_products` and/or `restricted_components` in the format: `{ "<product/component_id>": boolean_value }`

func (*CouponsController) UpdateCouponSubcodes

func (c *CouponsController) UpdateCouponSubcodes(
	ctx context.Context,
	couponId int,
	body *models.CouponSubcodes) (
	models.ApiResponse[models.CouponSubcodesResponse],
	error)

UpdateCouponSubcodes takes context, couponId, body as parameters and returns an models.ApiResponse with models.CouponSubcodesResponse data and an error if there was an issue with the request or response. You can update the subcodes for the given Coupon via the API with a PUT request to the resource endpoint. Send an array of new coupon subcodes. **Note**: All current subcodes for that Coupon will be deleted first, and replaced with the list of subcodes sent to this endpoint. The response will contain: + The created subcodes, + Subcodes that were not created because they already exist, + Any subcodes not created because they are invalid.

func (*CouponsController) ValidateCoupon

func (c *CouponsController) ValidateCoupon(
	ctx context.Context,
	code string,
	productFamilyId *int) (
	models.ApiResponse[models.CouponResponse],
	error)

ValidateCoupon takes context, code, productFamilyId as parameters and returns an models.ApiResponse with models.CouponResponse data and an error if there was an issue with the request or response. You can verify if a specific coupon code is valid using the `validate` method. This method is useful for validating coupon codes that are entered by a customer. If the coupon is found and is valid, the coupon will be returned with a 200 status code. If the coupon is invalid, the status code will be 404 and the response will say why it is invalid. If the coupon is valid, the status code will be 200 and the coupon will be returned. The following reasons for invalidity are supported: + Coupon not found + Coupon is invalid + Coupon expired If you have more than one product family and if the coupon you are validating does not belong to the first product family in your site, then you will need to specify the product family, either in the url or as a query string param. This can be done by supplying the id or the handle in the `handle:my-family` format. Eg. ``` https://<subdomain>.chargify.com/product_families/handle:<product_family_handle>/coupons/validate.<format>?code=<coupon_code> ``` Or: ``` https://<subdomain>.chargify.com/coupons/validate.<format>?code=<coupon_code>&product_family_id=<id> ```

type CustomFieldsController

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

CustomFieldsController represents a controller struct.

func NewCustomFieldsController

func NewCustomFieldsController(baseController baseController) *CustomFieldsController

NewCustomFieldsController creates a new instance of CustomFieldsController. It takes a baseController as a parameter and returns a pointer to the CustomFieldsController.

func (*CustomFieldsController) CreateMetadata

func (c *CustomFieldsController) CreateMetadata(
	ctx context.Context,
	resourceType models.ResourceType,
	resourceId int,
	body *models.CreateMetadataRequest) (
	models.ApiResponse[[]models.Metadata],
	error)

CreateMetadata takes context, resourceType, resourceId, body as parameters and returns an models.ApiResponse with []models.Metadata data and an error if there was an issue with the request or response. ## Custom Fields: Metadata Intro **Chargify refers to Custom Fields in the API documentation as metafields and metadata.** Within the Chargify UI, metadata and metafields are grouped together under the umbrella of "Custom Fields." All of our UI-based documentation that references custom fields will not cite the terminology metafields or metadata. + **Metafield is the custom field** + **Metadata is the data populating the custom field.** Chargify Metafields are used to add meaningful attributes to subscription and customer resources. Full documentation on how to create Custom Fields in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407659856411). For additional documentation on how to record data within custom fields, please see our subscription-based documentation [here.](https://chargify.zendesk.com/hc/en-us/articles/4407884887835#custom-fields) Metadata is associated to a customer or subscription, and corresponds to a Metafield. When creating a new metadata object for a given record, **if the metafield is not present it will be created**. ## Metadata limits Metadata values are limited to 2kB in size. Additonally, there are limits on the number of unique metafields available per resource. ## Create Metadata This method will create a metafield for the site on the fly if it does not already exist, and populate the metadata value. ### Subscription or Customer Resource Please pay special attention to the resource you use when creating metadata.

func (*CustomFieldsController) CreateMetafields

CreateMetafields takes context, resourceType, body as parameters and returns an models.ApiResponse with []models.Metafield data and an error if there was an issue with the request or response. ## Custom Fields: Metafield Intro **Chargify refers to Custom Fields in the API documentation as metafields and metadata.** Within the Chargify UI, metadata and metafields are grouped together under the umbrella of "Custom Fields." All of our UI-based documentation that references custom fields will not cite the terminology metafields or metadata. + **Metafield is the custom field** + **Metadata is the data populating the custom field.** Chargify Metafields are used to add meaningful attributes to subscription and customer resources. Full documentation on how to create Custom Fields in the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405332553613-Custom-Fields-Reference). For additional documentation on how to record data within custom fields, please see our subscription-based documentation [here.](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404434903181-Subscription-Summary#custom-fields) Metafield are the place where you will set up your resource to accept additional data. It is scoped to the site instead of a specific customer or subscription. Think of it as the key, and Metadata as the value on every record. ## Create Metafields Use this endpoint to create metafields for your Site. Metafields can be populated with metadata after the fact. Each site is limited to 100 unique Metafields (i.e. keys, or names) per resource. This means you can have 100 Metafields for Subscription and another 100 for Customer. ### Metafields "On-the-Fly" It is possible to create Metafields “on the fly” when you create your Metadata – if a non-existant name is passed when creating Metadata, a Metafield for that key will be automatically created. The Metafield API, however, gives you more control over your “keys”. ### Metafield Scope Warning If configuring metafields in the Admin UI or via the API, be careful sending updates to metafields with the scope attribute – **if a partial update is sent it will overwrite the current configuration**.

func (*CustomFieldsController) DeleteMetadata

func (c *CustomFieldsController) DeleteMetadata(
	ctx context.Context,
	resourceType models.ResourceType,
	resourceId int,
	name *string,
	names []string) (
	*http.Response,
	error)

DeleteMetadata takes context, resourceType, resourceId, name, names as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This method removes the metadata from the subscriber/customer cited. ## Query String Usage For instance if you wanted to delete the metadata for customer 99 named weight you would request: ``` https://acme.chargify.com/customers/99/metadata.json?name=weight ``` If you want to delete multiple metadata fields for a customer 99 named: `weight` and `age` you wrould request: ``` https://acme.chargify.com/customers/99/metadata.json?names[]=weight&names[]=age ``` ## Successful Response For a success, there will be a code `200` and the plain text response `true`. ## Unsuccessful Response When a failed response is encountered, you will receive a `404` response and the plain text response of `true`.

func (*CustomFieldsController) DeleteMetafield

func (c *CustomFieldsController) DeleteMetafield(
	ctx context.Context,
	resourceType models.ResourceType,
	name *string) (
	*http.Response,
	error)

DeleteMetafield takes context, resourceType, name as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Use the following method to delete a metafield. This will remove the metafield from the Site. Additionally, this will remove the metafield and associated metadata with all Subscriptions on the Site.

func (*CustomFieldsController) ListMetadata

ListMetadata takes context, resourceType, resourceId, page, perPage as parameters and returns an models.ApiResponse with models.PaginatedMetadata data and an error if there was an issue with the request or response. This request will list all of the metadata belonging to a particular resource (ie. subscription, customer) that is specified. ## Metadata Data This endpoint will also display the current stats of your metadata to use as a tool for pagination.

func (*CustomFieldsController) ListMetadataForResourceType

ListMetadataForResourceType takes context, resourceType, page, perPage, dateField, startDate, endDate, startDatetime, endDatetime, withDeleted, resourceIds, direction as parameters and returns an models.ApiResponse with models.PaginatedMetadata data and an error if there was an issue with the request or response. This method will provide you information on usage of metadata across your selected resource (ie. subscriptions, customers) ## Metadata Data This endpoint will also display the current stats of your metadata to use as a tool for pagination. ### Metadata for multiple records `https://acme.chargify.com/subscriptions/metadata.json?resource_ids[]=1&resource_ids[]=2` ## Read Metadata for a Site This endpoint will list the number of pages of metadata information that are contained within a site.

func (*CustomFieldsController) ListMetafields

ListMetafields takes context, resourceType, name, page, perPage, direction as parameters and returns an models.ApiResponse with models.ListMetafieldsResponse data and an error if there was an issue with the request or response. This endpoint lists metafields associated with a site. The metafield description and usage is contained in the response.

func (*CustomFieldsController) UpdateMetadata

func (c *CustomFieldsController) UpdateMetadata(
	ctx context.Context,
	resourceType models.ResourceType,
	resourceId int,
	body *models.UpdateMetadataRequest) (
	models.ApiResponse[[]models.Metadata],
	error)

UpdateMetadata takes context, resourceType, resourceId, body as parameters and returns an models.ApiResponse with []models.Metadata data and an error if there was an issue with the request or response. This method allows you to update the existing metadata associated with a subscription or customer.

func (*CustomFieldsController) UpdateMetafield

UpdateMetafield takes context, resourceType, body as parameters and returns an models.ApiResponse with []models.Metafield data and an error if there was an issue with the request or response. Use the following method to update metafields for your Site. Metafields can be populated with metadata after the fact.

type CustomersController

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

CustomersController represents a controller struct.

func NewCustomersController

func NewCustomersController(baseController baseController) *CustomersController

NewCustomersController creates a new instance of CustomersController. It takes a baseController as a parameter and returns a pointer to the CustomersController.

func (*CustomersController) CreateCustomer

CreateCustomer takes context, body as parameters and returns an models.ApiResponse with models.CustomerResponse data and an error if there was an issue with the request or response. You may create a new Customer at any time, or you may create a Customer at the same time you create a Subscription. The only validation restriction is that you may only create one customer for a given reference value. If provided, the `reference` value must be unique. It represents a unique identifier for the customer from your own app, i.e. the customer’s ID. This allows you to retrieve a given customer via a piece of shared information. Alternatively, you may choose to leave `reference` blank, and store Chargify’s unique ID for the customer, which is in the `id` attribute. Full documentation on how to locate, create and edit Customers in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407659914267). ## Required Country Format Chargify requires that you use the ISO Standard Country codes when formatting country attribute of the customer. Countries should be formatted as 2 characters. For more information, please see the following wikipedia article on [ISO_3166-1.](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) ## Required State Format Chargify requires that you use the ISO Standard State codes when formatting state attribute of the customer. + US States (2 characters): [ISO_3166-2](https://en.wikipedia.org/wiki/ISO_3166-2:US) + States Outside the US (2-3 characters): To find the correct state codes outside of the US, please go to [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) and click on the link in the “ISO 3166-2 codes” column next to country you wish to populate. ## Locale Chargify allows you to attribute a language/region to your customer to deliver invoices in any required language. For more: [Customer Locale](https://chargify.zendesk.com/hc/en-us/articles/4407870384283#customer-locale)

func (*CustomersController) DeleteCustomer

func (c *CustomersController) DeleteCustomer(
	ctx context.Context,
	id int) (
	*http.Response,
	error)

DeleteCustomer takes context, id as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This method allows you to delete the Customer.

func (*CustomersController) ListCustomerSubscriptions

func (c *CustomersController) ListCustomerSubscriptions(
	ctx context.Context,
	customerId int) (
	models.ApiResponse[[]models.SubscriptionResponse],
	error)

ListCustomerSubscriptions takes context, customerId as parameters and returns an models.ApiResponse with []models.SubscriptionResponse data and an error if there was an issue with the request or response. This method lists all subscriptions that belong to a customer.

func (*CustomersController) ListCustomers

ListCustomers takes context, direction, page, perPage, dateField, startDate, endDate, startDatetime, endDatetime, q as parameters and returns an models.ApiResponse with []models.CustomerResponse data and an error if there was an issue with the request or response. This request will by default list all customers associated with your Site. ## Find Customer Use the search feature with the `q` query parameter to retrieve an array of customers that matches the search query. Common use cases are: + Search by an email + Search by a Chargify ID + Search by an organization + Search by a reference value from your application + Search by a first or last name To retrieve a single, exact match by reference, please use the [lookup endpoint](https://developers.chargify.com/docs/api-docs/b710d8fbef104-read-customer-by-reference).

func (*CustomersController) ReadCustomer

ReadCustomer takes context, id as parameters and returns an models.ApiResponse with models.CustomerResponse data and an error if there was an issue with the request or response. This method allows to retrieve the Customer properties by Chargify-generated Customer ID.

func (*CustomersController) ReadCustomerByReference

func (c *CustomersController) ReadCustomerByReference(
	ctx context.Context,
	reference string) (
	models.ApiResponse[models.CustomerResponse],
	error)

ReadCustomerByReference takes context, reference as parameters and returns an models.ApiResponse with models.CustomerResponse data and an error if there was an issue with the request or response. Use this method to return the customer object if you have the unique **Reference ID (Your App)** value handy. It will return a single match.

func (*CustomersController) UpdateCustomer

UpdateCustomer takes context, id, body as parameters and returns an models.ApiResponse with models.CustomerResponse data and an error if there was an issue with the request or response. This method allows to update the Customer.

type Environment

type Environment string

Environment represents available environments.

const (
	PRODUCTION   Environment = "production"
	ENVIRONMENT2 Environment = "environment2"
)

type EventsBasedBillingSegmentsController

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

EventsBasedBillingSegmentsController represents a controller struct.

func NewEventsBasedBillingSegmentsController

func NewEventsBasedBillingSegmentsController(baseController baseController) *EventsBasedBillingSegmentsController

NewEventsBasedBillingSegmentsController creates a new instance of EventsBasedBillingSegmentsController. It takes a baseController as a parameter and returns a pointer to the EventsBasedBillingSegmentsController.

func (*EventsBasedBillingSegmentsController) BulkCreateSegments added in v0.1.0

BulkCreateSegments takes context, componentId, pricePointId, body as parameters and returns an models.ApiResponse with models.ListSegmentsResponse data and an error if there was an issue with the request or response. This endpoint allows you to create multiple segments in one request. The array of segments can contain up to `2000` records. If any of the records contain an error the whole request would fail and none of the requested segments get created. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

func (*EventsBasedBillingSegmentsController) BulkUpdateSegments added in v0.1.0

BulkUpdateSegments takes context, componentId, pricePointId, body as parameters and returns an models.ApiResponse with models.ListSegmentsResponse data and an error if there was an issue with the request or response. This endpoint allows you to update multiple segments in one request. The array of segments can contain up to `1000` records. If any of the records contain an error the whole request would fail and none of the requested segments get updated. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

func (*EventsBasedBillingSegmentsController) CreateSegment

CreateSegment takes context, componentId, pricePointId, body as parameters and returns an models.ApiResponse with models.SegmentResponse data and an error if there was an issue with the request or response. This endpoint creates a new Segment for a Component with segmented Metric. It allows you to specify properties to bill upon and prices for each Segment. You can only pass as many "property_values" as the related Metric has segmenting properties defined. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

func (*EventsBasedBillingSegmentsController) DeleteSegment

func (e *EventsBasedBillingSegmentsController) DeleteSegment(
	ctx context.Context,
	componentId string,
	pricePointId string,
	id float64) (
	*http.Response,
	error)

DeleteSegment takes context, componentId, pricePointId, id as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This endpoint allows you to delete a Segment with specified ID. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

func (*EventsBasedBillingSegmentsController) ListSegmentsForPricePoint

ListSegmentsForPricePoint takes context, componentId, pricePointId, page, perPage, filter as parameters and returns an models.ApiResponse with models.ListSegmentsResponse data and an error if there was an issue with the request or response. This endpoint allows you to fetch Segments created for a given Price Point. They will be returned in the order of creation. You can pass `page` and `per_page` parameters in order to access all of the segments. By default it will return `30` records. You can set `per_page` to `200` at most. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

func (*EventsBasedBillingSegmentsController) UpdateSegment

UpdateSegment takes context, componentId, pricePointId, id, body as parameters and returns an models.ApiResponse with models.SegmentResponse data and an error if there was an issue with the request or response. This endpoint updates a single Segment for a Component with a segmented Metric. It allows you to update the pricing for the segment. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax.

type EventsController

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

EventsController represents a controller struct.

func NewEventsController

func NewEventsController(baseController baseController) *EventsController

NewEventsController creates a new instance of EventsController. It takes a baseController as a parameter and returns a pointer to the EventsController.

func (*EventsController) ListEvents

ListEvents takes context, page, perPage, sinceId, maxId, direction, filter, dateField, startDate, endDate, startDatetime, endDatetime as parameters and returns an models.ApiResponse with []models.EventResponse data and an error if there was an issue with the request or response. ## Events Intro Chargify Events include various activity that happens around a Site. This information is **especially** useful to track down issues that arise when subscriptions are not created due to errors. Within the Chargify UI, "Events" are referred to as "Site Activity". Full documentation on how to record view Events / Site Activty in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407864698139). ## List Events for a Site This method will retrieve a list of events for a site. Use query string filters to narrow down results. You may use the `key` filter as part of your query string to narrow down results. ### Legacy Filters The following keys are no longer supported. + `payment_failure_recreated` + `payment_success_recreated` + `renewal_failure_recreated` + `renewal_success_recreated` + `zferral_revenue_post_failure` - (Specific to the deprecated Zferral integration) + `zferral_revenue_post_success` - (Specific to the deprecated Zferral integration) ## Event Specific Data Event Specific Data Each event type has its own `event_specific_data` specified. Here’s an example event for the `subscription_product_change` event: ``` { "event": { "id": 351, "key": "subscription_product_change", "message": "Product changed on Marky Mark's subscription from 'Basic' to 'Pro'", "subscription_id": 205, "event_specific_data": { "new_product_id": 3, "previous_product_id": 2 }, "created_at": "2012-01-30T10:43:31-05:00" } } ``` Here’s an example event for the `subscription_state_change` event: ``` { "event": { "id": 353, "key": "subscription_state_change", "message": "State changed on Marky Mark's subscription to Pro from trialing to active", "subscription_id": 205, "event_specific_data": { "new_subscription_state": "active", "previous_subscription_state": "trialing" }, "created_at": "2012-01-30T10:43:33-05:00" } } ```

func (*EventsController) ListSubscriptionEvents

ListSubscriptionEvents takes context, subscriptionId, page, perPage, sinceId, maxId, direction, filter as parameters and returns an models.ApiResponse with []models.EventResponse data and an error if there was an issue with the request or response. The following request will return a list of events for a subscription. Each event type has its own `event_specific_data` specified.

func (*EventsController) ReadEventsCount

ReadEventsCount takes context, page, perPage, sinceId, maxId, direction, filter as parameters and returns an models.ApiResponse with models.CountResponse data and an error if there was an issue with the request or response. Get a count of all the events for a given site by using this method.

type HttpConfiguration

type HttpConfiguration = https.HttpConfiguration

HttpConfiguration holds the configuration options for the client.

func CreateHttpConfiguration

func CreateHttpConfiguration(options ...HttpConfigurationOptions) HttpConfiguration

CreateHttpConfiguration creates a new HttpConfiguration with the provided options.

func DefaultHttpConfiguration

func DefaultHttpConfiguration() HttpConfiguration

DefaultHttpConfiguration returns the default HttpConfiguration for HTTP requests. It also configures various HttpConfiguration options.

type HttpConfigurationOptions

type HttpConfigurationOptions = https.HttpConfigurationOptions

HttpConfigurationOptions is a function type that modifies the HttpConfiguration.

type InsightsController

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

InsightsController represents a controller struct.

func NewInsightsController

func NewInsightsController(baseController baseController) *InsightsController

NewInsightsController creates a new instance of InsightsController. It takes a baseController as a parameter and returns a pointer to the InsightsController.

func (*InsightsController) ListMrrMovements added in v0.1.0

ListMrrMovements takes context, subscriptionId, page, perPage, direction as parameters and returns an models.ApiResponse with models.ListMRRResponse data and an error if there was an issue with the request or response. Deprecated: listMrrMovements is deprecated This endpoint returns your site's MRR movements. ## Understanding MRR movements This endpoint will aid in accessing your site's [MRR Report](https://chargify.zendesk.com/hc/en-us/articles/4407838249627) data. Whenever a subscription event occurs that causes your site's MRR to change (such as a signup or upgrade), we record an MRR movement. These records are accessible via the MRR Movements endpoint. Each MRR Movement belongs to a subscription and contains a timestamp, category, and an amount. `line_items` represent the subscription's product configuration at the time of the movement. ### Plan & Usage Breakouts In the MRR Report UI, we support a setting to [include or exclude](https://chargify.zendesk.com/hc/en-us/articles/4407838249627#displaying-component-based-metered-usage-in-mrr) usage revenue. In the MRR APIs, responses include `plan` and `usage` breakouts. Plan includes revenue from: * Products * Quantity-Based Components * On/Off Components Usage includes revenue from: * Metered Components * Prepaid Usage Components

func (*InsightsController) ListMrrPerSubscription

ListMrrPerSubscription takes context, filter, atTime, page, perPage, direction as parameters and returns an models.ApiResponse with models.SubscriptionMRRResponse data and an error if there was an issue with the request or response. Deprecated: listMrrPerSubscription is deprecated This endpoint returns your site's current MRR, including plan and usage breakouts split per subscription.

func (*InsightsController) ReadMrr

func (i *InsightsController) ReadMrr(
	ctx context.Context,
	atTime *time.Time,
	subscriptionId *int) (
	models.ApiResponse[models.MRRResponse],
	error)

ReadMrr takes context, atTime, subscriptionId as parameters and returns an models.ApiResponse with models.MRRResponse data and an error if there was an issue with the request or response. Deprecated: readMrr is deprecated This endpoint returns your site's current MRR, including plan and usage breakouts.

func (*InsightsController) ReadSiteStats

ReadSiteStats takes context as parameters and returns an models.ApiResponse with models.SiteSummary data and an error if there was an issue with the request or response. The Stats API is a very basic view of some Site-level stats. This API call only answers with JSON responses. An XML version is not provided. ## Stats Documentation There currently is not a complimentary matching set of documentation that compliments this endpoint. However, each Site's dashboard will reflect the summary of information provided in the Stats reposnse. ``` https://subdomain.chargify.com/dashboard ```

type InvoicesController

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

InvoicesController represents a controller struct.

func NewInvoicesController

func NewInvoicesController(baseController baseController) *InvoicesController

NewInvoicesController creates a new instance of InvoicesController. It takes a baseController as a parameter and returns a pointer to the InvoicesController.

func (*InvoicesController) CreateInvoice

func (i *InvoicesController) CreateInvoice(
	ctx context.Context,
	subscriptionId int,
	body *models.CreateInvoiceRequest) (
	models.ApiResponse[models.InvoiceResponse],
	error)

CreateInvoice takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.InvoiceResponse data and an error if there was an issue with the request or response. This endpoint will allow you to create an ad hoc invoice. ### Basic Behavior You can create a basic invoice by sending an array of line items to this endpoint. Each line item, at a minimum, must include a title, a quantity and a unit price. Example: ```json { "invoice": { "line_items": [ { "title": "A Product", "quantity": 12, "unit_price": "150.00" } ] } } ``` ### Catalog items Instead of creating custom products like in above example, You can pass existing items like products, components. ```json { "invoice": { "line_items": [ { "product_id": "handle:gold-product", "quantity": 2, } ] } } ``` The price for each line item will be calculated as well as a total due amount for the invoice. Multiple line items can be sent. ### Line items types When defining line item, You can choose one of 3 types for one line item: #### Custom item Like in basic behavior example above, You can pass `title` and `unit_price` for custom item. #### Product id Product handle (with handle: prefix) or id from the scope of current subscription's site can be provided with `product_id`. By default `unit_price` is taken from product's default price point, but can be overwritten by passing `unit_price` or `product_price_point_id`. If `product_id` is used, following fields cannot be used: `title`, `component_id`. #### Component id Component handle (with handle: prefix) or id from the scope of current subscription's site can be provided with `component_id`. If `component_id` is used, following fields cannot be used: `title`, `product_id`. By default `unit_price` is taken from product's default price point, but can be overwritten by passing `unit_price` or `price_point_id`. At this moment price points are supportted only for quantity based, on/off and metered components. For prepaid and event based billing components `unit_price` is required. ### Coupons When creating ad hoc invoice, new discounts can be applied in following way: ```json { "invoice": { "line_items": [ { "product_id": "handle:gold-product", "quantity": 1 } ], "coupons": [ { "code": "COUPONCODE", "percentage": 50.0 } ] } } ``` If You want to use existing coupon for discount creation, only `code` and optional `product_family_id` is needed ```json ... "coupons": [ { "code": "FREESETUP", "product_family_id": 1 } ] ... ``` ### Coupon options #### Code Coupon `code` will be displayed on invoice discount section. Coupon code can only contain uppercase letters, numbers, and allowed special characters. Lowercase letters will be converted to uppercase. It can be used to select an existing coupon from the catalog, or as an ad hoc coupon when passed with `percentage` or `amount`. #### Percentage Coupon `percentage` can take values from 0 to 100 and up to 4 decimal places. It cannot be used with `amount`. Only for ad hoc coupons, will be ignored if `code` is used to select an existing coupon from the catalog. #### Amount Coupon `amount` takes number value. It cannot be used with `percentage`. Used only when not matching existing coupon by `code`. #### Description Optional `description` will be displayed with coupon `code`. Used only when not matching existing coupon by `code`. #### Product Family id Optional `product_family_id` handle (with handle: prefix) or id is used to match existing coupon within site, when codes are not unique. #### Compounding Strategy Optional `compounding_strategy` for percentage coupons, can take values `compound` or `full-price`. For amount coupons, discounts will be always calculated against the original item price, before other discounts are applied. `compound` strategy: Percentage-based discounts will be calculated against the remaining price, after prior discounts have been calculated. It is set by default. `full-price` strategy: Percentage-based discounts will always be calculated against the original item price, before other discounts are applied. ### Line Item Options #### Period Date Range A custom period date range can be defined for each line item with the `period_range_start` and `period_range_end` parameters. Dates must be sent in the `YYYY-MM-DD` format. `period_range_end` must be greater or equal `period_range_start`. #### Taxes The `taxable` parameter can be sent as `true` if taxes should be calculated for a specific line item. For this to work, the site should be configured to use and calculate taxes. Further, if the site uses Avalara for tax calculations, a `tax_code` parameter should also be sent. For existing catalog items: products/components taxes cannot be overwritten. #### Price Point Price point handle (with handle: prefix) or id from the scope of current subscription's site can be provided with `price_point_id` for components with `component_id` or `product_price_point_id` for products with `product_id` parameter. If price point is passed `unit_price` cannot be used. It can be used only with catalog items products and components. #### Description Optional `description` parameter, it will overwrite default generated description for line item. ### Invoice Options #### Issue Date By default, invoices will be created with a issue date set to today. `issue_date` parameter can be send to alter that. Only dates in the past can be send. `issue_date` should be send in `YYYY-MM-DD` format. #### Net Terms By default, invoices will be created with a due date matching the date of invoice creation. If a different due date is desired, the `net_terms` parameter can be sent indicating the number of days in advance the due date should be. #### Addresses The seller, shipping and billing addresses can be sent to override the site's defaults. Each address requires to send a `first_name` at a minimum in order to work. Please see below for the details on which parameters can be sent for each address object. #### Memo and Payment Instructions A custom memo can be sent with the `memo` parameter to override the site's default. Likewise, custom payment instructions can be sent with the `payment_instrucions` parameter. #### Status By default, invoices will be created with open status. Possible alternative is `draft`.

func (*InvoicesController) IssueInvoice

IssueInvoice takes context, uid, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. This endpoint allows you to issue an invoice that is in "pending" status. For example, you can issue an invoice that was created when allocating new quantity on a component and using "accrue charges" option. You cannot issue a pending child invoice that was created for a member subscription in a group. For Remittance subscriptions, the invoice will go into "open" status and payment won't be attempted. The value for `on_failed_payment` would be rejected if sent. Any prepayments or service credits that exist on subscription will be automatically applied. Additionally, if setting is on, an email will be sent for issued invoice. For Automatic subscriptions, prepayments and service credits will apply to the invoice and before payment is attempted. On successful payment, the invoice will go into "paid" status and email will be sent to the customer (if setting applies). When payment fails, the next event depends on the `on_failed_payment` value: - `leave_open_invoice` - prepayments and credits applied to invoice; invoice status set to "open"; email sent to the customer for the issued invoice (if setting applies); payment failure recorded in the invoice history. This is the default option. - `rollback_to_pending` - prepayments and credits not applied; invoice remains in "pending" status; no email sent to the customer; payment failure recorded in the invoice history. - `initiate_dunning` - prepayments and credits applied to the invoice; invoice status set to "open"; email sent to the customer for the issued invoice (if setting applies); payment failure recorded in the invoice history; subscription will most likely go into "past_due" or "canceled" state (depending upon net terms and dunning settings).

func (*InvoicesController) ListConsolidatedInvoiceSegments added in v0.1.0

ListConsolidatedInvoiceSegments takes context, invoiceUid, page, perPage, direction as parameters and returns an models.ApiResponse with models.ConsolidatedInvoice data and an error if there was an issue with the request or response. Invoice segments returned on the index will only include totals, not detailed breakdowns for `line_items`, `discounts`, `taxes`, `credits`, `payments`, or `custom_fields`.

func (*InvoicesController) ListCreditNotes

ListCreditNotes takes context, subscriptionId, page, perPage, lineItems, discounts, taxes, refunds, applications as parameters and returns an models.ApiResponse with models.ListCreditNotesResponse data and an error if there was an issue with the request or response. Credit Notes are like inverse invoices. They reduce the amount a customer owes. By default, the credit notes returned by this endpoint will exclude the arrays of `line_items`, `discounts`, `taxes`, `applications`, or `refunds`. To include these arrays, pass the specific field as a key in the query with a value set to `true`.

func (*InvoicesController) ListInvoiceEvents

ListInvoiceEvents takes context, sinceDate, sinceId, page, perPage, invoiceUid, withChangeInvoiceStatus, eventTypes as parameters and returns an models.ApiResponse with models.ListInvoiceEventsResponse data and an error if there was an issue with the request or response. This endpoint returns a list of invoice events. Each event contains event "data" (such as an applied payment) as well as a snapshot of the `invoice` at the time of event completion. Exposed event types are: + issue_invoice + apply_credit_note + apply_payment + refund_invoice + void_invoice + void_remainder + backport_invoice + change_invoice_status + change_invoice_collection_method + remove_payment + failed_payment + apply_debit_note + create_debit_note + change_chargeback_status Invoice events are returned in ascending order. If both a `since_date` and `since_id` are provided in request parameters, the `since_date` will be used. Note - invoice events that occurred prior to 09/05/2018 __will not__ contain an `invoice` snapshot.

func (*InvoicesController) ListInvoices

ListInvoices takes context, startDate, endDate, status, subscriptionId, subscriptionGroupUid, page, perPage, direction, lineItems, discounts, taxes, credits, payments, customFields, refunds, dateField, startDatetime, endDatetime, customerIds, number, productIds, sort as parameters and returns an models.ApiResponse with models.ListInvoicesResponse data and an error if there was an issue with the request or response. By default, invoices returned on the index will only include totals, not detailed breakdowns for `line_items`, `discounts`, `taxes`, `credits`, `payments`, `custom_fields`, or `refunds`. To include breakdowns, pass the specific field as a key in the query with a value set to `true`.

func (*InvoicesController) PreviewCustomerInformationChanges

func (i *InvoicesController) PreviewCustomerInformationChanges(
	ctx context.Context,
	uid string) (
	models.ApiResponse[models.CustomerChangesPreviewResponse],
	error)

PreviewCustomerInformationChanges takes context, uid as parameters and returns an models.ApiResponse with models.CustomerChangesPreviewResponse data and an error if there was an issue with the request or response. Customer information may change after an invoice is issued which may lead to a mismatch between customer information that are present on an open invoice and actual customer information. This endpoint allows to preview these differences, if any. The endpoint doesn't accept a request body. Customer information differences are calculated on the application side.

func (*InvoicesController) ReadCreditNote

func (i *InvoicesController) ReadCreditNote(
	ctx context.Context,
	uid string) (
	models.ApiResponse[models.CreditNote],
	error)

ReadCreditNote takes context, uid as parameters and returns an models.ApiResponse with models.CreditNote data and an error if there was an issue with the request or response. Use this endpoint to retrieve the details for a credit note.

func (*InvoicesController) ReadInvoice

ReadInvoice takes context, uid as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. Use this endpoint to retrieve the details for an invoice. ## PDF Invoice retrieval Individual PDF Invoices can be retrieved by using the "Accept" header application/pdf or appending .pdf as the format portion of the URL: ```curl -u <api_key>:x -H Accept:application/pdf -H https://acme.chargify.com/invoices/inv_8gd8tdhtd3hgr.pdf > output_file.pdf URL: `https://<subdomain>.chargify.com/invoices/<uid>.<format>` Method: GET Required parameters: `uid` Response: A single Invoice. ```

func (*InvoicesController) RecordPaymentForInvoice

RecordPaymentForInvoice takes context, uid, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. This API call should be used when you want to record a payment of a given type against a specific invoice. If you would like to apply a payment across multiple invoices, you can use the Bulk Payment endpoint. ## Create a Payment from the existing payment profile In order to apply a payment to an invoice using an existing payment profile, specify `type` as `payment`, the amount less than the invoice total, and the customer's `payment_profile_id`. The ID of a payment profile might be retrieved via the Payment Profiles API endpoint. ``` { "type": "payment", "payment": { "amount": 10.00, "payment_profile_id": 123 } } ``` ## Create a Payment from the Subscription's Prepayment Account In order apply a prepayment to an invoice, specify the `type` as `prepayment`, and also the `amount`. ``` { "type": "prepayment", "payment": { "amount": 10.00 } } ``` Note that the `amount` must be less than or equal to the Subscription's Prepayment account balance. ## Create a Payment from the Subscription's Service Credit Account In order to apply a service credit to an invoice, specify the `type` as `service_credit`, and also the `amount`: ``` { "type": "service_credit", "payment": { "amount": 10.00 } } ``` Note that Chargify will attempt to fully pay the invoice's `due_amount` from the Subscription's Service Credit account. At this time, partial payments from a Service Credit Account are only allowed for consolidated invoices (subscription groups). Therefore, for normal invoices the Service Credit account balance must be greater than or equal to the invoice's `due_amount`.

func (*InvoicesController) RecordPaymentForMultipleInvoices added in v0.1.0

RecordPaymentForMultipleInvoices takes context, body as parameters and returns an models.ApiResponse with models.MultiInvoicePaymentResponse data and an error if there was an issue with the request or response. This API call should be used when you want to record an external payment against multiple invoices. In order apply a payment to multiple invoices, at minimum, specify the `amount` and `applications` (i.e., `invoice_uid` and `amount`) details. ``` { "payment": { "memo": "to pay the bills", "details": "check number 8675309", "method": "check", "amount": "250.00", "applications": [ { "invoice_uid": "inv_8gk5bwkct3gqt", "amount": "100.00" }, { "invoice_uid": "inv_7bc6bwkct3lyt", "amount": "150.00" } ] } } ``` Note that the invoice payment amounts must be greater than 0. Total amount must be greater or equal to invoices payment amount sum.

func (*InvoicesController) RecordPaymentForSubscription

func (i *InvoicesController) RecordPaymentForSubscription(
	ctx context.Context,
	subscriptionId int,
	body *models.RecordPaymentRequest) (
	models.ApiResponse[models.RecordPaymentResponse],
	error)

RecordPaymentForSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.RecordPaymentResponse data and an error if there was an issue with the request or response. Record an external payment made against a subscription that will pay partially or in full one or more invoices. Payment will be applied starting with the oldest open invoice and then next oldest, and so on until the amount of the payment is fully consumed. Excess payment will result in the creation of a prepayment on the Invoice Account. Only ungrouped or primary subscriptions may be paid using the "bulk" payment request.

func (*InvoicesController) RefundInvoice

RefundInvoice takes context, uid, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. Refund an invoice, segment, or consolidated invoice. ## Partial Refund for Consolidated Invoice A refund less than the total of a consolidated invoice will be split across its segments. A $50.00 refund on a $100.00 consolidated invoice with one $60.00 and one $40.00 segment, the refunded amount will be applied as 50% of each ($30.00 and $20.00 respectively).

func (*InvoicesController) ReopenInvoice

func (i *InvoicesController) ReopenInvoice(
	ctx context.Context,
	uid string) (
	models.ApiResponse[models.Invoice],
	error)

ReopenInvoice takes context, uid as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. This endpoint allows you to reopen any invoice with the "canceled" status. Invoices enter "canceled" status if they were open at the time the subscription was canceled (whether through dunning or an intentional cancellation). Invoices with "canceled" status are no longer considered to be due. Once reopened, they are considered due for payment. Payment may then be captured in one of the following ways: - Reactivating the subscription, which will capture all open invoices (See note below about automatic reopening of invoices.) - Recording a payment directly against the invoice A note about reactivations: any canceled invoices from the most recent active period are automatically opened as a part of the reactivation process. Reactivating via this endpoint prior to reactivation is only necessary when you wish to capture older invoices from previous periods during the reactivation. ### Reopening Consolidated Invoices When reopening a consolidated invoice, all of its canceled segments will also be reopened.

func (*InvoicesController) SendInvoice

func (i *InvoicesController) SendInvoice(
	ctx context.Context,
	uid string,
	body *models.SendInvoiceRequest) (
	*http.Response,
	error)

SendInvoice takes context, uid, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This endpoint allows for invoices to be programmatically delivered via email. This endpoint supports the delivery of both ad-hoc and automatically generated invoices. Additionally, this endpoint supports email delivery to direct recipients, carbon-copy (cc) recipients, and blind carbon-copy (bcc) recipients. Please note that if no recipient email addresses are specified in the request, then the subscription's default email configuration will be used. For example, if `recipient_emails` is left blank, then the invoice will be delivered to the subscription's customer email address. On success, a 204 no-content response will be returned. Please note that this does not indicate that email(s) have been delivered, but instead indicates that emails have been successfully queued for delivery. If _any_ invalid or malformed email address is found in the request body, the entire request will be rejected and a 422 response will be returned.

func (*InvoicesController) UpdateCustomerInformation

func (i *InvoicesController) UpdateCustomerInformation(
	ctx context.Context,
	uid string) (
	models.ApiResponse[models.Invoice],
	error)

UpdateCustomerInformation takes context, uid as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. This endpoint updates customer information on an open invoice and returns the updated invoice. If you would like to preview changes that will be applied, use the `/invoices/{uid}/customer_information/preview.json` endpoint before. The endpoint doesn't accept a request body. Customer information differences are calculated on the application side.

func (*InvoicesController) VoidInvoice

VoidInvoice takes context, uid, body as parameters and returns an models.ApiResponse with models.Invoice data and an error if there was an issue with the request or response. This endpoint allows you to void any invoice with the "open" or "canceled" status. It will also allow voiding of an invoice with the "pending" status if it is not a consolidated invoice.

type ListAllComponentPricePointsInput added in v0.1.0

type ListAllComponentPricePointsInput struct {
	// Allows including additional data in the response. Use in query: `include=currency_prices`.
	Include *models.ListComponentsPricePointsInclude
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
	// Filter to use for List PricePoints operations
	Filter *models.ListPricePointsFilter
}

ListAllComponentPricePointsInput represents the input of the ListAllComponentPricePoints endpoint.

type ListAllProductPricePointsInput added in v0.1.0

type ListAllProductPricePointsInput struct {
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
	// Filter to use for List PricePoints operations
	Filter *models.ListPricePointsFilter
	// Allows including additional data in the response. Use in query: `include=currency_prices`.
	Include *models.ListProductsPricePointsInclude
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListAllProductPricePointsInput represents the input of the ListAllProductPricePoints endpoint.

type ListChargifyJsPublicKeysInput added in v0.1.0

type ListChargifyJsPublicKeysInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListChargifyJsPublicKeysInput represents the input of the ListChargifyJsPublicKeys endpoint.

type ListComponentPricePointsInput added in v0.1.0

type ListComponentPricePointsInput struct {
	// The Chargify id of the component
	ComponentId int
	// Include an array of currency price data
	CurrencyPrices *bool
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Use in query: `filter[type]=catalog,default`.
	FilterType []models.PricePointType
}

ListComponentPricePointsInput represents the input of the ListComponentPricePoints endpoint.

type ListComponentsForProductFamilyInput added in v0.1.0

type ListComponentsForProductFamilyInput struct {
	// The Chargify id of the product family
	ProductFamilyId int
	// Include archived items.
	IncludeArchived *bool
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Components operations
	Filter *models.ListComponentsFilter
	// The type of filter you would like to apply to your search. Use in query `date_field=created_at`.
	DateField *models.BasicDateField
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date. optional.
	EndDatetime *string
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
}

ListComponentsForProductFamilyInput represents the input of the ListComponentsForProductFamily endpoint.

type ListComponentsInput added in v0.1.0

type ListComponentsInput struct {
	// The type of filter you would like to apply to your search.
	DateField *models.BasicDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.  optional
	EndDatetime *string
	// Include archived items
	IncludeArchived *bool
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Components operations
	Filter *models.ListComponentsFilter
}

ListComponentsInput represents the input of the ListComponents endpoint.

type ListConsolidatedInvoiceSegmentsInput added in v0.1.0

type ListConsolidatedInvoiceSegmentsInput struct {
	// The unique identifier of the consolidated invoice
	InvoiceUid string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Sort direction of the returned segments.
	Direction *models.Direction
}

ListConsolidatedInvoiceSegmentsInput represents the input of the ListConsolidatedInvoiceSegments endpoint.

type ListCouponSubcodesInput added in v0.1.0

type ListCouponSubcodesInput struct {
	// The Chargify id of the coupon
	CouponId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListCouponSubcodesInput represents the input of the ListCouponSubcodes endpoint.

type ListCouponsForProductFamilyInput added in v0.1.0

type ListCouponsForProductFamilyInput struct {
	// The Chargify id of the product family to which the coupon belongs
	ProductFamilyId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 30. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Coupons operations
	Filter *models.ListCouponsFilter
	// When fetching coupons, if you have defined multiple currencies at the site level, you can optionally pass the `?currency_prices=true` query param to include an array of currency price data in the response. Use in query `currency_prices=true`.
	CurrencyPrices *bool
}

ListCouponsForProductFamilyInput represents the input of the ListCouponsForProductFamily endpoint.

type ListCouponsInput added in v0.1.0

type ListCouponsInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 30. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Coupons operations
	Filter *models.ListCouponsFilter
	// When fetching coupons, if you have defined multiple currencies at the site level, you can optionally pass the `?currency_prices=true` query param to include an array of currency price data in the response. Use in query `currency_prices=true`.
	CurrencyPrices *bool
}

ListCouponsInput represents the input of the ListCoupons endpoint.

type ListCreditNotesInput added in v0.1.0

type ListCreditNotesInput struct {
	// The subscription's Chargify id
	SubscriptionId *int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Include line items data
	LineItems *bool
	// Include discounts data
	Discounts *bool
	// Include taxes data
	Taxes *bool
	// Include refunds data
	Refunds *bool
	// Include applications data
	Applications *bool
}

ListCreditNotesInput represents the input of the ListCreditNotes endpoint.

type ListCustomersInput added in v0.1.0

type ListCustomersInput struct {
	// Direction to sort customers by time of creation
	Direction *models.SortingDirection
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 50. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The type of filter you would like to apply to your search.
	// Use in query: `date_field=created_at`.
	DateField *models.BasicDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns subscriptions with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns subscriptions with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns subscriptions with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns subscriptions with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *string
	// A search query by which to filter customers (can be an email, an ID, a reference, organization)
	Q *string
}

ListCustomersInput represents the input of the ListCustomers endpoint.

type ListEventsInput added in v0.1.0

type ListEventsInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Returns events with an id greater than or equal to the one specified
	SinceId *int64
	// Returns events with an id less than or equal to the one specified
	MaxId *int64
	// The sort direction of the returned events.
	Direction *models.Direction
	// You can pass multiple event keys after comma.
	// Use in query `filter=signup_success,payment_success`.
	Filter []models.EventType
	// The type of filter you would like to apply to your search.
	DateField *models.ListEventsDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *string
}

ListEventsInput represents the input of the ListEvents endpoint.

type ListExportedInvoicesInput added in v0.1.0

type ListExportedInvoicesInput struct {
	// Id of a Batch Job.
	BatchId string
	// This parameter indicates how many records to fetch in each request.
	// Default value is 100.
	// The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000.
	PerPage *int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
}

ListExportedInvoicesInput represents the input of the ListExportedInvoices endpoint.

type ListExportedProformaInvoicesInput added in v0.1.0

type ListExportedProformaInvoicesInput struct {
	// Id of a Batch Job.
	BatchId string
	// This parameter indicates how many records to fetch in each request.
	// Default value is 100.
	// The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000.
	PerPage *int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
}

ListExportedProformaInvoicesInput represents the input of the ListExportedProformaInvoices endpoint.

type ListExportedSubscriptionsInput added in v0.1.0

type ListExportedSubscriptionsInput struct {
	// Id of a Batch Job.
	BatchId string
	// This parameter indicates how many records to fetch in each request.
	// Default value is 100.
	// The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000.
	PerPage *int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
}

ListExportedSubscriptionsInput represents the input of the ListExportedSubscriptions endpoint.

type ListInvoiceEventsInput added in v0.1.0

type ListInvoiceEventsInput struct {
	// The timestamp in a format `YYYY-MM-DD T HH:MM:SS Z`, or `YYYY-MM-DD`(in this case, it returns data from the beginning of the day). of the event from which you want to start the search. All the events before the `since_date` timestamp are not returned in the response.
	SinceDate *string
	// The ID of the event from which you want to start the search(ID is not included. e.g. if ID is set to 2, then all events with ID 3 and more will be shown) This parameter is not used if since_date is defined.
	SinceId *int64
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 100. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	PerPage *int
	// Providing an invoice_uid allows for scoping of the invoice events to a single invoice or credit note.
	InvoiceUid *string
	// Use this parameter if you want to fetch also invoice events with change_invoice_status type.
	WithChangeInvoiceStatus *string
	// Filter results by event_type. Supply a comma separated list of event types (listed above). Use in query: `event_types=void_invoice,void_remainder`.
	EventTypes []models.InvoiceEventType
}

ListInvoiceEventsInput represents the input of the ListInvoiceEvents endpoint.

type ListInvoicesInput added in v0.1.0

type ListInvoicesInput struct {
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns invoices with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns invoices with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The current status of the invoice.  Allowed Values: draft, open, paid, pending, voided
	Status *models.InvoiceStatus
	// The subscription's ID.
	SubscriptionId *int
	// The UID of the subscription group you want to fetch consolidated invoices for. This will return a paginated list of consolidated invoices for the specified group.
	SubscriptionGroupUid *string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The sort direction of the returned invoices.
	Direction *models.Direction
	// Include line items data
	LineItems *bool
	// Include discounts data
	Discounts *bool
	// Include taxes data
	Taxes *bool
	// Include credits data
	Credits *bool
	// Include payments data
	Payments *bool
	// Include custom fields data
	CustomFields *bool
	// Include refunds data
	Refunds *bool
	// The type of filter you would like to apply to your search. Use in query `date_field=issue_date`.
	DateField *models.InvoiceDateField
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns invoices with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date. Allowed to be used only along with date_field set to created_at or updated_at.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns invoices with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date. Allowed to be used only along with date_field set to created_at or updated_at.
	EndDatetime *string
	// Allows fetching invoices with matching customer id based on provided values. Use in query `customer_ids=1,2,3`.
	CustomerIds []int
	// Allows fetching invoices with matching invoice number based on provided values. Use in query `number=1234,1235`.
	Number []string
	// Allows fetching invoices with matching line items product ids based on provided values. Use in query `product_ids=23,34`.
	ProductIds []int
	// Allows specification of the order of the returned list. Use in query `sort=total_amount`.
	Sort *models.InvoiceSortField
}

ListInvoicesInput represents the input of the ListInvoices endpoint.

type ListMetadataForResourceTypeInput added in v0.1.0

type ListMetadataForResourceTypeInput struct {
	// the resource type to which the metafields belong
	ResourceType models.ResourceType
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The type of filter you would like to apply to your search.
	DateField *models.BasicDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns metadata with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *time.Time
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns metadata with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *time.Time
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns metadata with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *time.Time
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns metadata with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *time.Time
	// Allow to fetch deleted metadata.
	WithDeleted *bool
	// Allow to fetch metadata for multiple records based on provided ids. Use in query: `resource_ids[]=122&resource_ids[]=123&resource_ids[]=124`.
	ResourceIds []int
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
}

ListMetadataForResourceTypeInput represents the input of the ListMetadataForResourceType endpoint.

type ListMetadataInput added in v0.1.0

type ListMetadataInput struct {
	// the resource type to which the metafields belong
	ResourceType models.ResourceType
	// The Chargify id of the customer or the subscription for which the metadata applies
	ResourceId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListMetadataInput represents the input of the ListMetadata endpoint.

type ListMetafieldsInput added in v0.1.0

type ListMetafieldsInput struct {
	// the resource type to which the metafields belong
	ResourceType models.ResourceType
	// filter by the name of the metafield
	Name *string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
}

ListMetafieldsInput represents the input of the ListMetafields endpoint.

type ListMrrMovementsInput added in v0.1.0

type ListMrrMovementsInput struct {
	// optionally filter results by subscription
	SubscriptionId *int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 10. The maximum allowed values is 50; any per_page value over 50 will be changed to 50.
	// Use in query `per_page=20`.
	PerPage *int
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
}

ListMrrMovementsInput represents the input of the ListMrrMovements endpoint.

type ListMrrPerSubscriptionInput added in v0.1.0

type ListMrrPerSubscriptionInput struct {
	// Filter to use for List MRR per subscription operation
	Filter *models.ListMrrFilter
	// Submit a timestamp in ISO8601 format to request MRR for a historic time. Use in query: `at_time=2022-01-10T10:00:00-05:00`.
	AtTime *string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Controls the order in which results are returned. Records are ordered by subscription_id in ascending order by default. Use in query `direction=desc`.
	Direction *models.Direction
}

ListMrrPerSubscriptionInput represents the input of the ListMrrPerSubscription endpoint.

type ListOffersInput added in v0.1.0

type ListOffersInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Include archived products. Use in query: `include_archived=true`.
	IncludeArchived *bool
}

ListOffersInput represents the input of the ListOffers endpoint.

type ListPaymentProfilesInput added in v0.1.0

type ListPaymentProfilesInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The ID of the customer for which you wish to list payment profiles
	CustomerId *int
}

ListPaymentProfilesInput represents the input of the ListPaymentProfiles endpoint.

type ListPrepaymentsForSubscriptionGroupInput added in v0.1.0

type ListPrepaymentsForSubscriptionGroupInput struct {
	// The uid of the subscription group
	Uid string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Prepayments operations
	Filter *models.ListPrepaymentsFilter
}

ListPrepaymentsForSubscriptionGroupInput represents the input of the ListPrepaymentsForSubscriptionGroup endpoint.

type ListPrepaymentsInput added in v0.1.0

type ListPrepaymentsInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Prepayments operations
	Filter *models.ListPrepaymentsFilter
}

ListPrepaymentsInput represents the input of the ListPrepayments endpoint.

type ListProductFamiliesInput added in v0.1.0

type ListProductFamiliesInput struct {
	// The type of filter you would like to apply to your search.
	// Use in query: `date_field=created_at`.
	DateField *models.BasicDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *string
}

ListProductFamiliesInput represents the input of the ListProductFamilies endpoint.

type ListProductPricePointsInput added in v0.1.0

type ListProductPricePointsInput struct {
	// The id or handle of the product. When using the handle, it must be prefixed with `handle:`
	ProductId models.ListProductPricePointsInputProductId
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 10. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	PerPage *int
	// When fetching a product's price points, if you have defined multiple currencies at the site level, you can optionally pass the ?currency_prices=true query param to include an array of currency price data in the response. If the product price point is set to use_site_exchange_rate: true, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency.
	CurrencyPrices *bool
	// Use in query: `filter[type]=catalog,default`.
	FilterType []models.PricePointType
}

ListProductPricePointsInput represents the input of the ListProductPricePoints endpoint.

type ListProductsForProductFamilyInput added in v0.1.0

type ListProductsForProductFamilyInput struct {
	// The Chargify id of the product family to which the product belongs
	ProductFamilyId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The type of filter you would like to apply to your search.
	// Use in query: `date_field=created_at`.
	DateField *models.BasicDateField
	// Filter to use for List Products operations
	Filter *models.ListProductsFilter
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *string
	// Include archived products
	IncludeArchived *bool
	// Allows including additional data in the response. Use in query `include=prepaid_product_price_point`.
	Include *models.ListProductsInclude
}

ListProductsForProductFamilyInput represents the input of the ListProductsForProductFamily endpoint.

type ListProductsInput added in v0.1.0

type ListProductsInput struct {
	// The type of filter you would like to apply to your search.
	// Use in query: `date_field=created_at`.
	DateField *models.BasicDateField
	// Filter to use for List Products operations
	Filter *models.ListProductsFilter
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *time.Time
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *time.Time
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns products with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *time.Time
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns products with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *time.Time
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Include archived products. Use in query: `include_archived=true`.
	IncludeArchived *bool
	// Allows including additional data in the response. Use in query `include=prepaid_product_price_point`.
	Include *models.ListProductsInclude
}

ListProductsInput represents the input of the ListProducts endpoint.

type ListProformaInvoicesInput added in v0.1.0

type ListProformaInvoicesInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// The beginning date range for the invoice's Due Date, in the YYYY-MM-DD format.
	StartDate *string
	// The ending date range for the invoice's Due Date, in the YYYY-MM-DD format.
	EndDate *string
	// The current status of the invoice.  Allowed Values: draft, open, paid, pending, voided
	Status *models.ProformaInvoiceStatus
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The sort direction of the returned invoices.
	Direction *models.Direction
	// Include line items data
	LineItems *bool
	// Include discounts data
	Discounts *bool
	// Include taxes data
	Taxes *bool
	// Include credits data
	Credits *bool
	// Include payments data
	Payments *bool
	// Include custom fields data
	CustomFields *bool
}

ListProformaInvoicesInput represents the input of the ListProformaInvoices endpoint.

type ListReasonCodesInput added in v0.1.0

type ListReasonCodesInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListReasonCodesInput represents the input of the ListReasonCodes endpoint.

type ListSalesCommissionSettingsInput added in v0.1.0

type ListSalesCommissionSettingsInput struct {
	// The Chargify id of your seller account
	SellerId string
	// For authorization use user API key. See details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication).
	Authorization *string
	// This parameter indicates if records should be fetched from live mode sites. Default value is true.
	LiveMode *bool
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 100.
	PerPage *int
}

ListSalesCommissionSettingsInput represents the input of the ListSalesCommissionSettings endpoint.

type ListSalesRepsInput added in v0.1.0

type ListSalesRepsInput struct {
	// The Chargify id of your seller account
	SellerId string
	// For authorization use user API key. See details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication).
	Authorization *string
	// This parameter indicates if records should be fetched from live mode sites. Default value is true.
	LiveMode *bool
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 100.
	PerPage *int
}

ListSalesRepsInput represents the input of the ListSalesReps endpoint.

type ListSegmentsForPricePointInput added in v0.1.0

type ListSegmentsForPricePointInput struct {
	// ID or Handle for the Component
	ComponentId string
	// ID or Handle for the Price Point belonging to the Component
	PricePointId string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 30. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Filter to use for List Segments for a Price Point operation
	Filter *models.ListSegmentsFilter
}

ListSegmentsForPricePointInput represents the input of the ListSegmentsForPricePoint endpoint.

type ListSubscriptionComponentsForSiteInput added in v0.1.0

type ListSubscriptionComponentsForSiteInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The attribute by which to sort. Use in query: `sort=updated_at`.
	Sort *models.ListSubscriptionComponentsSort
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
	// Filter to use for List Subscription Components For Site operation
	Filter *models.ListSubscriptionComponentsForSiteFilter
	// The type of filter you'd like to apply to your search. Use in query: `date_field=updated_at`.
	DateField *models.SubscriptionListDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query `start_date=2011-12-15`.
	StartDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of start_date. Use in query `start_datetime=2022-07-01 09:00:05`.
	StartDatetime *string
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query `end_date=2011-12-16`.
	EndDate *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of end_date. Use in query `end_datetime=2022-07-01 09:00:05`.
	EndDatetime *string
	// Allows fetching components allocation with matching subscription id based on provided ids. Use in query `subscription_ids=1,2,3`.
	SubscriptionIds []int
	// Allows fetching components allocation only if price point id is present. Use in query `price_point_ids=not_null`.
	PricePointIds *models.IncludeNotNull
	// Allows fetching components allocation with matching product family id based on provided ids. Use in query `product_family_ids=1,2,3`.
	ProductFamilyIds []int
	// Allows including additional data in the response. Use in query `include=subscription,historic_usages`.
	Include *models.ListSubscriptionComponentsInclude
}

ListSubscriptionComponentsForSiteInput represents the input of the ListSubscriptionComponentsForSite endpoint.

type ListSubscriptionComponentsInput added in v0.1.0

type ListSubscriptionComponentsInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// The type of filter you'd like to apply to your search. Use in query `date_field=updated_at`.
	DateField *models.SubscriptionListDateField
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
	// Filter to use for List Subscription Components operation
	Filter *models.ListSubscriptionComponentsFilter
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified.
	EndDate *string
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of end_date.
	EndDatetime *string
	// Allows fetching components allocation only if price point id is present. Use in query `price_point_ids=not_null`.
	PricePointIds *models.IncludeNotNull
	// Allows fetching components allocation with matching product family id based on provided ids. Use in query `product_family_ids=1,2,3`.
	ProductFamilyIds []int
	// The attribute by which to sort. Use in query `sort=updated_at`.
	Sort *models.ListSubscriptionComponentsSort
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified.
	StartDate *string
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site”s time zone will be used. If provided, this parameter will be used instead of start_date.
	StartDatetime *string
	// Allows including additional data in the response. Use in query `include=subscription,historic_usages`.
	Include []models.ListSubscriptionComponentsInclude
	// If in_use is set to true, it returns only components that are currently in use. However, if it's set to false or not provided, it returns all components connected with the subscription.
	InUse *bool
}

ListSubscriptionComponentsInput represents the input of the ListSubscriptionComponents endpoint.

type ListSubscriptionEventsInput added in v0.1.0

type ListSubscriptionEventsInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Returns events with an id greater than or equal to the one specified
	SinceId *int64
	// Returns events with an id less than or equal to the one specified
	MaxId *int64
	// The sort direction of the returned events.
	Direction *models.Direction
	// You can pass multiple event keys after comma.
	// Use in query `filter=signup_success,payment_success`.
	Filter []models.EventType
}

ListSubscriptionEventsInput represents the input of the ListSubscriptionEvents endpoint.

type ListSubscriptionGroupProformaInvoicesInput added in v0.1.0

type ListSubscriptionGroupProformaInvoicesInput struct {
	// The uid of the subscription group
	Uid string
	// Include line items data
	LineItems *bool
	// Include discounts data
	Discounts *bool
	// Include taxes data
	Taxes *bool
	// Include credits data
	Credits *bool
	// Include payments data
	Payments *bool
	// Include custom fields data
	CustomFields *bool
}

ListSubscriptionGroupProformaInvoicesInput represents the input of the ListSubscriptionGroupProformaInvoices endpoint.

type ListSubscriptionGroupsInput added in v0.1.0

type ListSubscriptionGroupsInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// A list of additional information to include in the response. The following values are supported:
	// - `account_balances`: Account balance information for the subscription groups. Use in query: `include[]=account_balances`
	Include []models.SubscriptionGroupsListInclude
}

ListSubscriptionGroupsInput represents the input of the ListSubscriptionGroups endpoint.

type ListSubscriptionNotesInput added in v0.1.0

type ListSubscriptionNotesInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListSubscriptionNotesInput represents the input of the ListSubscriptionNotes endpoint.

type ListSubscriptionsInput added in v0.1.0

type ListSubscriptionsInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The current state of the subscription
	State *models.SubscriptionStateFilter
	// The product id of the subscription. (Note that the product handle cannot be used.)
	Product *int
	// The ID of the product price point. If supplied, product is required
	ProductPricePointId *int
	// The numeric id of the coupon currently applied to the subscription. (This can be found in the URL when editing a coupon. Note that the coupon code cannot be used.)
	Coupon *int
	// The type of filter you'd like to apply to your search.  Allowed Values: , current_period_ends_at, current_period_starts_at, created_at, activated_at, canceled_at, expires_at, trial_started_at, trial_ended_at, updated_at
	DateField *models.SubscriptionDateField
	// The start date (format YYYY-MM-DD) with which to filter the date_field. Returns subscriptions with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query `start_date=2022-07-01`.
	StartDate *time.Time
	// The end date (format YYYY-MM-DD) with which to filter the date_field. Returns subscriptions with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query `end_date=2022-08-01`.
	EndDate *time.Time
	// The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns subscriptions with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of start_date. Use in query `start_datetime=2022-07-01 09:00:05`.
	StartDatetime *time.Time
	// The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns subscriptions with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date. Use in query `end_datetime=2022-08-01 10:00:05`.
	EndDatetime *time.Time
	// The value of the metadata field specified in the parameter. Use in query `metadata[my-field]=value&metadata[other-field]=another_value`.
	Metadata map[string]string
	// Controls the order in which results are returned.
	// Use in query `direction=asc`.
	Direction *models.SortingDirection
	// The attribute by which to sort
	Sort *models.SubscriptionSort
	// Allows including additional data in the response. Use in query: `include[]=self_service_page_token`.
	Include []models.SubscriptionListInclude
}

ListSubscriptionsInput represents the input of the ListSubscriptions endpoint.

type ListUsagesInput added in v0.1.0

type ListUsagesInput struct {
	// The Chargify id of the subscription
	SubscriptionId int
	// Either the Chargify id for the component or the component's handle prefixed by `handle:`
	ComponentId models.ListUsagesInputComponentId
	// Returns usages with an id greater than or equal to the one specified
	SinceId *int64
	// Returns usages with an id less than or equal to the one specified
	MaxId *int64
	// Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the date specified.
	SinceDate *time.Time
	// Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date specified.
	UntilDate *time.Time
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
}

ListUsagesInput represents the input of the ListUsages endpoint.

type ListWebhooksInput added in v0.1.0

type ListWebhooksInput struct {
	// Webhooks with matching status would be returned.
	Status *models.WebhookStatus
	// Format YYYY-MM-DD. Returns Webhooks with the created_at date greater than or equal to the one specified.
	SinceDate *string
	// Format YYYY-MM-DD. Returns Webhooks with the created_at date less than or equal to the one specified.
	UntilDate *string
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// The order in which the Webhooks are returned.
	Order *models.WebhookOrder
	// The Chargify id of a subscription you'd like to filter for
	Subscription *int
}

ListWebhooksInput represents the input of the ListWebhooks endpoint.

type OffersController

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

OffersController represents a controller struct.

func NewOffersController

func NewOffersController(baseController baseController) *OffersController

NewOffersController creates a new instance of OffersController. It takes a baseController as a parameter and returns a pointer to the OffersController.

func (*OffersController) ArchiveOffer

func (o *OffersController) ArchiveOffer(
	ctx context.Context,
	offerId int) (
	*http.Response,
	error)

ArchiveOffer takes context, offerId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Archive an existing offer. Please provide an `offer_id` in order to archive the correct item.

func (*OffersController) CreateOffer

CreateOffer takes context, body as parameters and returns an models.ApiResponse with models.OfferResponse data and an error if there was an issue with the request or response. Create an offer within your Chargify site by sending a POST request. ## Documentation Offers allow you to package complicated combinations of products, components and coupons into a convenient package which can then be subscribed to just like products. Once an offer is defined it can be used as an alternative to the product when creating subscriptions. Full documentation on how to use offers in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407753852059). ## Using a Product Price Point You can optionally pass in a `product_price_point_id` that corresponds with the `product_id` and the offer will use that price point. If a `product_price_point_id` is not passed in, the product's default price point will be used.

func (*OffersController) ListOffers

ListOffers takes context, page, perPage, includeArchived as parameters and returns an models.ApiResponse with models.ListOffersResponse data and an error if there was an issue with the request or response. This endpoint will list offers for a site.

func (*OffersController) ReadOffer added in v0.1.0

func (o *OffersController) ReadOffer(
	ctx context.Context,
	offerId int) (
	models.ApiResponse[models.OfferResponse],
	error)

ReadOffer takes context, offerId as parameters and returns an models.ApiResponse with models.OfferResponse data and an error if there was an issue with the request or response. This method allows you to list a specific offer's attributes. This is different than list all offers for a site, as it requires an `offer_id`.

func (*OffersController) UnarchiveOffer

func (o *OffersController) UnarchiveOffer(
	ctx context.Context,
	offerId int) (
	*http.Response,
	error)

UnarchiveOffer takes context, offerId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Unarchive a previously archived offer. Please provide an `offer_id` in order to un-archive the correct item.

type PaymentProfilesController

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

PaymentProfilesController represents a controller struct.

func NewPaymentProfilesController

func NewPaymentProfilesController(baseController baseController) *PaymentProfilesController

NewPaymentProfilesController creates a new instance of PaymentProfilesController. It takes a baseController as a parameter and returns a pointer to the PaymentProfilesController.

func (*PaymentProfilesController) ChangeSubscriptionDefaultPaymentProfile added in v0.1.0

func (p *PaymentProfilesController) ChangeSubscriptionDefaultPaymentProfile(
	ctx context.Context,
	subscriptionId int,
	paymentProfileId int) (
	models.ApiResponse[models.PaymentProfileResponse],
	error)

ChangeSubscriptionDefaultPaymentProfile takes context, subscriptionId, paymentProfileId as parameters and returns an models.ApiResponse with models.PaymentProfileResponse data and an error if there was an issue with the request or response. This will change the default payment profile on the subscription to the existing payment profile with the id specified. You must elect to change the existing payment profile to a new payment profile ID in order to receive a satisfactory response from this endpoint.

func (*PaymentProfilesController) ChangeSubscriptionGroupDefaultPaymentProfile added in v0.1.0

func (p *PaymentProfilesController) ChangeSubscriptionGroupDefaultPaymentProfile(
	ctx context.Context,
	uid string,
	paymentProfileId int) (
	models.ApiResponse[models.PaymentProfileResponse],
	error)

ChangeSubscriptionGroupDefaultPaymentProfile takes context, uid, paymentProfileId as parameters and returns an models.ApiResponse with models.PaymentProfileResponse data and an error if there was an issue with the request or response. This will change the default payment profile on the subscription group to the existing payment profile with the id specified. You must elect to change the existing payment profile to a new payment profile ID in order to receive a satisfactory response from this endpoint. The new payment profile must belong to the subscription group's customer, otherwise you will receive an error.

func (*PaymentProfilesController) CreatePaymentProfile

CreatePaymentProfile takes context, body as parameters and returns an models.ApiResponse with models.PaymentProfileResponse data and an error if there was an issue with the request or response. Use this endpoint to create a payment profile for a customer. Payment Profiles house the credit card, ACH (Authorize.Net or Stripe only,) or PayPal (Braintree only,) data for a customer. The payment information is attached to the customer within Chargify, as opposed to the Subscription itself. You must include a customer_id so that Chargify will attach it to the customer entry. If no customer_id is included the API will return a 404. ## Create a Payment Profile for ACH usage If you would like to create a payment method that is a Bank Account applicable for ACH payments use the following: ```json { "payment_profile": { "customer_id": [Valid-Customer-ID], "bank_name": "Best Bank", "bank_routing_number": "021000089", "bank_account_number": "111111111111", "bank_account_type": "checking", "bank_account_holder_type": "business", "payment_type": "bank_account" } } ``` ## Taxable Subscriptions If your subscriber pays taxes on their purchased product, and you are attempting to create or update the `payment_profile`, complete address information is required. For information on required address formatting to allow your subscriber to be taxed, please see our documentation [here](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) ## Payment Profile Documentation Full documentation on how Payment Profiles operate within Chargify can be located under the following links: + [Subscriber Payment Details](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405212558349-Customers-Reference#customers-reference-0-0) + [Self Service Pages](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404759627021) (Allows credit card updates by Subscriber) + [Public Signup Pages payment settings](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405267754381-Individual-Page-Settings#credit-card-settings) ## Create a Payment Profile with a Chargify.js token ```json { "payment_profile": { "customer_id": 1036, "chargify_token": "tok_w68qcpnftyv53jk33jv6wk3w" } } ``` ## Active Payment Methods Creating a new payment profile for a Customer via the API will not make that Payment Profile current for any of the Customer’s Subscriptions. In order to utilize the payment profile as the default, it must be set as the default payment profile for the subscription or subscription group. ## Requirements Either the full_number, expiration_month, and expiration_year or if you have an existing vault_token from your gateway, that vault_token and the current_vault are required. Passing in the vault_token and current_vault are only allowed when creating a new payment profile. ### Taxable Subscriptions If your subscriber pays taxes on their purchased product, and you are attempting to create or update the `payment_profile`, complete address information is required. For information on required address formatting to allow your subscriber to be taxed, please see our documentation [here](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) ## BraintreeBlue Some merchants use Braintree JavaScript libraries directly and then pass `payment_method_nonce` and/or `paypal_email` to create a payment profile. This implementation is deprecated and does not handle 3D Secure. Instead, we have provided [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview) which is continuously improved and supports Credit Cards (along with 3D Secure), PayPal and ApplePay payment types. ## GoCardless For more information on GoCardless, please view the following resources: + [Full documentation on GoCardless](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404501889677) + [Using Chargify.js with GoCardless - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) + [Using Chargify.js with GoCardless - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) ### GoCardless with Local Bank Details Following examples create customer, bank account and mandate in GoCardless: ```json { "payment_profile": { "customer_id": "Valid-Customer-ID", "bank_name": "Royal Bank of France", "bank_account_number": "0000000", "bank_routing_number": "0003", "bank_branch_code": "00006", "payment_type": "bank_account", "billing_address": "20 Place de la Gare", "billing_city": "Colombes", "billing_state": "Île-de-France", "billing_zip": "92700", "billing_country": "FR" } } ``` ### GoCardless with IBAN ```json { "payment_profile": { "customer_id": "24907598", "bank_name": "French Bank", "bank_iban": "FR1420041010050500013M02606", "payment_type": "bank_account", "billing_address": "20 Place de la Gare", "billing_city": "Colombes", "billing_state": "Île-de-France", "billing_zip": "92700", "billing_country": "FR" } } ``` ### Importing GoCardless If the customer, bank account, and mandate already exist in GoCardless, a payment profile can be created by using the IDs. In order to create masked versions of `bank_account_number` and `bank_routing_number` that are used to display within Chargify Admin UI, you can pass the last four digits for this fields which then will be saved in this form `XXXX[four-provided-digits]`. ```json { "payment_profile": { "customer_id": "24907598", "customer_vault_token": [Existing GoCardless Customer ID] "vault_token": [Existing GoCardless Mandate ID], "current_vault": "gocardless", "bank_name": "French Bank", "bank_account_number": [Last Four Of The Existing Account Number or IBAN if applicable], "bank_routing_number": [Last Four Of The Existing Routing Number], "payment_type": "bank_account", "billing_address": "20 Place de la Gare", "billing_city": "Colombes", "billing_state": "Île-de-France", "billing_zip": "92700", "billing_country": "FR" } } ``` ## SEPA Direct Debit For more information on Stripe SEPA Direct Debit, please view the following resources: + [Full documentation on Stripe SEPA Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) + [Using Chargify.js with Stripe Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + [Using Chargify.js with Stripe Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) ### Stripe SEPA Direct Debit Payment Profiles The following example creates a customer, bank account and mandate in Stripe: ```json { "payment_profile": { "customer_id": "24907598", "bank_name": "Deutsche bank", "bank_iban": "DE89370400440532013000", "payment_type": "bank_account", "billing_address": "Test", "billing_city": "Berlin", "billing_state": "Brandenburg", "billing_zip": "12345", "billing_country": "DE" } } ``` ## Stripe BECS Direct Debit For more information on Stripe BECS Direct Debit, please view the following resources: + [Full documentation on Stripe BECS Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) + [Using Chargify.js with Stripe BECS Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + [Using Chargify.js with Stripe BECS Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) ### Stripe BECS Direct Debit Payment Profiles The following example creates a customer, bank account and mandate in Stripe: ```json { "payment_profile": { "customer_id": "24907598", "bank_name": "Australian bank", "bank_branch_code": "000000", "bank_account_number": "000123456" "payment_type": "bank_account", "billing_address": "Test", "billing_city": "Stony Rise", "billing_state": "Tasmania", "billing_zip": "12345", "billing_country": "AU" } } ``` ## Stripe BACS Direct Debit Contact the support team to enable this payment method. For more information on Stripe BACS Direct Debit, please view the following resources: + [Full documentation on Stripe BACS Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) ### Stripe BACS Direct Debit Payment Profiles The following example creates a customer, bank account and mandate in Stripe: ```json { "payment_profile": { "customer_id": "24907598", "bank_name": "British bank", "bank_branch_code": "108800", "bank_account_number": "00012345" "payment_type": "bank_account", "billing_address": "Test", "billing_city": "London", "billing_state": "LND", "billing_zip": "12345", "billing_country": "GB" } } ``` ## 3D Secure - Checkout It may happen that a payment needs 3D Secure Authentication when the payment profile is created; this is referred to in our help docs as a [post-authentication flow](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405177432077#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: ```json { "jsonapi": { "version": "1.0" }, "errors": [ { "title": "This card requires 3DSecure verification.", "detail": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu?one_time_token_id=93&callback_url=http://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after credit card is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", "links": { "action_link": "https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu?one_time_token_id=93" } } ] } ``` To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - whether the authentication was successful (`success`) - the payment profile ID (`payment_profile_id`) Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like to redirect a customer back to your site. It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. The final URL that you send a customer to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu?one_time_token_id=93&callback_url=http://localhost:4000&redirect_url=https://yourpage.com` ### Example Redirect Flow You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: 1. Create a payment profile via API; it requires 3DS 2. You receive a `action_link` in the response. 3. Use this `action_link` to, for example, connect with your internal resources or generate a session_id 4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied 6. After the customer finishes 3DS authentication, we let you know the result by making a request to applied `callback_url`. 7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was successful or not

func (*PaymentProfilesController) DeleteSubscriptionGroupPaymentProfile

func (p *PaymentProfilesController) DeleteSubscriptionGroupPaymentProfile(
	ctx context.Context,
	uid string,
	paymentProfileId int) (
	*http.Response,
	error)

DeleteSubscriptionGroupPaymentProfile takes context, uid, paymentProfileId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This will delete a Payment Profile belonging to a Subscription Group. **Note**: If the Payment Profile belongs to multiple Subscription Groups and/or Subscriptions, it will be removed from all of them.

func (*PaymentProfilesController) DeleteSubscriptionsPaymentProfile

func (p *PaymentProfilesController) DeleteSubscriptionsPaymentProfile(
	ctx context.Context,
	subscriptionId int,
	paymentProfileId int) (
	*http.Response,
	error)

DeleteSubscriptionsPaymentProfile takes context, subscriptionId, paymentProfileId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This will delete a payment profile belonging to the customer on the subscription. + If the customer has multiple subscriptions, the payment profile will be removed from all of them. + If you delete the default payment profile for a subscription, you will need to specify another payment profile to be the default through the api, or either prompt the user to enter a card in the billing portal or on the self-service page, or visit the Payment Details tab on the subscription in the Admin UI and use the “Add New Credit Card” or “Make Active Payment Method” link, (depending on whether there are other cards present).

func (*PaymentProfilesController) DeleteUnusedPaymentProfile

func (p *PaymentProfilesController) DeleteUnusedPaymentProfile(
	ctx context.Context,
	paymentProfileId int) (
	*http.Response,
	error)

DeleteUnusedPaymentProfile takes context, paymentProfileId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Deletes an unused payment profile. If the payment profile is in use by one or more subscriptions or groups, a 422 and error message will be returned.

func (*PaymentProfilesController) ListPaymentProfiles

ListPaymentProfiles takes context, page, perPage, customerId as parameters and returns an models.ApiResponse with []models.PaymentProfileResponse data and an error if there was an issue with the request or response. This method will return all of the active `payment_profiles` for a Site, or for one Customer within a site. If no payment profiles are found, this endpoint will return an empty array, not a 404.

func (*PaymentProfilesController) ReadOneTimeToken

ReadOneTimeToken takes context, chargifyToken as parameters and returns an models.ApiResponse with models.GetOneTimeTokenRequest data and an error if there was an issue with the request or response. One Time Tokens aka Chargify Tokens house the credit card or ACH (Authorize.Net or Stripe only) data for a customer. You can use One Time Tokens while creating a subscription or payment profile instead of passing all bank account or credit card data directly to a given API endpoint. To obtain a One Time Token you have to use [chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview).

func (*PaymentProfilesController) ReadPaymentProfile

func (p *PaymentProfilesController) ReadPaymentProfile(
	ctx context.Context,
	paymentProfileId int) (
	models.ApiResponse[models.PaymentProfileResponse],
	error)

ReadPaymentProfile takes context, paymentProfileId as parameters and returns an models.ApiResponse with models.PaymentProfileResponse data and an error if there was an issue with the request or response. Using the GET method you can retrieve a Payment Profile identified by its unique ID. Please note that a different JSON object will be returned if the card method on file is a bank account. ### Response for Bank Account Example response for Bank Account: ``` { "payment_profile": { "id": 10089892, "first_name": "Chester", "last_name": "Tester", "customer_id": 14543792, "current_vault": "bogus", "vault_token": "0011223344", "billing_address": "456 Juniper Court", "billing_city": "Boulder", "billing_state": "CO", "billing_zip": "80302", "billing_country": "US", "customer_vault_token": null, "billing_address_2": "", "bank_name": "Bank of Kansas City", "masked_bank_routing_number": "XXXX6789", "masked_bank_account_number": "XXXX3344", "bank_account_type": "checking", "bank_account_holder_type": "personal", "payment_type": "bank_account", "site_gateway_setting_id": 1, "gateway_handle": null } } ```

func (*PaymentProfilesController) SendRequestUpdatePaymentEmail

func (p *PaymentProfilesController) SendRequestUpdatePaymentEmail(
	ctx context.Context,
	subscriptionId int) (
	*http.Response,
	error)

SendRequestUpdatePaymentEmail takes context, subscriptionId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. You can send a "request payment update" email to the customer associated with the subscription. If you attempt to send a "request payment update" email more than five times within a 30-minute period, you will receive a `422` response with an error message in the body. This error message will indicate that the request has been rejected due to excessive attempts, and will provide instructions on how to resubmit the request. Additionally, if you attempt to send a "request payment update" email for a subscription that does not exist, you will receive a `404` error response. This error message will indicate that the subscription could not be found, and will provide instructions on how to correct the error and resubmit the request. These error responses are designed to prevent excessive or invalid requests, and to provide clear and helpful information to users who encounter errors during the request process.

func (*PaymentProfilesController) UpdatePaymentProfile

UpdatePaymentProfile takes context, paymentProfileId, body as parameters and returns an models.ApiResponse with models.PaymentProfileResponse data and an error if there was an issue with the request or response. ## Partial Card Updates In the event that you are using the Authorize.net, Stripe, Cybersource, Forte or Braintree Blue payment gateways, you can update just the billing and contact information for a payment method. Note the lack of credit-card related data contained in the JSON payload. In this case, the following JSON is acceptable: ``` { "payment_profile": { "first_name": "Kelly", "last_name": "Test", "billing_address": "789 Juniper Court", "billing_city": "Boulder", "billing_state": "CO", "billing_zip": "80302", "billing_country": "US", "billing_address_2": null } } ``` The result will be that you have updated the billing information for the card, yet retained the original card number data. ## Specific notes on updating payment profiles - Merchants with **Authorize.net**, **Cybersource**, **Forte**, **Braintree Blue** or **Stripe** as their payment gateway can update their Customer’s credit cards without passing in the full credit card number and CVV. - If you are using **Authorize.net**, **Cybersource**, **Forte**, **Braintree Blue** or **Stripe**, Chargify will ignore the credit card number and CVV when processing an update via the API, and attempt a partial update instead. If you wish to change the card number on a payment profile, you will need to create a new payment profile for the given customer. - A Payment Profile cannot be updated with the attributes of another type of Payment Profile. For example, if the payment profile you are attempting to update is a credit card, you cannot pass in bank account attributes (like `bank_account_number`), and vice versa. - Updating a payment profile directly will not trigger an attempt to capture a past-due balance. If this is the intent, update the card details via the Subscription instead. - If you are using Authorize.net or Stripe, you may elect to manually trigger a retry for a past due subscription after a partial update.

func (*PaymentProfilesController) VerifyBankAccount

VerifyBankAccount takes context, bankAccountId, body as parameters and returns an models.ApiResponse with models.BankAccountResponse data and an error if there was an issue with the request or response. Submit the two small deposit amounts the customer received in their bank account in order to verify the bank account. (Stripe only)

type ProductFamiliesController

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

ProductFamiliesController represents a controller struct.

func NewProductFamiliesController

func NewProductFamiliesController(baseController baseController) *ProductFamiliesController

NewProductFamiliesController creates a new instance of ProductFamiliesController. It takes a baseController as a parameter and returns a pointer to the ProductFamiliesController.

func (*ProductFamiliesController) CreateProductFamily

CreateProductFamily takes context, body as parameters and returns an models.ApiResponse with models.ProductFamilyResponse data and an error if there was an issue with the request or response. This method will create a Product Family within your Chargify site. Create a Product Family to act as a container for your products, components and coupons. Full documentation on how Product Families operate within the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405369633421).

func (*ProductFamiliesController) ListProductFamilies

ListProductFamilies takes context, dateField, startDate, endDate, startDatetime, endDatetime as parameters and returns an models.ApiResponse with []models.ProductFamilyResponse data and an error if there was an issue with the request or response. This method allows to retrieve a list of Product Families for a site.

func (*ProductFamiliesController) ListProductsForProductFamily

ListProductsForProductFamily takes context, productFamilyId, page, perPage, dateField, filter, startDate, endDate, startDatetime, endDatetime, includeArchived, include as parameters and returns an models.ApiResponse with []models.ProductResponse data and an error if there was an issue with the request or response. This method allows to retrieve a list of Products belonging to a Product Family.

func (*ProductFamiliesController) ReadProductFamily

ReadProductFamily takes context, id as parameters and returns an models.ApiResponse with models.ProductFamilyResponse data and an error if there was an issue with the request or response. This method allows to retrieve a Product Family via the `product_family_id`. The response will contain a Product Family object. The product family can be specified either with the id number, or with the `handle:my-family` format.

type ProductPricePointsController

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

ProductPricePointsController represents a controller struct.

func NewProductPricePointsController

func NewProductPricePointsController(baseController baseController) *ProductPricePointsController

NewProductPricePointsController creates a new instance of ProductPricePointsController. It takes a baseController as a parameter and returns a pointer to the ProductPricePointsController.

func (*ProductPricePointsController) ArchiveProductPricePoint

ArchiveProductPricePoint takes context, productId, pricePointId as parameters and returns an models.ApiResponse with models.ProductPricePointResponse data and an error if there was an issue with the request or response. Use this endpoint to archive a product price point.

func (*ProductPricePointsController) BulkCreateProductPricePoints added in v0.1.0

BulkCreateProductPricePoints takes context, productId, body as parameters and returns an models.ApiResponse with models.BulkCreateProductPricePointsResponse data and an error if there was an issue with the request or response. Use this endpoint to create multiple product price points in one request.

func (*ProductPricePointsController) CreateProductCurrencyPrices

CreateProductCurrencyPrices takes context, productPricePointId, body as parameters and returns an models.ApiResponse with models.CurrencyPricesResponse data and an error if there was an issue with the request or response. This endpoint allows you to create currency prices for a given currency that has been defined on the site level in your settings. When creating currency prices, they need to mirror the structure of your primary pricing. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. Note: Currency Prices are not able to be created for custom product price points.

func (*ProductPricePointsController) CreateProductPricePoint

CreateProductPricePoint takes context, productId, body as parameters and returns an models.ApiResponse with models.ProductPricePointResponse data and an error if there was an issue with the request or response. [Product Price Point Documentation](https://chargify.zendesk.com/hc/en-us/articles/4407755824155)

func (*ProductPricePointsController) ListAllProductPricePoints

ListAllProductPricePoints takes context, direction, filter, include, page, perPage as parameters and returns an models.ApiResponse with models.ListProductPricePointsResponse data and an error if there was an issue with the request or response. This method allows retrieval of a list of Products Price Points belonging to a Site.

func (*ProductPricePointsController) ListProductPricePoints

ListProductPricePoints takes context, productId, page, perPage, currencyPrices, filterType as parameters and returns an models.ApiResponse with models.ListProductPricePointsResponse data and an error if there was an issue with the request or response. Use this endpoint to retrieve a list of product price points.

func (*ProductPricePointsController) PromoteProductPricePointToDefault

func (p *ProductPricePointsController) PromoteProductPricePointToDefault(
	ctx context.Context,
	productId int,
	pricePointId int) (
	models.ApiResponse[models.ProductResponse],
	error)

PromoteProductPricePointToDefault takes context, productId, pricePointId as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. Use this endpoint to make a product price point the default for the product. Note: Custom product price points are not able to be set as the default for a product.

func (*ProductPricePointsController) ReadProductPricePoint

ReadProductPricePoint takes context, productId, pricePointId, currencyPrices as parameters and returns an models.ApiResponse with models.ProductPricePointResponse data and an error if there was an issue with the request or response. Use this endpoint to retrieve details for a specific product price point.

func (*ProductPricePointsController) UnarchiveProductPricePoint

func (p *ProductPricePointsController) UnarchiveProductPricePoint(
	ctx context.Context,
	productId int,
	pricePointId int) (
	models.ApiResponse[models.ProductPricePointResponse],
	error)

UnarchiveProductPricePoint takes context, productId, pricePointId as parameters and returns an models.ApiResponse with models.ProductPricePointResponse data and an error if there was an issue with the request or response. Use this endpoint to unarchive an archived product price point.

func (*ProductPricePointsController) UpdateProductCurrencyPrices

func (p *ProductPricePointsController) UpdateProductCurrencyPrices(
	ctx context.Context,
	productPricePointId int,
	body *models.UpdateCurrencyPricesRequest) (
	models.ApiResponse[models.CurrencyPricesResponse],
	error)

UpdateProductCurrencyPrices takes context, productPricePointId, body as parameters and returns an models.ApiResponse with models.CurrencyPricesResponse data and an error if there was an issue with the request or response. This endpoint allows you to update the `price`s of currency prices for a given currency that exists on the product price point. When updating the pricing, it needs to mirror the structure of your primary pricing. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. Note: Currency Prices are not able to be updated for custom product price points.

func (*ProductPricePointsController) UpdateProductPricePoint

UpdateProductPricePoint takes context, productId, pricePointId, body as parameters and returns an models.ApiResponse with models.ProductPricePointResponse data and an error if there was an issue with the request or response. Use this endpoint to update a product price point. Note: Custom product price points are not able to be updated.

type ProductsController

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

ProductsController represents a controller struct.

func NewProductsController

func NewProductsController(baseController baseController) *ProductsController

NewProductsController creates a new instance of ProductsController. It takes a baseController as a parameter and returns a pointer to the ProductsController.

func (*ProductsController) ArchiveProduct

func (p *ProductsController) ArchiveProduct(
	ctx context.Context,
	productId int) (
	models.ApiResponse[models.ProductResponse],
	error)

ArchiveProduct takes context, productId as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. Sending a DELETE request to this endpoint will archive the product. All current subscribers will be unffected; their subscription/purchase will continue to be charged monthly. This will restrict the option to chose the product for purchase via the Billing Portal, as well as disable Public Signup Pages for the product.

func (*ProductsController) CreateProduct

CreateProduct takes context, productFamilyId, body as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. Use this method to create a product within your Chargify site. + [Products Documentation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405561405709) + [Changing a Subscription's Product](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404225334669-Product-Changes-Migrations)

func (*ProductsController) ListProducts

ListProducts takes context, dateField, filter, endDate, endDatetime, startDate, startDatetime, page, perPage, includeArchived, include as parameters and returns an models.ApiResponse with []models.ProductResponse data and an error if there was an issue with the request or response. This method allows to retrieve a list of Products belonging to a Site.

func (*ProductsController) ReadProduct

func (p *ProductsController) ReadProduct(
	ctx context.Context,
	productId int) (
	models.ApiResponse[models.ProductResponse],
	error)

ReadProduct takes context, productId as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. This endpoint allows you to read the current details of a product that you've created in Chargify.

func (*ProductsController) ReadProductByHandle

func (p *ProductsController) ReadProductByHandle(
	ctx context.Context,
	apiHandle string) (
	models.ApiResponse[models.ProductResponse],
	error)

ReadProductByHandle takes context, apiHandle as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. This method allows to retrieve a Product object by its `api_handle`.

func (*ProductsController) UpdateProduct

UpdateProduct takes context, productId, body as parameters and returns an models.ApiResponse with models.ProductResponse data and an error if there was an issue with the request or response. Use this method to change aspects of an existing product. ### Input Attributes Update Notes + `update_return_params` The parameters we will append to your `update_return_url`. See Return URLs and Parameters ### Product Price Point Updating a product using this endpoint will create a new price point and set it as the default price point for this product. If you should like to update an existing product price point, that must be done separately.

type ProformaInvoicesController

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

ProformaInvoicesController represents a controller struct.

func NewProformaInvoicesController

func NewProformaInvoicesController(baseController baseController) *ProformaInvoicesController

NewProformaInvoicesController creates a new instance of ProformaInvoicesController. It takes a baseController as a parameter and returns a pointer to the ProformaInvoicesController.

func (*ProformaInvoicesController) CreateConsolidatedProformaInvoice

func (p *ProformaInvoicesController) CreateConsolidatedProformaInvoice(
	ctx context.Context,
	uid string) (
	*http.Response,
	error)

CreateConsolidatedProformaInvoice takes context, uid as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This endpoint will trigger the creation of a consolidated proforma invoice asynchronously. It will return a 201 with no message, or a 422 with any errors. To find and view the new consolidated proforma invoice, you may poll the subscription group listing for proforma invoices; only one consolidated proforma invoice may be created per group at a time. If the information becomes outdated, simply void the old consolidated proforma invoice and generate a new one. ## Restrictions Proforma invoices are only available on Relationship Invoicing sites. To create a proforma invoice, the subscription must not be prepaid, and must be in a live state.

func (*ProformaInvoicesController) CreateProformaInvoice

func (p *ProformaInvoicesController) CreateProformaInvoice(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.ProformaInvoice],
	error)

CreateProformaInvoice takes context, subscriptionId as parameters and returns an models.ApiResponse with models.ProformaInvoice data and an error if there was an issue with the request or response. This endpoint will create a proforma invoice and return it as a response. If the information becomes outdated, simply void the old proforma invoice and generate a new one. If you would like to preview the next billing amounts without generating a full proforma invoice, please use the renewal preview endpoint. ## Restrictions Proforma invoices are only available on Relationship Invoicing sites. To create a proforma invoice, the subscription must not be in a group, must not be prepaid, and must be in a live state.

func (*ProformaInvoicesController) CreateSignupProformaInvoice

CreateSignupProformaInvoice takes context, body as parameters and returns an models.ApiResponse with models.ProformaInvoice data and an error if there was an issue with the request or response. This endpoint is only available for Relationship Invoicing sites. It cannot be used to create consolidated proforma invoices or preview prepaid subscriptions. Create a proforma invoice to preview costs before a subscription's signup. Like other proforma invoices, it can be emailed to the customer, voided, and publicly viewed on the chargifypay domain. Pass a payload that resembles a subscription create or signup preview request. For example, you can specify components, coupons/a referral, offers, custom pricing, and an existing customer or payment profile to populate a shipping or billing address. A product and customer first name, last name, and email are the minimum requirements. We recommend associating the proforma invoice with a customer_id to easily find their proforma invoices, since the subscription_id will always be blank.

func (*ProformaInvoicesController) ListProformaInvoices

ListProformaInvoices takes context, subscriptionId, startDate, endDate, status, page, perPage, direction, lineItems, discounts, taxes, credits, payments, customFields as parameters and returns an models.ApiResponse with models.ListProformaInvoicesResponse data and an error if there was an issue with the request or response. By default, proforma invoices returned on the index will only include totals, not detailed breakdowns for `line_items`, `discounts`, `taxes`, `credits`, `payments`, or `custom_fields`. To include breakdowns, pass the specific field as a key in the query with a value set to `true`.

func (*ProformaInvoicesController) ListSubscriptionGroupProformaInvoices

ListSubscriptionGroupProformaInvoices takes context, uid, lineItems, discounts, taxes, credits, payments, customFields as parameters and returns an models.ApiResponse with models.ListProformaInvoicesResponse data and an error if there was an issue with the request or response. Only proforma invoices with a `consolidation_level` of parent are returned. By default, proforma invoices returned on the index will only include totals, not detailed breakdowns for `line_items`, `discounts`, `taxes`, `credits`, `payments`, `custom_fields`. To include breakdowns, pass the specific field as a key in the query with a value set to true.

func (*ProformaInvoicesController) PreviewProformaInvoice

func (p *ProformaInvoicesController) PreviewProformaInvoice(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.ProformaInvoice],
	error)

PreviewProformaInvoice takes context, subscriptionId as parameters and returns an models.ApiResponse with models.ProformaInvoice data and an error if there was an issue with the request or response. Return a preview of the data that will be included on a given subscription's proforma invoice if one were to be generated. It will have similar line items and totals as a renewal preview, but the response will be presented in the format of a proforma invoice. Consequently it will include additional information such as the name and addresses that will appear on the proforma invoice. The preview endpoint is subject to all the same conditions as the proforma invoice endpoint. For example, previews are only available on the Relationship Invoicing architecture, and previews cannot be made for end-of-life subscriptions. If all the data returned in the preview is as expected, you may then create a static proforma invoice and send it to your customer. The data within a preview will not be saved and will not be accessible after the call is made. Alternatively, if you have some proforma invoices already, you may make a preview call to determine whether any billing information for the subscription's upcoming renewal has changed.

func (*ProformaInvoicesController) PreviewSignupProformaInvoice

PreviewSignupProformaInvoice takes context, include, body as parameters and returns an models.ApiResponse with models.SignupProformaPreviewResponse data and an error if there was an issue with the request or response. This endpoint is only available for Relationship Invoicing sites. It cannot be used to create consolidated proforma invoice previews or preview prepaid subscriptions. Create a signup preview in the format of a proforma invoice to preview costs before a subscription's signup. You have the option of optionally previewing the first renewal's costs as well. The proforma invoice preview will not be persisted. Pass a payload that resembles a subscription create or signup preview request. For example, you can specify components, coupons/a referral, offers, custom pricing, and an existing customer or payment profile to populate a shipping or billing address. A product and customer first name, last name, and email are the minimum requirements.

func (*ProformaInvoicesController) ReadProformaInvoice

func (p *ProformaInvoicesController) ReadProformaInvoice(
	ctx context.Context,
	proformaInvoiceUid string) (
	models.ApiResponse[models.ProformaInvoice],
	error)

ReadProformaInvoice takes context, proformaInvoiceUid as parameters and returns an models.ApiResponse with models.ProformaInvoice data and an error if there was an issue with the request or response. Use this endpoint to read the details of an existing proforma invoice. ## Restrictions Proforma invoices are only available on Relationship Invoicing sites.

func (*ProformaInvoicesController) VoidProformaInvoice

func (p *ProformaInvoicesController) VoidProformaInvoice(
	ctx context.Context,
	proformaInvoiceUid string,
	body *models.VoidInvoiceRequest) (
	models.ApiResponse[models.ProformaInvoice],
	error)

VoidProformaInvoice takes context, proformaInvoiceUid, body as parameters and returns an models.ApiResponse with models.ProformaInvoice data and an error if there was an issue with the request or response. This endpoint will void a proforma invoice that has the status "draft". ## Restrictions Proforma invoices are only available on Relationship Invoicing sites. Only proforma invoices that have the appropriate status may be reopened. If the invoice identified by {uid} does not have the appropriate status, the response will have HTTP status code 422 and an error message. A reason for the void operation is required to be included in the request body. If one is not provided, the response will have HTTP status code 422 and an error message.

type ReadEventsCountInput added in v0.1.0

type ReadEventsCountInput struct {
	// Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
	// Use in query `page=1`.
	Page *int
	// This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
	// Use in query `per_page=200`.
	PerPage *int
	// Returns events with an id greater than or equal to the one specified
	SinceId *int64
	// Returns events with an id less than or equal to the one specified
	MaxId *int64
	// The sort direction of the returned events.
	Direction *models.Direction
	// You can pass multiple event keys after comma.
	// Use in query `filter=signup_success,payment_success`.
	Filter []models.EventType
}

ReadEventsCountInput represents the input of the ReadEventsCount endpoint.

type ReasonCodesController

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

ReasonCodesController represents a controller struct.

func NewReasonCodesController

func NewReasonCodesController(baseController baseController) *ReasonCodesController

NewReasonCodesController creates a new instance of ReasonCodesController. It takes a baseController as a parameter and returns a pointer to the ReasonCodesController.

func (*ReasonCodesController) CreateReasonCode

CreateReasonCode takes context, body as parameters and returns an models.ApiResponse with models.ReasonCodeResponse data and an error if there was an issue with the request or response. # Reason Codes Intro ReasonCodes are a way to gain a high level view of why your customers are cancelling the subcription to your product or service. Add a set of churn reason codes to be displayed in-app and/or the Chargify Billing Portal. As your subscribers decide to cancel their subscription, learn why they decided to cancel. ## Reason Code Documentation Full documentation on how Reason Codes operate within Chargify can be located under the following links. [Churn Reason Codes](https://chargify.zendesk.com/hc/en-us/articles/4407896775579#churn-reason-codes) ## Create Reason Code This method gives a merchant the option to create a reason codes for a given Site.

func (*ReasonCodesController) DeleteReasonCode

func (r *ReasonCodesController) DeleteReasonCode(
	ctx context.Context,
	reasonCodeId int) (
	models.ApiResponse[models.ReasonCodesJsonResponse],
	error)

DeleteReasonCode takes context, reasonCodeId as parameters and returns an models.ApiResponse with models.ReasonCodesJsonResponse data and an error if there was an issue with the request or response. This method gives a merchant the option to delete one reason code from the Churn Reason Codes. This code will be immediately removed. This action is not reversable.

func (*ReasonCodesController) ListReasonCodes

ListReasonCodes takes context, page, perPage as parameters and returns an models.ApiResponse with []models.ReasonCodeResponse data and an error if there was an issue with the request or response. This method gives a merchant the option to retrieve a list of all of the current churn codes for a given site.

func (*ReasonCodesController) ReadReasonCode

func (r *ReasonCodesController) ReadReasonCode(
	ctx context.Context,
	reasonCodeId int) (
	models.ApiResponse[models.ReasonCodeResponse],
	error)

ReadReasonCode takes context, reasonCodeId as parameters and returns an models.ApiResponse with models.ReasonCodeResponse data and an error if there was an issue with the request or response. This method gives a merchant the option to retrieve a list of a particular code for a given Site by providing the unique numerical ID of the code.

func (*ReasonCodesController) UpdateReasonCode

UpdateReasonCode takes context, reasonCodeId, body as parameters and returns an models.ApiResponse with models.ReasonCodeResponse data and an error if there was an issue with the request or response. This method gives a merchant the option to update an existing reason code for a given site.

type ReferralCodesController

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

ReferralCodesController represents a controller struct.

func NewReferralCodesController

func NewReferralCodesController(baseController baseController) *ReferralCodesController

NewReferralCodesController creates a new instance of ReferralCodesController. It takes a baseController as a parameter and returns a pointer to the ReferralCodesController.

func (*ReferralCodesController) ValidateReferralCode

ValidateReferralCode takes context, code as parameters and returns an models.ApiResponse with models.ReferralValidationResponse data and an error if there was an issue with the request or response. Use this method to determine if the referral code is valid and applicable within your Site. This method is useful for validating referral codes that are entered by a customer. ## Referrals Documentation Full documentation on how to use the referrals feature in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407802831643). ## Server Response If the referral code is valid the status code will be `200` and the referral code will be returned. If the referral code is invalid, a `404` response will be returned.

type RetryConfiguration

type RetryConfiguration = https.RetryConfiguration

RetryConfiguration holds the configuration options for the client.

func CreateRetryConfiguration

func CreateRetryConfiguration(options ...RetryConfigurationOptions) RetryConfiguration

CreateRetryConfiguration creates a new RetryConfiguration with the provided options.

func DefaultRetryConfiguration

func DefaultRetryConfiguration() RetryConfiguration

DefaultRetryConfiguration returns the default RetryConfiguration for HTTP requests. It also configures various retry options.

type RetryConfigurationOptions

type RetryConfigurationOptions = https.RetryConfigurationOptions

RetryConfigurationOptions is a function type that modifies the RetryConfiguration.

type SalesCommissionsController

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

SalesCommissionsController represents a controller struct.

func NewSalesCommissionsController

func NewSalesCommissionsController(baseController baseController) *SalesCommissionsController

NewSalesCommissionsController creates a new instance of SalesCommissionsController. It takes a baseController as a parameter and returns a pointer to the SalesCommissionsController.

func (*SalesCommissionsController) ListSalesCommissionSettings

ListSalesCommissionSettings takes context, sellerId, authorization, liveMode, page, perPage as parameters and returns an models.ApiResponse with []models.SaleRepSettings data and an error if there was an issue with the request or response. Endpoint returns subscriptions with associated sales reps ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Chargify support. > Note: The request is at seller level, it means `<<subdomain>>` variable will be replaced by `app`

func (*SalesCommissionsController) ListSalesReps

ListSalesReps takes context, sellerId, authorization, liveMode, page, perPage as parameters and returns an models.ApiResponse with []models.ListSaleRepItem data and an error if there was an issue with the request or response. Endpoint returns sales rep list with details ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Chargify support. > Note: The request is at seller level, it means `<<subdomain>>` variable will be replaced by `app`

func (*SalesCommissionsController) ReadSalesRep

func (s *SalesCommissionsController) ReadSalesRep(
	ctx context.Context,
	sellerId string,
	salesRepId string,
	authorization *string,
	liveMode *bool,
	page *int,
	perPage *int) (
	models.ApiResponse[models.SaleRep],
	error)

ReadSalesRep takes context, sellerId, salesRepId, authorization, liveMode, page, perPage as parameters and returns an models.ApiResponse with models.SaleRep data and an error if there was an issue with the request or response. Endpoint returns sales rep and attached subscriptions details. ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Chargify support. > Note: The request is at seller level, it means `<<subdomain>>` variable will be replaced by `app`

type Server

type Server string

Server represents available servers.

const (
	ENUMDEFAULT Server = "default"
)

type SitesController

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

SitesController represents a controller struct.

func NewSitesController

func NewSitesController(baseController baseController) *SitesController

NewSitesController creates a new instance of SitesController. It takes a baseController as a parameter and returns a pointer to the SitesController.

func (*SitesController) ClearSite

func (s *SitesController) ClearSite(
	ctx context.Context,
	cleanupScope *models.CleanupScope) (
	*http.Response,
	error)

ClearSite takes context, cleanupScope as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This call is asynchronous and there may be a delay before the site data is fully deleted. If you are clearing site data for an automated test, you will need to build in a delay and/or check that there are no products, etc., in the site before proceeding. **This functionality will only work on sites in TEST mode. Attempts to perform this on sites in “live” mode will result in a response of 403 FORBIDDEN.**

func (*SitesController) ListChargifyJsPublicKeys

ListChargifyJsPublicKeys takes context, page, perPage as parameters and returns an models.ApiResponse with models.ListPublicKeysResponse data and an error if there was an issue with the request or response. This endpoint returns public keys used for Chargify.js.

func (*SitesController) ReadSite

ReadSite takes context as parameters and returns an models.ApiResponse with models.SiteResponse data and an error if there was an issue with the request or response. This endpoint allows you to fetch some site data. Full documentation on Sites in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407870738587). Specifically, the [Clearing Site Data](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405428327309) section is extremely relevant to this endpoint documentation. #### Relationship invoicing enabled If site has RI enabled then you will see more settings like: "customer_hierarchy_enabled": true, "whopays_enabled": true, "whopays_default_payer": "self" You can read more about these settings here: [Who Pays & Customer Hierarchy](https://chargify.zendesk.com/hc/en-us/articles/4407746683291)

type SubscriptionComponentsController

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

SubscriptionComponentsController represents a controller struct.

func NewSubscriptionComponentsController

func NewSubscriptionComponentsController(baseController baseController) *SubscriptionComponentsController

NewSubscriptionComponentsController creates a new instance of SubscriptionComponentsController. It takes a baseController as a parameter and returns a pointer to the SubscriptionComponentsController.

func (*SubscriptionComponentsController) ActivateEventBasedComponent

func (s *SubscriptionComponentsController) ActivateEventBasedComponent(
	ctx context.Context,
	subscriptionId int,
	componentId int) (
	*http.Response,
	error)

ActivateEventBasedComponent takes context, subscriptionId, componentId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. In order to bill your subscribers on your Events data under the Events-Based Billing feature, the components must be activated for the subscriber. Learn more about the role of activation in the [Events-Based Billing docs](https://chargify.zendesk.com/hc/en-us/articles/4407720810907#activating-components-for-subscribers). Use this endpoint to activate an event-based component for a single subscription. Activating an event-based component causes Chargify to bill for events when the subscription is renewed. *Note: it is possible to stream events for a subscription at any time, regardless of component activation status. The activation status only determines if the subscription should be billed for event-based component usage at renewal.*

func (*SubscriptionComponentsController) AllocateComponent

func (s *SubscriptionComponentsController) AllocateComponent(
	ctx context.Context,
	subscriptionId int,
	componentId int,
	body *models.CreateAllocationRequest) (
	models.ApiResponse[models.AllocationResponse],
	error)

AllocateComponent takes context, subscriptionId, componentId, body as parameters and returns an models.ApiResponse with models.AllocationResponse data and an error if there was an issue with the request or response. This endpoint creates a new allocation, setting the current allocated quantity for the Component and recording a memo. **Notice**: Allocations can only be updated for Quantity, On/Off, and Prepaid Components. ## Allocations Documentation Full documentation on how to record Allocations in the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997). It is focused on how allocations operate within the Chargify UI.It goes into greater detail on how the user interface will react when recording allocations. This documentation also goes into greater detail on how proration is taken into consideration when applying component allocations. ## Proration Schemes Changing the allocated quantity of a component mid-period can result in either a Charge or Credit being applied to the subscription. When creating an allocation via the API, you can pass the `upgrade_charge`, `downgrade_credit`, and `accrue_charge` to be applied. **Notice:** These proration and accural fields will be ignored for Prepaid Components since this component type always generate charges immediately without proration. For background information on prorated components and upgrade/downgrade schemes, see [Setting Component Allocations.](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997#proration-upgrades-vs-downgrades). See the tables below for valid values. | upgrade_charge | Definition                                                        | |----------------|-------------------------------------------------------------------| | `full`         | A charge is added for the full price of the component.            | | `prorated`     | A charge is added for the prorated price of the component change. | | `none`         | No charge is added.                                               | | downgrade_credit | Definition                                        | |------------------|---------------------------------------------------| | `full`           | A full price credit is added for the amount owed. | | `prorated`       | A prorated credit is added for the amount owed.   | | `none`           | No charge is added.                               | | accrue_charge | Definition                                                                                               | |---------------|------------------------------------------------------------------------------------------------------------| | `true`        | Attempt to charge the customer at next renewal. | | `false`       | Attempt to charge the customer right away. If it fails, the charge will be accrued until the next renewal. | ### Order of Resolution for upgrade_charge and downgrade_credit 1. Per allocation in API call (within a single allocation of the `allocations` array) 2. [Component-level default value](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997-Component-Allocations#component-allocations-0-0) 3. Allocation API call top level (outside of the `allocations` array) 4. [Site-level default value](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997#proration-schemes) ### Order of Resolution for accrue charge 1. Allocation API call top level (outside of the `allocations` array) 2. [Site-level default value](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997#proration-schemes) **NOTE: Proration uses the current price of the component as well as the current tax rates. Changes to either may cause the prorated charge/credit to be wrong.**

func (*SubscriptionComponentsController) AllocateComponents

AllocateComponents takes context, subscriptionId, body as parameters and returns an models.ApiResponse with []models.AllocationResponse data and an error if there was an issue with the request or response. Creates multiple allocations, setting the current allocated quantity for each of the components and recording a memo. The charges and/or credits that are created will be rolled up into a single total which is used to determine whether this is an upgrade or a downgrade. Be aware of the Order of Resolutions explained below in determining the proration scheme. A `component_id` is required for each allocation. This endpoint only responds to JSON. It is not available for XML.

func (*SubscriptionComponentsController) BulkRecordEvents added in v0.1.0

func (s *SubscriptionComponentsController) BulkRecordEvents(
	ctx context.Context,
	subdomain string,
	apiHandle string,
	storeUid *string,
	body []models.EBBEvent) (
	*http.Response,
	error)

BulkRecordEvents takes context, subdomain, apiHandle, storeUid, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Use this endpoint to record a collection of events. *Note: this endpoint differs from the standard Chargify endpoints in that the subdomain will be `events` and your site subdomain will be included in the URL path.* A maximum of 1000 events can be published in a single request. A 422 will be returned if this limit is exceeded.

func (*SubscriptionComponentsController) BulkResetSubscriptionComponentsPricePoints added in v0.1.0

func (s *SubscriptionComponentsController) BulkResetSubscriptionComponentsPricePoints(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

BulkResetSubscriptionComponentsPricePoints takes context, subscriptionId as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Resets all of a subscription's components to use the current default. **Note**: this will update the price point for all of the subscription's components, even ones that have not been allocated yet.

func (*SubscriptionComponentsController) BulkUpdateSubscriptionComponentsPricePoints added in v0.1.0

BulkUpdateSubscriptionComponentsPricePoints takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.BulkComponentsPricePointAssignment data and an error if there was an issue with the request or response. Updates the price points on one or more of a subscription's components. The `price_point` key can take either a: 1. Price point id (integer) 2. Price point handle (string) 3. `"_default"` string, which will reset the price point to the component's current default price point.

func (*SubscriptionComponentsController) CreateUsage

CreateUsage takes context, subscriptionId, componentId, body as parameters and returns an models.ApiResponse with models.UsageResponse data and an error if there was an issue with the request or response. ## Documentation Full documentation on how to create Components in the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677#creating-components). Additionally, for information on how to record component usage against a subscription, please see the following resources: + [Recording Metered Component Usage](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997#reporting-metered-component-usage) + [Reporting Prepaid Component Status](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404527849997#reporting-prepaid-component-status) You may choose to report metered or prepaid usage to Chargify as often as you wish. You may report usage as it happens. You may also report usage periodically, such as each night or once per billing period. If usage events occur in your system very frequently (on the order of thousands of times an hour), it is best to accumulate usage into batches on your side, and then report those batches less frequently, such as daily. This will ensure you remain below any API throttling limits. If your use case requires higher rates of usage reporting, we recommend utilizing Events Based Components. ## Create Usage for Subscription This endpoint allows you to record an instance of metered or prepaid usage for a subscription. The `quantity` from usage for each component is accumulated to the `unit_balance` on the [Component Line Item](./b3A6MTQxMDgzNzQ-read-subscription-component) for the subscription. ## Price Point ID usage If you are using price points, for metered and prepaid usage components, Chargify gives you the option to specify a price point in your request. You do not need to specify a price point ID. If a price point is not included, the default price point for the component will be used when the usage is recorded. If an invalid `price_point_id` is submitted, the endpoint will return an error. ## Deducting Usage In the event that you need to reverse a previous usage report or otherwise deduct from the current usage balance, you may provide a negative quantity. Example: Previously recorded: ```json { "usage": { "quantity": 5000, "memo": "Recording 5000 units" } } ``` At this point, `unit_balance` would be `5000`. To reduce the balance to `0`, POST the following payload: ```json { "usage": { "quantity": -5000, "memo": "Deducting 5000 units" } } ``` The `unit_balance` has a floor of `0`; negative unit balances are never allowed. For example, if the usage balance is 100 and you deduct 200 units, the unit balance would then be `0`, not `-100`. ## FAQ Q. Is it possible to record metered usage for more than one component at a time? A. No. Usage should be reported as one API call per component on a single subscription. For example, to record that a subscriber has sent both an SMS Message and an Email, send an API call for each.

func (*SubscriptionComponentsController) DeactivateEventBasedComponent

func (s *SubscriptionComponentsController) DeactivateEventBasedComponent(
	ctx context.Context,
	subscriptionId int,
	componentId int) (
	*http.Response,
	error)

DeactivateEventBasedComponent takes context, subscriptionId, componentId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Use this endpoint to deactivate an event-based component for a single subscription. Deactivating the event-based component causes Chargify to ignore related events at subscription renewal.

func (*SubscriptionComponentsController) DeletePrepaidUsageAllocation

func (s *SubscriptionComponentsController) DeletePrepaidUsageAllocation(
	ctx context.Context,
	subscriptionId int,
	componentId int,
	allocationId int,
	body *models.CreditSchemeRequest) (
	*http.Response,
	error)

DeletePrepaidUsageAllocation takes context, subscriptionId, componentId, allocationId, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Prepaid Usage components are unique in that their allocations are always additive. In order to reduce a subscription's allocated quantity for a prepaid usage component each allocation must be destroyed individually via this endpoint. ## Credit Scheme By default, destroying an allocation will generate a service credit on the subscription. This behavior can be modified with the optional `credit_scheme` parameter on this endpoint. The accepted values are: 1. `none`: The allocation will be destroyed and the balances will be updated but no service credit or refund will be created. 2. `credit`: The allocation will be destroyed and the balances will be updated and a service credit will be generated. This is also the default behavior if the `credit_scheme` param is not passed. 3. `refund`: The allocation will be destroyed and the balances will be updated and a refund will be issued along with a Credit Note.

func (*SubscriptionComponentsController) ListAllocations

func (s *SubscriptionComponentsController) ListAllocations(
	ctx context.Context,
	subscriptionId int,
	componentId int,
	page *int) (
	models.ApiResponse[[]models.AllocationResponse],
	error)

ListAllocations takes context, subscriptionId, componentId, page as parameters and returns an models.ApiResponse with []models.AllocationResponse data and an error if there was an issue with the request or response. This endpoint returns the 50 most recent Allocations, ordered by most recent first. ## On/Off Components When a subscription's on/off component has been toggled to on (`1`) or off (`0`), usage will be logged in this response. ## Querying data via Chargify gem You can also query the current quantity via the [official Chargify Gem.](http://github.com/chargify/chargify_api_ares) ```# First way component = Chargify::Subscription::Component.find(1, :params => {:subscription_id => 7}) puts component.allocated_quantity # => 23 # Second way component = Chargify::Subscription.find(7).component(1) puts component.allocated_quantity # => 23 ```

func (*SubscriptionComponentsController) ListSubscriptionComponents

ListSubscriptionComponents takes context, subscriptionId, dateField, direction, filter, endDate, endDatetime, pricePointIds, productFamilyIds, sort, startDate, startDatetime, include, inUse as parameters and returns an models.ApiResponse with []models.SubscriptionComponentResponse data and an error if there was an issue with the request or response. This request will list a subscription's applied components. ## Archived Components When requesting to list components for a given subscription, if the subscription contains **archived** components they will be listed in the server response.

func (*SubscriptionComponentsController) ListSubscriptionComponentsForSite

ListSubscriptionComponentsForSite takes context, page, perPage, sort, direction, filter, dateField, startDate, startDatetime, endDate, endDatetime, subscriptionIds, pricePointIds, productFamilyIds, include as parameters and returns an models.ApiResponse with models.ListSubscriptionComponentsResponse data and an error if there was an issue with the request or response. This request will list components applied to each subscription.

func (*SubscriptionComponentsController) ListUsages

ListUsages takes context, subscriptionId, componentId, sinceId, maxId, sinceDate, untilDate, page, perPage as parameters and returns an models.ApiResponse with []models.UsageResponse data and an error if there was an issue with the request or response. This request will return a list of the usages associated with a subscription for a particular metered component. This will display the previously recorded components for a subscription. This endpoint is not compatible with quantity-based components. ## Since Date and Until Date Usage Note: The `since_date` and `until_date` attributes each default to midnight on the date specified. For example, in order to list usages for January 20th, you would need to append the following to the URL. ``` ?since_date=2016-01-20&until_date=2016-01-21 ``` ## Read Usage by Handle Use this endpoint to read the previously recorded components for a subscription. You can now specify either the component id (integer) or the component handle prefixed by "handle:" to specify the unique identifier for the component you are working with.

func (*SubscriptionComponentsController) PreviewAllocations

PreviewAllocations takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.AllocationPreviewResponse data and an error if there was an issue with the request or response. Chargify offers the ability to preview a potential subscription's **quantity-based** or **on/off** component allocation in the middle of the current billing period. This is useful if you want users to be able to see the effect of a component operation before actually doing it. ## Fine-grained Component Control: Use with multiple `upgrade_charge`s or `downgrade_credits` When the allocation uses multiple different types of `upgrade_charge`s or `downgrade_credit`s, the Allocation is viewed as an Allocation which uses "Fine-Grained Component Control". As a result, the response will not include `direction` and `proration` within the `allocation_preview`, but at the `line_items` and `allocations` level respectfully. See example below for Fine-Grained Component Control response.

func (*SubscriptionComponentsController) ReadSubscriptionComponent

func (s *SubscriptionComponentsController) ReadSubscriptionComponent(
	ctx context.Context,
	subscriptionId int,
	componentId int) (
	models.ApiResponse[models.SubscriptionComponentResponse],
	error)

ReadSubscriptionComponent takes context, subscriptionId, componentId as parameters and returns an models.ApiResponse with models.SubscriptionComponentResponse data and an error if there was an issue with the request or response. This request will list information regarding a specific component owned by a subscription.

func (*SubscriptionComponentsController) RecordEvent

func (s *SubscriptionComponentsController) RecordEvent(
	ctx context.Context,
	subdomain string,
	apiHandle string,
	storeUid *string,
	body *models.EBBEvent) (
	*http.Response,
	error)

RecordEvent takes context, subdomain, apiHandle, storeUid, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. ## Documentation Events-Based Billing is an evolved form of metered billing that is based on data-rich events streamed in real-time from your system to Chargify. These events can then be transformed, enriched, or analyzed to form the computed totals of usage charges billed to your customers. This API allows you to stream events into the Chargify data ingestion engine. Learn more about the feature in general in the [Events-Based Billing help docs](https://chargify.zendesk.com/hc/en-us/articles/4407720613403). ## Record Event Use this endpoint to record a single event. *Note: this endpoint differs from the standard Chargify endpoints in that the URL subdomain will be `events` and your site subdomain will be included in the URL path. For example:* ``` https://events.chargify.com/my-site-subdomain/events/my-stream-api-handle ```

func (*SubscriptionComponentsController) UpdatePrepaidUsageAllocationExpirationDate added in v0.1.0

func (s *SubscriptionComponentsController) UpdatePrepaidUsageAllocationExpirationDate(
	ctx context.Context,
	subscriptionId int,
	componentId int,
	allocationId int,
	body *models.UpdateAllocationExpirationDate) (
	*http.Response,
	error)

UpdatePrepaidUsageAllocationExpirationDate takes context, subscriptionId, componentId, allocationId, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. When the expiration interval options are selected on a prepaid usage component price point, all allocations will be created with an expiration date. This expiration date can be changed after the fact to allow for extending or shortening the allocation's active window. In order to change a prepaid usage allocation's expiration date, a PUT call must be made to the allocation's endpoint with a new expiration date. ## Limitations A few limitations exist when changing an allocation's expiration date: - An expiration date can only be changed for an allocation that belongs to a price point with expiration interval options explicitly set. - An expiration date can be changed towards the future with no limitations. - An expiration date can be changed towards the past (essentially expiring it) up to the subscription's current period beginning date.

type SubscriptionGroupInvoiceAccountController

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

SubscriptionGroupInvoiceAccountController represents a controller struct.

func NewSubscriptionGroupInvoiceAccountController

func NewSubscriptionGroupInvoiceAccountController(baseController baseController) *SubscriptionGroupInvoiceAccountController

NewSubscriptionGroupInvoiceAccountController creates a new instance of SubscriptionGroupInvoiceAccountController. It takes a baseController as a parameter and returns a pointer to the SubscriptionGroupInvoiceAccountController.

func (*SubscriptionGroupInvoiceAccountController) CreateSubscriptionGroupPrepayment

CreateSubscriptionGroupPrepayment takes context, uid, body as parameters and returns an models.ApiResponse with models.SubscriptionGroupPrepaymentResponse data and an error if there was an issue with the request or response. A prepayment can be added for a subscription group identified by the group's `uid`. This endpoint requires a `amount`, `details`, `method`, and `memo`. On success, the prepayment will be added to the group's prepayment balance.

func (*SubscriptionGroupInvoiceAccountController) DeductSubscriptionGroupServiceCredit added in v0.1.0

DeductSubscriptionGroupServiceCredit takes context, uid, body as parameters and returns an models.ApiResponse with models.ServiceCredit data and an error if there was an issue with the request or response. Credit can be deducted for a subscription group identified by the group's `uid`. Credit will be deducted from the group in the amount specified in the request body.

func (*SubscriptionGroupInvoiceAccountController) IssueSubscriptionGroupServiceCredit added in v0.1.0

IssueSubscriptionGroupServiceCredit takes context, uid, body as parameters and returns an models.ApiResponse with models.ServiceCreditResponse data and an error if there was an issue with the request or response. Credit can be issued for a subscription group identified by the group's `uid`. Credit will be added to the group in the amount specified in the request body. The credit will be applied to group member invoices as they are generated.

func (*SubscriptionGroupInvoiceAccountController) ListPrepaymentsForSubscriptionGroup

ListPrepaymentsForSubscriptionGroup takes context, uid, page, perPage, filter as parameters and returns an models.ApiResponse with models.ListSubscriptionGroupPrepaymentResponse data and an error if there was an issue with the request or response. This request will list a subscription group's prepayments.

type SubscriptionGroupStatusController

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

SubscriptionGroupStatusController represents a controller struct.

func NewSubscriptionGroupStatusController

func NewSubscriptionGroupStatusController(baseController baseController) *SubscriptionGroupStatusController

NewSubscriptionGroupStatusController creates a new instance of SubscriptionGroupStatusController. It takes a baseController as a parameter and returns a pointer to the SubscriptionGroupStatusController.

func (*SubscriptionGroupStatusController) CancelDelayedCancellationForGroup added in v0.1.0

func (s *SubscriptionGroupStatusController) CancelDelayedCancellationForGroup(
	ctx context.Context,
	uid string) (
	*http.Response,
	error)

CancelDelayedCancellationForGroup takes context, uid as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Removing the delayed cancellation on a subscription group will ensure that the subscriptions do not get canceled at the end of the period. The request will reset the `cancel_at_end_of_period` flag to false on each member in the group.

func (*SubscriptionGroupStatusController) CancelSubscriptionsInGroup

CancelSubscriptionsInGroup takes context, uid, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This endpoint will immediately cancel all subscriptions within the specified group. The group is identified by it's `uid` passed in the URL. To successfully cancel the group, the primary subscription must be on automatic billing. The group members as well must be on automatic billing or they must be prepaid. In order to cancel a subscription group while also charging for any unbilled usage on metered or prepaid components, the `charge_unbilled_usage=true` parameter must be included in the request.

func (*SubscriptionGroupStatusController) InitiateDelayedCancellationForGroup

func (s *SubscriptionGroupStatusController) InitiateDelayedCancellationForGroup(
	ctx context.Context,
	uid string) (
	*http.Response,
	error)

InitiateDelayedCancellationForGroup takes context, uid as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This endpoint will schedule all subscriptions within the specified group to be canceled at the end of their billing period. The group is identified by it's uid passed in the URL. All subscriptions in the group must be on automatic billing in order to successfully cancel them, and the group must not be in a "past_due" state.

func (*SubscriptionGroupStatusController) ReactivateSubscriptionGroup

ReactivateSubscriptionGroup takes context, uid, body as parameters and returns an models.ApiResponse with models.ReactivateSubscriptionGroupResponse data and an error if there was an issue with the request or response. This endpoint will attempt to reactivate or resume a cancelled subscription group. Upon reactivation, any canceled invoices created after the beginning of the primary subscription's billing period will be reopened and payment will be attempted on them. If the subscription group is being reactivated (as opposed to resumed), new charges will also be assessed for the new billing period. Whether a subscription group is reactivated (a new billing period is created) or resumed (the current billing period is respected) will depend on the parameters that are sent with the request as well as the date of the request relative to the primary subscription's period. ## Reactivating within the current period If a subscription group is cancelled and reactivated within the primary subscription's current period, we can choose to either start a new billing period or maintain the existing one. If we want to maintain the existing billing period the `resume=true` option must be passed in request parameters. An exception to the above are subscriptions that are on calendar billing. These subscriptions cannot be reactivated within the current period. If the `resume=true` option is not passed the request will return an error. The `resume_members` option is ignored in this case. All eligible group members will be automatically resumed. ## Reactivating beyond the current period In this case, a subscription group can only be reactivated with a new billing period. If the `resume=true` option is passed it will be ignored. Member subscriptions can have billing periods that are longer than the primary (e.g. a monthly primary with annual group members). If the primary subscription in a group cannot be reactivated within the current period, but other group members can be, passing `resume_members=true` will resume the existing billing period for eligible group members. The primary subscription will begin a new billing period. For calendar billing subscriptions, the new billing period created will be a partial one, spanning from the date of reactivation to the next corresponding calendar renewal date.

type SubscriptionGroupsController

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

SubscriptionGroupsController represents a controller struct.

func NewSubscriptionGroupsController

func NewSubscriptionGroupsController(baseController baseController) *SubscriptionGroupsController

NewSubscriptionGroupsController creates a new instance of SubscriptionGroupsController. It takes a baseController as a parameter and returns a pointer to the SubscriptionGroupsController.

func (*SubscriptionGroupsController) AddSubscriptionToGroup added in v0.1.0

AddSubscriptionToGroup takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionGroupResponse data and an error if there was an issue with the request or response. For sites making use of the [Relationship Billing](https://chargify.zendesk.com/hc/en-us/articles/4407737494171) and [Customer Hierarchy](https://chargify.zendesk.com/hc/en-us/articles/4407746683291) features, it is possible to add existing subscriptions to subscription groups. Passing `group` parameters with a `target` containing a `type` and optional `id` is all that's needed. When the `target` parameter specifies a `"customer"` or `"subscription"` that is already part of a hierarchy, the subscription will become a member of the customer's subscription group. If the target customer or subscription is not part of a subscription group, a new group will be created and the subscription will become part of the group with the specified target customer set as the responsible payer for the group's subscriptions. **Please Note:** In order to add an existing subscription to a subscription group, it must belong to either the same customer record as the target, or be within the same customer hierarchy. Rather than specifying a customer, the `target` parameter could instead simply have a value of * `"self"` which indicates the subscription will be paid for not by some other customer, but by the subscribing customer, * `"parent"` which indicates the subscription will be paid for by the subscribing customer's parent within a customer hierarchy, or * `"eldest"` which indicates the subscription will be paid for by the root-level customer in the subscribing customer's hierarchy. To create a new subscription into a subscription group, please reference the following: [Create Subscription in a Subscription Group](https://developers.chargify.com/docs/api-docs/d571659cf0f24-create-subscription#subscription-in-a-subscription-group)

func (*SubscriptionGroupsController) CreateSubscriptionGroup

CreateSubscriptionGroup takes context, body as parameters and returns an models.ApiResponse with models.SubscriptionGroupResponse data and an error if there was an issue with the request or response. Creates a subscription group with given members.

func (*SubscriptionGroupsController) DeleteSubscriptionGroup

DeleteSubscriptionGroup takes context, uid as parameters and returns an models.ApiResponse with models.DeleteSubscriptionGroupResponse data and an error if there was an issue with the request or response. Use this endpoint to delete subscription group. Only groups without members can be deleted

func (*SubscriptionGroupsController) FindSubscriptionGroup added in v0.1.0

FindSubscriptionGroup takes context, subscriptionId as parameters and returns an models.ApiResponse with models.FullSubscriptionGroupResponse data and an error if there was an issue with the request or response. Use this endpoint to find subscription group associated with subscription. If the subscription is not in a group endpoint will return 404 code.

func (*SubscriptionGroupsController) ListSubscriptionGroups

ListSubscriptionGroups takes context, page, perPage, include as parameters and returns an models.ApiResponse with models.ListSubscriptionGroupsResponse data and an error if there was an issue with the request or response. Returns an array of subscription groups for the site. The response is paginated and will return a `meta` key with pagination information. #### Account Balance Information Account balance information for the subscription groups is not returned by default. If this information is desired, the `include[]=account_balances` parameter must be provided with the request.

func (*SubscriptionGroupsController) ReadSubscriptionGroup

ReadSubscriptionGroup takes context, uid, include as parameters and returns an models.ApiResponse with models.FullSubscriptionGroupResponse data and an error if there was an issue with the request or response. Use this endpoint to find subscription group details. #### Current Billing Amount in Cents Current billing amount for the subscription group is not returned by default. If this information is desired, the `include[]=current_billing_amount_in_cents` parameter must be provided with the request.

func (*SubscriptionGroupsController) RemoveSubscriptionFromGroup

func (s *SubscriptionGroupsController) RemoveSubscriptionFromGroup(
	ctx context.Context,
	subscriptionId int) (
	*http.Response,
	error)

RemoveSubscriptionFromGroup takes context, subscriptionId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. For sites making use of the [Relationship Billing](https://chargify.zendesk.com/hc/en-us/articles/4407737494171) and [Customer Hierarchy](https://chargify.zendesk.com/hc/en-us/articles/4407746683291) features, it is possible to remove existing subscription from subscription group.

func (*SubscriptionGroupsController) SignupWithSubscriptionGroup

SignupWithSubscriptionGroup takes context, body as parameters and returns an models.ApiResponse with models.SubscriptionGroupSignupResponse data and an error if there was an issue with the request or response. Create multiple subscriptions at once under the same customer and consolidate them into a subscription group. You must provide one and only one of the `payer_id`/`payer_reference`/`payer_attributes` for the customer attached to the group. You must provide one and only one of the `payment_profile_id`/`credit_card_attributes`/`bank_account_attributes` for the payment profile attached to the group. Only one of the `subscriptions` can have `"primary": true` attribute set. When passing product to a subscription you can use either `product_id` or `product_handle` or `offer_id`. You can also use `custom_price` instead.

func (*SubscriptionGroupsController) UpdateSubscriptionGroupMembers

UpdateSubscriptionGroupMembers takes context, uid, body as parameters and returns an models.ApiResponse with models.SubscriptionGroupResponse data and an error if there was an issue with the request or response. Use this endpoint to update subscription group members. `"member_ids"` should contain an array of both subscription IDs to set as group members and subscription IDs already present in the groups. Not including them will result in removing them from subscription group. To clean up members, just leave the array empty.

type SubscriptionInvoiceAccountController

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

SubscriptionInvoiceAccountController represents a controller struct.

func NewSubscriptionInvoiceAccountController

func NewSubscriptionInvoiceAccountController(baseController baseController) *SubscriptionInvoiceAccountController

NewSubscriptionInvoiceAccountController creates a new instance of SubscriptionInvoiceAccountController. It takes a baseController as a parameter and returns a pointer to the SubscriptionInvoiceAccountController.

func (*SubscriptionInvoiceAccountController) CreatePrepayment

CreatePrepayment takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.CreatePrepaymentResponse data and an error if there was an issue with the request or response. ## Create Prepayment In order to specify a prepayment made against a subscription, specify the `amount, memo, details, method`. When the `method` specified is `"credit_card_on_file"`, the prepayment amount will be collected using the default credit card payment profile and applied to the prepayment account balance. This is especially useful for manual replenishment of prepaid subscriptions. Please note that you **can't** pass `amount_in_cents`.

func (*SubscriptionInvoiceAccountController) DeductServiceCredit

func (s *SubscriptionInvoiceAccountController) DeductServiceCredit(
	ctx context.Context,
	subscriptionId int,
	body *models.DeductServiceCreditRequest) (
	*http.Response,
	error)

DeductServiceCredit takes context, subscriptionId, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Credit will be removed from the subscription in the amount specified in the request body. The credit amount being deducted must be equal to or less than the current credit balance.

func (*SubscriptionInvoiceAccountController) IssueServiceCredit

IssueServiceCredit takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.ServiceCredit data and an error if there was an issue with the request or response. Credit will be added to the subscription in the amount specified in the request body. The credit is subsequently applied to the next generated invoice.

func (*SubscriptionInvoiceAccountController) ListPrepayments

ListPrepayments takes context, subscriptionId, page, perPage, filter as parameters and returns an models.ApiResponse with models.PrepaymentsResponse data and an error if there was an issue with the request or response. This request will list a subscription's prepayments.

func (*SubscriptionInvoiceAccountController) ReadAccountBalances

func (s *SubscriptionInvoiceAccountController) ReadAccountBalances(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.AccountBalances],
	error)

ReadAccountBalances takes context, subscriptionId as parameters and returns an models.ApiResponse with models.AccountBalances data and an error if there was an issue with the request or response. Returns the `balance_in_cents` of the Subscription's Pending Discount, Service Credit, and Prepayment accounts, as well as the sum of the Subscription's open, payable invoices.

func (*SubscriptionInvoiceAccountController) RefundPrepayment

RefundPrepayment takes context, subscriptionId, prepaymentId, body as parameters and returns an models.ApiResponse with models.PrepaymentResponse data and an error if there was an issue with the request or response. This endpoint will refund, completely or partially, a particular prepayment applied to a subscription. The `prepayment_id` will be the account transaction ID of the original payment. The prepayment must have some amount remaining in order to be refunded. The amount may be passed either as a decimal, with `amount`, or an integer in cents, with `amount_in_cents`.

type SubscriptionNotesController

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

SubscriptionNotesController represents a controller struct.

func NewSubscriptionNotesController

func NewSubscriptionNotesController(baseController baseController) *SubscriptionNotesController

NewSubscriptionNotesController creates a new instance of SubscriptionNotesController. It takes a baseController as a parameter and returns a pointer to the SubscriptionNotesController.

func (*SubscriptionNotesController) CreateSubscriptionNote

CreateSubscriptionNote takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionNoteResponse data and an error if there was an issue with the request or response. Use the following method to create a note for a subscription. ## How to Use Subscription Notes Notes allow you to record information about a particular Subscription in a free text format. If you have structured data such as birth date, color, etc., consider using Metadata instead. Full documentation on how to use Notes in the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404434903181-Subscription-Summary#notes).

func (*SubscriptionNotesController) DeleteSubscriptionNote

func (s *SubscriptionNotesController) DeleteSubscriptionNote(
	ctx context.Context,
	subscriptionId int,
	noteId int) (
	*http.Response,
	error)

DeleteSubscriptionNote takes context, subscriptionId, noteId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Use the following method to delete a note for a Subscription.

func (*SubscriptionNotesController) ListSubscriptionNotes

ListSubscriptionNotes takes context, subscriptionId, page, perPage as parameters and returns an models.ApiResponse with []models.SubscriptionNoteResponse data and an error if there was an issue with the request or response. Use this method to retrieve a list of Notes associated with a Subscription. The response will be an array of Notes.

func (*SubscriptionNotesController) ReadSubscriptionNote

func (s *SubscriptionNotesController) ReadSubscriptionNote(
	ctx context.Context,
	subscriptionId int,
	noteId int) (
	models.ApiResponse[models.SubscriptionNoteResponse],
	error)

ReadSubscriptionNote takes context, subscriptionId, noteId as parameters and returns an models.ApiResponse with models.SubscriptionNoteResponse data and an error if there was an issue with the request or response. Once you have obtained the ID of the note you wish to read, use this method to show a particular note attached to a subscription.

func (*SubscriptionNotesController) UpdateSubscriptionNote

UpdateSubscriptionNote takes context, subscriptionId, noteId, body as parameters and returns an models.ApiResponse with models.SubscriptionNoteResponse data and an error if there was an issue with the request or response. Use the following method to update a note for a Subscription.

type SubscriptionProductsController

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

SubscriptionProductsController represents a controller struct.

func NewSubscriptionProductsController

func NewSubscriptionProductsController(baseController baseController) *SubscriptionProductsController

NewSubscriptionProductsController creates a new instance of SubscriptionProductsController. It takes a baseController as a parameter and returns a pointer to the SubscriptionProductsController.

func (*SubscriptionProductsController) MigrateSubscriptionProduct

MigrateSubscriptionProduct takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. In order to create a migration, you must pass the `product_id` or `product_handle` in the object when you send a POST request. You may also pass either a `product_price_point_id` or `product_price_point_handle` to choose which price point the subscription is moved to. If no price point identifier is passed the subscription will be moved to the products default price point. The response will be the updated subscription. ## Valid Subscriptions Subscriptions should be in the `active` or `trialing` state in order to be migrated. (For backwards compatibility reasons, it is possible to migrate a subscription that is in the `trial_ended` state via the API, however this is not recommended. Since `trial_ended` is an end-of-life state, the subscription should be canceled, the product changed, and then the subscription can be reactivated.) ## Migrations Documentation Full documentation on how to record Migrations in the Chargify UI can be located [here](https://chargify.zendesk.com/hc/en-us/articles/4407898373531). ## Failed Migrations One of the most common ways that a migration can fail is when the attempt is made to migrate a subscription to it's current product. Please be aware of this issue! ## Migration 3D Secure - Stripe It may happen that a payment needs 3D Secure Authentication when the subscription is migrated to a new product; this is referred to in our help docs as a [post-authentication flow](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405177432077#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: ```json { "errors": [ "Your card was declined. This transaction requires 3D secure authentication." ], "gateway_payment_id": "pi_1F0aGoJ2UDb3Q4av7zU3sHPh", "description": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", "action_link": "http://acme.chargify.com/3d-secure/pi_1F0aGoJ2UDb3Q4av7zU3sHPh?one_time_token_id=242" } ``` To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - whether the authentication was successful (`success`) - the gateway ID for the payment (`gateway_payment_id`) - the subscription ID (`subscription_id`) Lastly, you can also specify a `redirect_url` within the `action_link` URL if you’d like to redirect a customer back to your site. It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. The final URL that you send a customer to to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` ### Example Redirect Flow You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: 1. Create a migration via API; it requires 3DS 2. You receive a `gateway_payment_id` in the `action_link` along other params in the response. 3. Use this `gateway_payment_id` to, for example, connect with your internal resources or generate a session_id 4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied 6. After the customer finishes 3DS authentication, we let you know the result by making a request to applied `callback_url`. 7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was successful or not.

func (*SubscriptionProductsController) PreviewSubscriptionProductMigration

PreviewSubscriptionProductMigration takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionMigrationPreviewResponse data and an error if there was an issue with the request or response. ## Previewing a future date It is also possible to preview the migration for a date in the future, as long as it's still within the subscription's current billing period, by passing a `proration_date` along with the request (eg: `"proration_date": "2020-12-18T18:25:43.511Z"`). This will calculate the prorated adjustment, charge, payment and credit applied values assuming the migration is done at that date in the future as opposed to right now.

type SubscriptionStatusController

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

SubscriptionStatusController represents a controller struct.

func NewSubscriptionStatusController

func NewSubscriptionStatusController(baseController baseController) *SubscriptionStatusController

NewSubscriptionStatusController creates a new instance of SubscriptionStatusController. It takes a baseController as a parameter and returns a pointer to the SubscriptionStatusController.

func (*SubscriptionStatusController) CancelDelayedCancellation added in v0.1.0

func (s *SubscriptionStatusController) CancelDelayedCancellation(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.DelayedCancellationResponse],
	error)

CancelDelayedCancellation takes context, subscriptionId as parameters and returns an models.ApiResponse with models.DelayedCancellationResponse data and an error if there was an issue with the request or response. Removing the delayed cancellation on a subscription will ensure that it doesn't get canceled at the end of the period that it is in. The request will reset the `cancel_at_end_of_period` flag to `false`. This endpoint is idempotent. If the subscription was not set to cancel in the future, removing the delayed cancellation has no effect and the call will be successful.

func (*SubscriptionStatusController) CancelDunning

CancelDunning takes context, subscriptionId as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. If a subscription is currently in dunning, the subscription will be set to active and the active Dunner will be resolved.

func (*SubscriptionStatusController) CancelSubscription

CancelSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. The DELETE action causes the cancellation of the Subscription. This means, the method sets the Subscription state to "canceled".

func (*SubscriptionStatusController) InitiateDelayedCancellation

func (s *SubscriptionStatusController) InitiateDelayedCancellation(
	ctx context.Context,
	subscriptionId int,
	body *models.CancellationRequest) (
	models.ApiResponse[models.DelayedCancellationResponse],
	error)

InitiateDelayedCancellation takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.DelayedCancellationResponse data and an error if there was an issue with the request or response. Chargify offers the ability to cancel a subscription at the end of the current billing period. This period is set by its current product. Requesting to cancel the subscription at the end of the period sets the `cancel_at_end_of_period` flag to true. Note that you cannot set `cancel_at_end_of_period` at subscription creation, or if the subscription is past due.

func (*SubscriptionStatusController) PauseSubscription

func (s *SubscriptionStatusController) PauseSubscription(
	ctx context.Context,
	subscriptionId int,
	body *models.PauseRequest) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

PauseSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. This will place the subscription in the on_hold state and it will not renew. ## Limitations You may not place a subscription on hold if the `next_billing` date is within 24 hours.

func (*SubscriptionStatusController) PreviewRenewal

PreviewRenewal takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.RenewalPreviewResponse data and an error if there was an issue with the request or response. The Chargify API allows you to preview a renewal by posting to the renewals endpoint. Renewal Preview is an object representing a subscription’s next assessment. You can retrieve it to see a snapshot of how much your customer will be charged on their next renewal. The "Next Billing" amount and "Next Billing" date are already represented in the UI on each Subscriber's Summary. For more information, please see our documentation [here](https://chargify.zendesk.com/hc/en-us/articles/4407884887835#next-billing). ## Optional Component Fields This endpoint is particularly useful due to the fact that it will return the computed billing amount for the base product and the components which are in use by a subscriber. By default, the preview will include billing details for all components _at their **current** quantities_. This means: * Current `allocated_quantity` for quantity-based components * Current enabled/disabled status for on/off components * Current metered usage `unit_balance` for metered components * Current metric quantity value for events recorded thus far for events-based components In the above statements, "current" means the quantity or value as of the call to the renewal preview endpoint. We do not predict end-of-period values for components, so metered or events-based usage may be less than it will eventually be at the end of the period. Optionally, **you may provide your own custom quantities** for any component to see a billing preview for non-current quantities. This is accomplished by sending a request body with data under the `components` key. See the request body documentation below. ## Subscription Side Effects You can request a `POST` to obtain this data from the endpoint without any side effects. Plain and simple, this will preview data, not log any changes against a subscription.

func (*SubscriptionStatusController) ReactivateSubscription

ReactivateSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Chargify offers the ability to reactivate a previously canceled subscription. For details on how the reactivation works, and how to reactivate subscriptions through the application, see [reactivation](https://chargify.zendesk.com/hc/en-us/articles/4407898737691). **Please note: The term "resume" is used also during another process in Chargify. This occurs when an on-hold subscription is "resumed". This returns the subscription to an active state.** + The response returns the subscription object in the `active` or `trialing` state. + The `canceled_at` and `cancellation_message` fields do not have values. + The method works for "Canceled" or "Trial Ended" subscriptions. + It will not work for items not marked as "Canceled", "Unpaid", or "Trial Ended". ## Resume the current billing period for a subscription A subscription is considered "resumable" if you are attempting to reactivate within the billing period the subscription was canceled in. A resumed subscription's billing date remains the same as before it was canceled. In other words, it does not start a new billing period. Payment may or may not be collected for a resumed subscription, depending on whether or not the subscription had a balance when it was canceled (for example, if it was canceled because of dunning). Consider a subscription which was created on June 1st, and would renew on July 1st. The subscription is then canceled on June 15. If a reactivation with `resume: true` were attempted _before_ what would have been the next billing date of July 1st, then Chargify would resume the subscription. If a reactivation with `resume: true` were attempted _after_ what would have been the next billing date of July 1st, then Chargify would not resume the subscription, and instead it would be reactivated with a new billing period. | Canceled | Reactivation | Resumable? | |---|---|---| | Jun 15 | June 28 | Yes | | Jun 15 | July 2 | No | ## Reactivation Scenarios ### Reactivating Canceled Subscription While Preserving Balance + Given you have a product that costs $20 + Given you have a canceled subscription to the $20 product + 1 charge should exist for $20 + 1 payment should exist for $20 + When the subscription has canceled due to dunning, it retained a negative balance of $20 #### Results The resulting charges upon reactivation will be: + 1 charge for $20 for the new product + 1 charge for $20 for the balance due + Total charges = $40 + The subscription will transition to active + The subscription balance will be zero ### Reactivating a Canceled Subscription With Coupon + Given you have a canceled subscription + It has no current period defined + You have a coupon code "EARLYBIRD" + The coupon is set to recur for 6 periods PUT request sent to: `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?coupon_code=EARLYBIRD` #### Results + The subscription will transition to active + The subscription should have applied a coupon with code "EARLYBIRD" ### Reactivating Canceled Subscription With a Trial, Without the include_trial Flag + Given you have a canceled subscription + The product associated with the subscription has a trial + PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json` #### Results + The subscription will transition to active ### Reactivating Canceled Subscription With Trial, With the include_trial Flag + Given you have a canceled subscription + The product associated with the subscription has a trial + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?include_trial=1` #### Results + The subscription will transition to trialing ### Reactivating Trial Ended Subscription + Given you have a trial_ended subscription + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json` #### Results + The subscription will transition to active ### Resuming a Canceled Subscription + Given you have a `canceled` subscription and it is resumable + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?resume=true` #### Results + The subscription will transition to active + The next billing date should not have changed ### Attempting to resume a subscription which is not resumable + Given you have a `canceled` subscription, and it is not resumable + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?resume=true` #### Results + The subscription will transition to active, with a new billing period. ### Attempting to resume but not reactivate a subscription which is not resumable + Given you have a `canceled` subscription, and it is not resumable + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?resume[require_resume]=true` + The response status should be "422 UNPROCESSABLE ENTITY" + The subscription should be canceled with the following response ``` { "errors": ["Request was 'resume only', but this subscription cannot be resumed."] } ``` #### Results + The subscription should remain `canceled` + The next billing date should not have changed ### Resuming Subscription Which Was Trialing + Given you have a `trial_ended` subscription, and it is resumable + And the subscription was canceled in the middle of a trial + And there is still time left on the trial + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?resume=true` #### Results + The subscription will transition to trialing + The next billing date should not have changed ### Resuming Subscription Which Was trial_ended + Given you have a `trial_ended` subscription, and it is resumable + Send a PUT request to `https://acme.chargify.com/subscriptions/{subscription_id}/reactivate.json?resume=true` #### Results + The subscription will transition to active + The next billing date should not have changed + Any product-related charges should have been collected

func (*SubscriptionStatusController) ResumeSubscription

func (s *SubscriptionStatusController) ResumeSubscription(
	ctx context.Context,
	subscriptionId int,
	calendarBillingResumptionCharge *models.ResumptionCharge) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

ResumeSubscription takes context, subscriptionId, calendarBillingResumptionCharge as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Resume a paused (on-hold) subscription. If the normal next renewal date has not passed, the subscription will return to active and will renew on that date. Otherwise, it will behave like a reactivation, setting the billing date to 'now' and charging the subscriber.

func (*SubscriptionStatusController) RetrySubscription

func (s *SubscriptionStatusController) RetrySubscription(
	ctx context.Context,
	subscriptionId int) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

RetrySubscription takes context, subscriptionId as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Chargify offers the ability to retry collecting the balance due on a past due Subscription without waiting for the next scheduled attempt. ## Successful Reactivation The response will be `200 OK` with the updated Subscription. ## Failed Reactivation The response will be `422 "Unprocessable Entity`.

func (*SubscriptionStatusController) UpdateAutomaticSubscriptionResumption

func (s *SubscriptionStatusController) UpdateAutomaticSubscriptionResumption(
	ctx context.Context,
	subscriptionId int,
	body *models.PauseRequest) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

UpdateAutomaticSubscriptionResumption takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Once a subscription has been paused / put on hold, you can update the date which was specified to automatically resume the subscription. To update a subscription's resume date, use this method to change or update the `automatically_resume_at` date. ### Remove the resume date Alternately, you can change the `automatically_resume_at` to `null` if you would like the subscription to not have a resume date.

type SubscriptionsController

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

SubscriptionsController represents a controller struct.

func NewSubscriptionsController

func NewSubscriptionsController(baseController baseController) *SubscriptionsController

NewSubscriptionsController creates a new instance of SubscriptionsController. It takes a baseController as a parameter and returns a pointer to the SubscriptionsController.

func (*SubscriptionsController) ActivateSubscription

ActivateSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Chargify offers the ability to activate awaiting signup and trialing subscriptions. This feature is only available on the Relationship Invoicing architecture. Subscriptions in a group may not be activated immediately. For details on how the activation works, and how to activate subscriptions through the application, see [activation](#). The `revert_on_failure` parameter controls the behavior upon activation failure. - If set to `true` and something goes wrong i.e. payment fails, then Chargify will not change the subscription's state. The subscription’s billing period will also remain the same. - If set to `false` and something goes wrong i.e. payment fails, then Chargify will continue through with the activation and enter an end of life state. For trialing subscriptions, that will either be trial ended (if the trial is no obligation), past due (if the trial has an obligation), or canceled (if the site has no dunning strategy, or has a strategy that says to cancel immediately). For awaiting signup subscriptions, that will always be canceled. The default activation failure behavior can be configured per activation attempt, or you may set a default value under Config > Settings > Subscription Activation Settings. ## Activation Scenarios ### Activate Awaiting Signup subscription - Given you have a product without trial - Given you have a site without dunning strategy ```mermaid flowchart LR AS[Awaiting Signup] --> A{Activate} A -->|Success| Active A -->|Failure| ROF{revert_on_failure} ROF -->|true| AS ROF -->|false| Canceled ``` - Given you have a product with trial - Given you have a site with dunning strategy ```mermaid flowchart LR AS[Awaiting Signup] --> A{Activate} A -->|Success| Trialing A -->|Failure| ROF{revert_on_failure} ROF -->|true| AS ROF -->|false| PD[Past Due] ``` ### Activate Trialing subscription You can read more about the behavior of trialing subscriptions [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404494617357#trialing-subscriptions-0-0). When the `revert_on_failure` parameter is set to `true`, the subscription's state will remain as Trialing, we will void the invoice from activation and return any prepayments and credits applied to the invoice back to the subscription.

func (*SubscriptionsController) ApplyCouponsToSubscription added in v0.1.0

func (s *SubscriptionsController) ApplyCouponsToSubscription(
	ctx context.Context,
	subscriptionId int,
	code *string,
	body *models.AddCouponsRequest) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

ApplyCouponsToSubscription takes context, subscriptionId, code, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. An existing subscription can accommodate multiple discounts/coupon codes. This is only applicable if each coupon is stackable. For more information on stackable coupons, we recommend reviewing our [coupon documentation.](https://chargify.zendesk.com/hc/en-us/articles/4407755909531#stackable-coupons) ## Query Parameters vs Request Body Parameters Passing in a coupon code as a query parameter will add the code to the subscription, completely replacing all existing coupon codes on the subscription. For this reason, using this query parameter on this endpoint has been deprecated in favor of using the request body parameters as described below. When passing in request body parameters, the list of coupon codes will simply be added to any existing list of codes on the subscription.

func (*SubscriptionsController) CreateSubscription

CreateSubscription takes context, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Full documentation on how subscriptions operate within Chargify can be located under the following topics: + [Subscriptions Reference](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405577172749-Subscription-Introduction) + [Subscriptions Actions](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405510556557-Actions) + [Subscription Cancellation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405510556557-Actions#initiate-cancellation) + [Subscription Reactivation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404559291021-Reactivating-and-Resuming) + [Subscription Import](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404863655821-Imports) When creating a subscription, you must specify a product and a customer. Credit card details may be required, depending on the options for the Product being subscribed ([see Product Options](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405246782221#payment-method-settings)). The product may be specified by `product_id` or by `product_handle` (API Handle). In similar fashion, to pass a particular product price point, you may either use `product_price_point_handle` or `product_price_point_id`. An existing customer may be specified by a `customer_id` (ID within Chargify) or a `customer_reference` (unique value within your app that you have shared with Chargify via the reference attribute on a customer). You may also pass in an existing payment profile for that customer with `payment_profile_id`. A new customer may be created by providing `customer_attributes`. Credit card details may be required, depending on the options for the product being subscribed. The product can be specified by `product_id` or by `product_handle` (API Handle). If you are creating a subscription with a payment profile, the attribute to send will be `credit_card_attributes` or `bank_account_attributes` for ACH and Direct Debit. That said, when you read the subscription after creation, we return the profile details under `credit_card` or `bank_account`. ## Taxable Subscriptions If your intent is to charge your subscribers tax via [Avalara Taxes](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405275711885-Avalara-VAT-Tax) or [Custom Taxes](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405069041549-Custom-Taxes), there are a few considerations to be made regarding collecting subscription data. For subscribers to be eligible to be taxed, the following information for the `customer` object or `payment_profile` object must by supplied: + A subscription to a [taxable product](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405246782221-Product-Editing#tax-settings) + [Full valid billing or shipping address](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405356114317#full-address-required-for-taxable-subscriptions) to identify the tax locale + The portion of the address that houses the [state information](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405356114317#required-state-format-for-taxable-subscriptions) of either adddress must adhere to the ISO standard of a 2-3 character limit/format. + The portion of the address that houses the [country information](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405356114317#required-country-format-for-taxable-subscriptions) must adhere to the ISO standard of a 2 character limit/format. ## Subscription Request Examples The subscription examples below will be split into two sections. The first section, "Subscription Customization", will focus on passing different information with a subscription, such as components, calendar billing, and custom fields. These examples will presume you are using a secure `chargify_token` generated by Chargify.js. The second section, "Passing Payment Information", will focus on passing payment information into Chargify. Please be aware that <b>collecting and sending Chargify raw card details requires PCI compliance on your end</b>; these examples are provided as guidance. If your business is not PCI compliant, we recommend using Chargify.js to collect credit cards or bank accounts. # Subscription Customization ## With Components Different components require slightly different data. For example, quantity-based and on/off components accept `allocated_quantity`, while metered components accept `unit_balance`. When creating a subscription with a component, a `price_point_id` can be passed in along with the `component_id` to specify which price point to use. If not passed in, the default price point will be used. Note: if an invalid `price_point_id` is used, the subscription will still proceed but will use the component's default price point. Components and their price points may be added by ID or by handle. See the example request body labeled "Components By Handle (Quantity-Based)"; the format will be the same for other component types. ## With Coupon(s) Pass an array of `coupon_codes`. See the example request body "With Coupon". ## With Manual Invoice Collection The `invoice` collection method works only on legacy Statement Architecture. On Relationship Invoicing Architecture use the `remittance` collection method. ## Prepaid Subscription A prepaid subscription can be created with the usual subscription creation parameters, specifying `prepaid` as the `payment_collection_method` and including a nested `prepaid_configuration`. After a prepaid subscription has been created, additional funds can be manually added to the prepayment account through the [Create Prepayment Endpoint](https://developers.chargify.com/docs/api-docs/7ec482de77ba7-create-prepayment). Prepaid subscriptions do not work on legacy Statement Architecture. ## With Metafields Metafields can either attach to subscriptions or customers. Metafields are popuplated with the supplied metadata to the resource specified. If the metafield doesn't exist yet, it will be created on-the-fly. ## With Custom Pricing Custom pricing is pricing specific to the subscription in question. Create a subscription with custom pricing by passing pricing information instead of a price point. For a custom priced product, pass the custom_price object in place of `product_price_point_id`. For a custom priced component, pass the `custom_price` object within the component object. Custom prices and price points can exist in harmony on a subscription. # Passing Payment Information ## Subscription with Chargify.js token The `chargify_token` can be obtained using [chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview). The token represents payment profile attributes that were provided by the customer in their browser and stored at the payment gateway. The `payment_type` attribute may either be `credit_card` or `bank_account`, depending on the type of payment method being added. If a bank account is being passed, the payment attributes should be changed to `bank_account_attributes`. ```json { "subscription": { "product_handle": "pro-plan", "customer_attributes": { "first_name": "Joe", "last_name": "Smith", "email": "j.smith@example.com" }, "credit_card_attributes": { "chargify_token": "tok_cwhvpfcnbtgkd8nfkzf9dnjn", "payment_type": "credit_card" } } } ``` ## Subscription with vault token If you already have a customer and card stored in your payment gateway, you may create a subscription with a `vault_token`. Providing the last_four, card type and expiration date will allow the card to be displayed properly in the Chargify UI. ```json { "subscription": { "product_handle": "pro-plan", "customer_attributes": { "first_name": "Joe", "last_name": "Smith", "email": "j.smith@example.com" }, "credit_card_attributes": { first_name: "Joe, last_name: "Smith", card_type: "visa", expiration_month: "05", expiration_year: "2025", last_four: "1234", vault_token: "12345abc", current_vault: "braintree_blue" } } ``` ## Subscription with Credit Card ```json "subscription": { "product_handle": "basic", "customer_attributes": { "first_name": "Joe", "last_name": "Blow", "email": "joe@example.com", "zip": "02120", "state": "MA", "reference": "XYZ", "phone": "(617) 111 - 0000", "organization": "Acme", "country": "US", "city": "Boston", "address_2": null, "address": "123 Mass Ave." }, "credit_card_attributes": { "last_name": "Smith", "first_name": "Joe", "full_number": "4111111111111111", "expiration_year": "2021", "expiration_month": "1", "card_type": "visa", "billing_zip": "02120", "billing_state": "MA", "billing_country": "US", "billing_city": "Boston", "billing_address_2": null, "billing_address": "123 Mass Ave." } } ``` ## Subscription with ACH as Payment Profile ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Joe", "last_name": "Blow", "email": "joe@example.com", "zip": "02120", "state": "MA", "reference": "XYZ", "phone": "(617) 111 - 0000", "organization": "Acme", "country": "US", "city": "Boston", "address_2": null, "address": "123 Mass Ave." }, "bank_account_attributes": { "bank_name": "Best Bank", "bank_routing_number": "021000089", "bank_account_number": "111111111111", "bank_account_type": "checking", "bank_account_holder_type": "business", "payment_type": "bank_account" } } } ``` ## Subscription with PayPal payment profile ### With the nonce from Braintree JS ```json { "subscription": { "product_handle":"test-product-b", "customer_attributes": { "first_name":"Amelia", "last_name":"Johnson", "email":"amelia@example.com", "organization":"My Awesome Company" }, "payment_profile_attributes":{ "paypal_email": "amelia@example.com", "current_vault": "braintree_blue", "payment_method_nonce":"abc123", "payment_type":"paypal_account" } } ``` ### With the Braintree Customer ID as the vault token: ```json { "subscription": { "product_handle":"test-product-b", "customer_attributes": { "first_name":"Amelia", "last_name":"Johnson", "email":"amelia@example.com", "organization":"My Awesome Company" }, "payment_profile_attributes":{ "paypal_email": "amelia@example.com", "current_vault": "braintree_blue", "vault_token":"58271347", "payment_type":"paypal_account" } } ``` ## Subscription using GoCardless Bank Number These examples creates a customer, bank account and mandate in GoCardless. For more information on GoCardless, please view the following two resources: + [Payment Profiles via API for GoCardless](https://developers.chargify.com/docs/api-docs/1f10a4f170405-create-payment-profile#gocardless) + [Full documentation on GoCardless](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404501889677) + [Using Chargify.js with GoCardless - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-direct-debit-gocardless-gateway) + [Using Chargify.js with GoCardless - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-direct-debit-gocardless-gateway) ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "Royal Bank of France", "bank_account_number": "0000000", "bank_routing_number": "0003", "bank_branch_code": "00006", "payment_type": "bank_account", "billing_address": "20 Place de la Gare", "billing_city": "Colombes", "billing_state": "Île-de-France", "billing_zip": "92700", "billing_country": "FR" } } } ``` ## Subscription using GoCardless IBAN Number ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "French Bank", "bank_iban": "FR1420041010050500013M02606", "payment_type": "bank_account", "billing_address": "20 Place de la Gare", "billing_city": "Colombes", "billing_state": "Île-de-France", "billing_zip": "92700", "billing_country": "FR" } } } ``` ## Subscription using Stripe SEPA Direct Debit For more information on Stripe Direct Debit, please view the following two resources: + [Payment Profiles via API for Stripe SEPA Direct Debit](https://developers.chargify.com/docs/api-docs/1f10a4f170405-create-payment-profile#sepa-direct-debit) + [Full documentation on Stripe Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) + [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + [Using Chargify.js with Stripe SEPA Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "Test Bank", "bank_iban": "DE89370400440532013000", "payment_type": "bank_account" } } } ``` ## Subscription using Stripe BECS Direct Debit For more information on Stripe Direct Debit, please view the following two resources: + [Payment Profiles via API for Stripe BECS Direct Debit]($e/Payment%20Profiles/createPaymentProfile) + [Full documentation on Stripe Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) + [Using Chargify.js with Stripe BECS Direct Debit - full example](page:development-tools/chargify-js/examples#full-example-with-becs-direct-debit-stripe-gateway) ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "Test Bank", "bank_branch_code": "000000", "bank_account_number": "000123456", "payment_type": "bank_account" } } } ``` ## Subscription using Stripe BACS Direct Debit For more information on Stripe Direct Debit, please view the following two resources: + [Payment Profiles via API for Stripe BACS Direct Debit]($e/Payment%20Profiles/createPaymentProfile) + [Full documentation on Stripe Direct Debit](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405050826765-Stripe-SEPA-and-BECS-Direct-Debit) + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](page:development-tools/chargify-js/examples#minimal-example-with-sepa-becs-or-bacs-direct-debit-stripe-gateway) + [Using Chargify.js with Stripe BACS Direct Debit - full example](page:development-tools/chargify-js/examples#full-example-with-bacs-direct-debit-stripe-gateway) ```json { "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "Test Bank", "bank_branch_code": "108800", "bank_account_number": "00012345", "payment_type": "bank_account", "billing_address": "123 Main St.", "billing_city": "London", "billing_state": "LND", "billing_zip": "W1A 1AA", "billing_country": "GB" } } } ``` ## 3D Secure - Stripe It may happen that a payment needs 3D Secure Authentication when the subscription is created; this is referred to in our help docs as a [post-authentication flow](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405177432077#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: ```json { "errors": [ "Your card was declined. This transaction requires 3D secure authentication." ], "gateway_payment_id": "pi_1F0aGoJ2UDb3Q4av7zU3sHPh", "description": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", "action_link": "http://acme.chargify.com/3d-secure/pi_1F0aGoJ2UDb3Q4av7zU3sHPh?one_time_token_id=242" } ``` To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - whether the authentication was successful (`success`) - the gateway ID for the payment (`gateway_payment_id`) - the subscription ID (`subscription_id`) Lastly, you can also specify a `redirect_url` within the `action_link` URL if you’d like to redirect a customer back to your site. It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. The final URL that you send a customer to to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` ## 3D Secure - Checkout It may happen that a payment needs 3D Secure Authentication when the subscription is created; this is referred to in our help docs as a [post-authentication flow](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405177432077#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: ```json { "errors": [ "Your card was declined. This transaction requires 3D secure authentication." ], "gateway_payment_id": "pay_6gjofv7dlyrkpizlolsuspvtiu", "description": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", "action_link": "http://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123" } ``` To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - whether the authentication was successful (`success`) - the gateway ID for the payment (`gateway_payment_id`) - the subscription ID (`subscription_id`) Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like to redirect a customer back to your site. It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. The final URL that you send a customer to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` ### Example Redirect Flow You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: 1. Create a subscription via API; it requires 3DS 2. You receive a `gateway_payment_id` in the `action_link` along other params in the response. 3. Use this `gateway_payment_id` to, for example, connect with your internal resources or generate a session_id 4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied 6. After the customer finishes 3DS authentication, we let you know the result by making a request to applied `callback_url`. 7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was successful or not ## Subscriptions Import Subscriptions can be “imported” via the API to handle the following scenarios: + You already have existing subscriptions with specific start and renewal dates that you would like to import to Chargify + You already have credit cards stored in your provider’s vault and you would like to create subscriptions using those tokens Before importing, you should have already set up your products to match your offerings. Then, you can create Subscriptions via the API just like you normally would, but using a few special attributes. Full documentation on how import Subscriptions using the **import tool** in the Chargify UI can be located [here](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404863655821#imports-0-0). ### Important Notices and Disclaimers regarding Imports Before performing a bulk import of subscriptions via the API, we suggest reading the [Subscriptions Import](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404863655821#important-notices-and-disclaimers) instructions to understand the repurcussions of a large import. ### Subscription Input Attributes The following _additional_ attributes to the subscription input attributes make imports possible: `next_billing_at`, `previous_billing_at`, and `import_mrr`. ### Current Vault If you are using a Legacy gateway such as "eWAY Rapid (Legacy)" or "Stripe (Legacy)" then please contact Support for further instructions on subscription imports. ### Braintree Blue (Braintree v2) Imports Braintree Blue is Braintree’s newer (version 2) API. For this gateway, please provide the `vault_token` parameter with the value from Braintree’s “Customer ID” rather than the “Payment Profile Token”. At this time we do not use `current_vault_token` with the Braintree Blue gateway, and we only support a single payment profile per Braintree Customer. When importing PayPal type payment profiles, please set `payment_type` to `paypal_account`. ### Stripe ACH Imports If the bank account has already been verified, currently you will need to create the customer, create the payment profile in Chargify - setting verified=true, then create a subscription using the customer_id and payment_profile_id. ### Webhooks During Import If no `next_billing_at` is provided, webhooks will be fired as normal. If you do set a future `next_billing_at`, only a subset of the webhooks are fired when the subscription is created. Keep reading for more information as to what webhooks will be fired under which scenarios. #### Successful creation with Billing Date Scenario: If `next_billing_at` provided + `signup_success` + `billing_date_change` #### Successful creation without Billing Date Scenario: If no `next_billing_at` provided + `signup_success` + `payment_success` #### Unsuccessful creation Scenario: If card can’t be charged, and no `next_billing_at` provided + signup_failure #### Webhooks fired when next_billing_at is reached: + `renewal_success or renewal_failure` + `payment_success or payment_failure` ### Date and Time Formats We will attempt to parse any string you send as the value of next_billing_at in to a date or time. For best results, use a known format like described in “Date and Time Specification” of RFC 2822 or ISO 8601 . The following are all equivalent and will work as input to `next_billing_at`: ``` Aug 06 2030 11:34:00 -0400 Aug 06 2030 11:34 -0400 2030-08-06T11:34:00-04:00 8/6/2030 11:34:00 EDT 8/6/2030 8:34:00 PDT 2030-08-06T15:34:00Z ``` You may also pass just a date, in which case we will assume the time to be noon ``` 2010-08-06 ``` ## Subscription Hierarchies & WhoPays When subscription groups were first added to our Relationship Invoicing architecture, to group together invoices for related subscriptions and allow for complex customer hierarchies and WhoPays scenarios, they were designed to consist of a primary and a collection of group members. The primary would control many aspects of the group, such as when the consolidated invoice is generated. As of today, groups still function this way. In the future, the concept of a "primary" will be removed in order to offer more flexibility into group management and reduce confusion concerning what actions must be done on a primary level, rather than a member level. We have introduced a two scheme system as a bridge between these two group organizations. Scheme 1, which is relevant to all subscription groups today, marks the group as being "ruled" by a primary. When reading a subscription via API, they will return a top-level attribute called `group`, which will denote which scheme is being used. At this time, the `scheme` attribute will always be 1. ### Subscription in a Customer Hierarchy For sites making use of the [Relationship Billing](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices) and [Customer Hierarchy](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404900384141) features, it is possible to create subscriptions within a customer hierarchy. This can be achieved through the API by passing group parameters in the **Create Subscription** request. + The `group` parameters are optional and consist of the required `target` and optional `billing` parameters. When the `target` parameter specifies a customer that is already part of a hierarchy, the new subscription will become a member of the customer hierarchy as well. If the target customer is not part of a hierarchy, a new customer hierarchy will be created and both the target customer and the new subscription will become part of the hierarchy with the specified target customer set as the responsible payer for the hierarchy's subscriptions. Rather than specifying a customer, the `target` parameter could instead simply have a value of `self` which indicates the subscription will be paid for not by some other customer, but by the subscribing customer. This will be true whether the customer is being created new, is already part of a hierarchy, or already exists outside a hierarchy. A valid payment method must also be specified in the subscription parameters. Note that when creating subscriptions in a customer hierarchy, if the customer hierarchy does not already have a payment method, passing valid credit card attributes in the subscription parameters will also result in the payment method being established as the default payment method for the customer hierarchy irrespective of the responsible payer. The optional `billing` parameters specify how some aspects of the billing for the new subscription should be handled. Rather than capturing payment immediately, the `accrue` parameter can be included so that the new subscription charges accrue until the next assessment date. Regarding the date, the `align_date` parameter can be included so that the billing date of the new subscription matches up with the default subscription group in the customer hierarchy. When choosing to align the dates, the `prorate` parameter can also be specified so that the new subscription charges are prorated based on the billing period of the default subscription group in the customer hierarchy also. ### Subscription in a Subscription Group For sites making use of [Relationship Billing](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices) it may be desireable to create a subscription as part of a [subscription group](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405577356173) in order to rely on [invoice consolidation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404980119949). This can be achieved through the API by passing group parameters in the Create Subscription request. The `group` parameters are optional and consist of the required `target` and optional `billing` parameters. The `target` parameters specify an existing subscription with which the newly created subscription should be grouped. If the target subscription is already part of a group, the new subscription will become a member of the group as well. If the target subscription is not part of a group, a new group will be created and both the target and the new subscription will become part of the group with the target as the group's primary subscription. The optional `billing` parameters specify how some aspects of the billing for the new subscription should be handled. Rather than capturing payment immediately, the `accrue` parameter can be included so that the new subscription charges accrue until the next assessment date. Regarding the date, the `align_date` parameter can be included so that the billing date of the new subscription matches up with the target subscription. When choosing to align the dates, the `prorate` parameter can also be specified so that the new subscription charges are prorated based on the billing period of the target subscription also. ## Providing Agreement Acceptance Params It is possible to provide a proof of customer's acceptance of terms and policies. We will be storing this proof in case it might be required (i.e. chargeback). Currently, we already keep it for subscriptions created via Public Signup Pages. In order to create a subscription with the proof of agreement acceptance, you must provide additional parameters `agreement acceptance` with `ip_address` and at least one url to the policy that was accepted: `terms_url` or `privacy_policy_url`. Additional urls that can be provided: `return_refund_policy_url`, `delivery_policy_url` and `secure_checkout_policy_url`. ```json "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "agreement_acceptance": { "ip_address": "1.2.3.4", "terms_url": "https://terms.url", "privacy_policy_url": "https://privacy_policy.url", "return_refund_policy_url": "https://return_refund_policy.url", "delivery_policy_url": "https://delivery_policy.url", "secure_checkout_policy_url": "https://secure_checkout_policy.url" } } } ``` **For Maxio Payments subscriptions, the agreement acceptance params are required, with at least terms_url provided.** ## Providing ACH Agreement params It is also possible to provide a proof that a customer authorized ACH agreement terms. The proof will be stored and the email will be sent to the customer with a copy of the terms (if enabled). In order to create a subscription with the proof of authorized ACH agreement terms, you must provide the additional parameter `ach_agreement` with the following nested parameters: `agreement_terms`, `authorizer_first_name`, `authorizer_last_name` and `ip_address`. Each of them is required. ```json "subscription": { "product_handle": "gold-product", "customer_attributes": { "first_name": "Jane", "last_name": "Doe", "email": "jd@chargify.test" }, "bank_account_attributes": { "bank_name": "Test Bank", "bank_routing_number": "021000089", "bank_account_number": "111111111111", "bank_account_type": "checking", "bank_account_holder_type": "business", "payment_type": "bank_account" }, "ach_agreement": { "agreement_terms": "ACH agreement terms", "authorizer_first_name": "Jane", "authorizer_last_name": "Doe", "ip_address": "1.2.3.4" } } ```

func (*SubscriptionsController) FindSubscription added in v0.1.0

FindSubscription takes context, reference as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Use this endpoint to find a subscription by its reference.

func (*SubscriptionsController) ListSubscriptions

ListSubscriptions takes context, page, perPage, state, product, productPricePointId, coupon, dateField, startDate, endDate, startDatetime, endDatetime, metadata, direction, sort, include as parameters and returns an models.ApiResponse with []models.SubscriptionResponse data and an error if there was an issue with the request or response. This method will return an array of subscriptions from a Site. Pay close attention to query string filters and pagination in order to control responses from the server. ## Search for a subscription Use the query strings below to search for a subscription using the criteria available. The return value will be an array. ## Self-Service Page token Self-Service Page token for the subscriptions is not returned by default. If this information is desired, the include[]=self_service_page_token parameter must be provided with the request.

func (*SubscriptionsController) OverrideSubscription

func (s *SubscriptionsController) OverrideSubscription(
	ctx context.Context,
	subscriptionId int,
	body *models.OverrideSubscriptionRequest) (
	*http.Response,
	error)

OverrideSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This API endpoint allows you to set certain subscription fields that are usually managed for you automatically. Some of the fields can be set via the normal Subscriptions Update API, but others can only be set using this endpoint. This endpoint is provided for cases where you need to “align” Chargify data with data that happened in your system, perhaps before you started using Chargify. For example, you may choose to import your historical subscription data, and would like the activation and cancellation dates in Chargify to match your existing historical dates. Chargify does not backfill historical events (i.e. from the Events API), but some static data can be changed via this API. Why are some fields only settable from this endpoint, and not the normal subscription create and update endpoints? Because we want users of this endpoint to be aware that these fields are usually managed by Chargify, and using this API means **you are stepping out on your own.** Changing these fields will not affect any other attributes. For example, adding an expiration date will not affect the next assessment date on the subscription. If you regularly need to override the current_period_starts_at for new subscriptions, this can also be accomplished by setting both `previous_billing_at` and `next_billing_at` at subscription creation. See the documentation on [Importing Subscriptions](./b3A6MTQxMDgzODg-create-subscription#subscriptions-import) for more information. ## Limitations When passing `current_period_starts_at` some validations are made: 1. The subscription needs to be unbilled (no statements or invoices). 2. The value passed must be a valid date/time. We recommend using the iso 8601 format. 3. The value passed must be before the current date/time. If unpermitted parameters are sent, a 400 HTTP response is sent along with a string giving the reason for the problem.

func (*SubscriptionsController) PreviewSubscription

PreviewSubscription takes context, body as parameters and returns an models.ApiResponse with models.SubscriptionPreviewResponse data and an error if there was an issue with the request or response. The Chargify API allows you to preview a subscription by POSTing the same JSON or XML as for a subscription creation. The "Next Billing" amount and "Next Billing" date are represented in each Subscriber's Summary. For more information, please see our documentation [here](https://chargify.zendesk.com/hc/en-us/articles/4407884887835#next-billing). ## Side effects A subscription will not be created by sending a POST to this endpoint. It is meant to serve as a prediction. ## Taxable Subscriptions This endpoint will preview taxes applicable to a purchase. In order for taxes to be previewed, the following conditions must be met: + Taxes must be configured on the subscription + The preview must be for the purchase of a taxable product or component, or combination of the two. + The subscription payload must contain a full billing or shipping address in order to calculate tax For more information about creating taxable previews, please see our documentation guide on how to create [taxable subscriptions.](https://chargify.zendesk.com/hc/en-us/articles/4407904217755#creating-taxable-subscriptions) You do **not** need to include a card number to generate tax information when you are previewing a subscription. However, please note that when you actually want to create the subscription, you must include the credit card information if you want the billing address to be stored in Chargify. The billing address and the credit card information are stored together within the payment profile object. Also, you may not send a billing address to Chargify without payment profile information, as the address is stored on the card. You can pass shipping and billing addresses and still decide not to calculate taxes. To do that, pass `skip_billing_manifest_taxes: true` attribute. ## Non-taxable Subscriptions If you'd like to calculate subscriptions that do not include tax, please feel free to leave off the billing information.

func (*SubscriptionsController) PurgeSubscription

func (s *SubscriptionsController) PurgeSubscription(
	ctx context.Context,
	subscriptionId int,
	ack int,
	cascade []models.SubscriptionPurgeType) (
	*http.Response,
	error)

PurgeSubscription takes context, subscriptionId, ack, cascade as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. For sites in test mode, you may purge individual subscriptions. Provide the subscription ID in the url. To confirm, supply the customer ID in the query string `ack` parameter. You may also delete the customer record and/or payment profiles by passing `cascade` parameters. For example, to delete just the customer record, the query params would be: `?ack={customer_id}&cascade[]=customer` If you need to remove subscriptions from a live site, please contact support to discuss your use case. ### Delete customer and payment profile The query params will be: `?ack={customer_id}&cascade[]=customer&cascade[]=payment_profile`

func (*SubscriptionsController) ReadSubscription

func (s *SubscriptionsController) ReadSubscription(
	ctx context.Context,
	subscriptionId int,
	include []models.SubscriptionInclude) (
	models.ApiResponse[models.SubscriptionResponse],
	error)

ReadSubscription takes context, subscriptionId, include as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. Use this endpoint to find subscription details. ## Self-Service Page token Self-Service Page token for the subscription is not returned by default. If this information is desired, the include[]=self_service_page_token parameter must be provided with the request.

func (*SubscriptionsController) RemoveCouponFromSubscription added in v0.1.0

func (s *SubscriptionsController) RemoveCouponFromSubscription(
	ctx context.Context,
	subscriptionId int,
	couponCode *string) (
	models.ApiResponse[string],
	error)

RemoveCouponFromSubscription takes context, subscriptionId, couponCode as parameters and returns an models.ApiResponse with string data and an error if there was an issue with the request or response. Use this endpoint to remove a coupon from an existing subscription. For more information on the expected behaviour of removing a coupon from a subscription, please see our documentation [here.](https://chargify.zendesk.com/hc/en-us/articles/4407896488987#removing-a-coupon)

func (*SubscriptionsController) UpdatePrepaidSubscriptionConfiguration added in v0.1.0

func (s *SubscriptionsController) UpdatePrepaidSubscriptionConfiguration(
	ctx context.Context,
	subscriptionId int,
	body *models.UpsertPrepaidConfigurationRequest) (
	models.ApiResponse[models.PrepaidConfigurationResponse],
	error)

UpdatePrepaidSubscriptionConfiguration takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.PrepaidConfigurationResponse data and an error if there was an issue with the request or response. Use this endpoint to update a subscription's prepaid configuration.

func (*SubscriptionsController) UpdateSubscription

UpdateSubscription takes context, subscriptionId, body as parameters and returns an models.ApiResponse with models.SubscriptionResponse data and an error if there was an issue with the request or response. The subscription endpoint allows you to instantly update one or many attributes about a subscription in a single call. ## Update Subscription Payment Method Change the card that your Subscriber uses for their subscription. You can also use this method to simply change the expiration date of the card **if your gateway allows**. Note that partial card updates for **Authorize.Net** are not allowed via this endpoint. The existing Payment Profile must be directly updated instead. You also use this method to change the subscription to a different product by setting a new value for product_handle. A product change can be done in two different ways, **product change** or **delayed product change**. ## Product Change This endpoint may be used to change a subscription's product. The new payment amount is calculated and charged at the normal start of the next period. If you desire complex product changes or prorated upgrades and downgrades instead, please see the documentation on Migrating Subscription Products. To perform a product change, simply set either the `product_handle` or `product_id` attribute to that of a different product from the same site as the subscription. You can also change the price point by passing in either `product_price_point_id` or `product_price_point_handle` - otherwise the new product's default price point will be used. ### Delayed Product Change This method also changes the product and/or price point, and the new payment amount is calculated and charged at the normal start of the next period. This method schedules the product change to happen automatically at the subscription’s next renewal date. To perform a Delayed Product Change, set the `product_handle` attribute as you would in a regular product change, but also set the `product_change_delayed` attribute to `true`. No proration applies in this case. You can also perform a delayed change to the price point by passing in either `product_price_point_id` or `product_price_point_handle` **Note: To cancel a delayed product change, set `next_product_id` to an empty string.** ## Billing Date Changes ### Regular Billing Date Changes Send the `next_billing_at` to set the next billing date for the subscription. After that date passes and the subscription is processed, the following billing date will be set according to the subscription's product period. Note that if you pass an invalid date, we will automatically interpret and set the correct date. For example, when February 30 is entered, the next billing will be set to March 2nd in a non-leap year. The server response will not return data under the key/value pair of `next_billing`. Please view the key/value pair of `current_period_ends_at` to verify that the `next_billing` date has been changed successfully. ### Snap Day Changes For a subscription using Calendar Billing, setting the next billing date is a bit different. Send the `snap_day` attribute to change the calendar billing date for **a subscription using a product eligible for calendar billing**. Note: If you change the product associated with a subscription that contains a `snap_date` and immediately `READ/GET` the subscription data, it will still contain evidence of the existing `snap_date`. This is due to the fact that a product change is instantanous and only affects the product associated with a subscription. After the `next_billing` date arrives, the `snap_day` associated with the subscription will return to `null.` Another way of looking at this is that you willl have to wait for the next billing cycle to arrive before the `snap_date` will reset to `null`.

type WebhooksController

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

WebhooksController represents a controller struct.

func NewWebhooksController

func NewWebhooksController(baseController baseController) *WebhooksController

NewWebhooksController creates a new instance of WebhooksController. It takes a baseController as a parameter and returns a pointer to the WebhooksController.

func (*WebhooksController) CreateEndpoint

CreateEndpoint takes context, body as parameters and returns an models.ApiResponse with models.EndpointResponse data and an error if there was an issue with the request or response. The Chargify API allows you to create an endpoint and assign a list of webhooks subscriptions (events) to it. You can check available events here. [Event keys](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405357509645-Webhooks-Reference#example-payloads)

func (*WebhooksController) EnableWebhooks

EnableWebhooks takes context, body as parameters and returns an models.ApiResponse with models.EnableWebhooksResponse data and an error if there was an issue with the request or response. This method allows you to enable webhooks via API for your site

func (*WebhooksController) ListEndpoints

ListEndpoints takes context as parameters and returns an models.ApiResponse with []models.Endpoint data and an error if there was an issue with the request or response. This method returns created endpoints for site.

func (*WebhooksController) ListWebhooks

ListWebhooks takes context, status, sinceDate, untilDate, page, perPage, order, subscription as parameters and returns an models.ApiResponse with []models.WebhookResponse data and an error if there was an issue with the request or response. ## Webhooks Intro The Webhooks API allows you to view a list of all webhooks and to selectively resend individual or groups of webhooks. Webhooks will be sent on endpoints specified by you. Endpoints can be added via API or Web UI. There is also an option to enable / disable webhooks via API request. We recommend that you review Chargify's webhook documentation located in our help site. The following resources will help guide you on how to use webhooks in Chargify, in addition to these webhook endpoints: + [Adding/editing new webhooks](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404448450317#configure-webhook-url) + [Webhooks introduction and delivery information](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405568068365#webhooks-introduction-0-0) + [Main webhook overview](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405357509645-Webhooks-Reference#webhooks-reference-0-0) + [Available webhooks and payloads](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405357509645-Webhooks-Reference#events) ## List Webhooks for a Site This method allows you to fetch data about webhooks. You can pass query parameters if you want to filter webhooks.

func (*WebhooksController) ReplayWebhooks

ReplayWebhooks takes context, body as parameters and returns an models.ApiResponse with models.ReplayWebhooksResponse data and an error if there was an issue with the request or response. Posting to the replay endpoint does not immediately resend the webhooks. They are added to a queue and will be sent as soon as possible, depending on available system resources. You may submit an array of up to 1000 webhook IDs to replay in the request.

func (*WebhooksController) UpdateEndpoint

UpdateEndpoint takes context, endpointId, body as parameters and returns an models.ApiResponse with models.EndpointResponse data and an error if there was an issue with the request or response. You can update an Endpoint via the API with a PUT request to the resource endpoint. You can change the `url` of your endpoint which consumes webhooks or list of `webhook_subscriptions`. Check available [Event keys](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404448450317-Webhooks#configure-webhook-url). Always send a complete list of events which you want subscribe/watch. Sending an PUT request for existing endpoint with empty list of `webhook_subscriptions` will end with unsubscribe from all events. If you want unsubscribe from specific event, just send a list of `webhook_subscriptions` without the specific event key.

Directories

Path Synopsis
Package advancedbilling
Package advancedbilling
Package advancedbilling
Package advancedbilling
test module

Jump to

Keyboard shortcuts

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