chargify

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 16 Imported by: 0

README

Chargify SDK

Go Report Card GitHub license Maintenance

This library is a small wrapper around a subset of the Chargify API.

This library is actively used in production, however not all end points are used regularly. We do our best to keep up to date with changes, but focus primarily on our own needs. However, pull requests are always welcome!

Update as of 10/14/22

Chargify has rebranded as "Maxio", but all references for the time being will remain to the name "Chargify".

Usage

Usage is fairly straight-forward. See Configuration for more information about setting up and configuring the SDK.

Environment Variables

  • CHARGIFY_ENV set to production to actually make calls
  • CHARGIFY_API_KEY Your secret API key
  • CHARGIFY_SUBDOMAIN The subdomain for your account at Chargify

Testing

Testing requires an actual account (nothing is mocked, but that could be a good addition!). Make sure your subdomain, api key, etc are properly set.

IMPORTANT If you run all of the tests, there isn't currently a way to delete the following entities. As such, you will need to handle that in the GUI until a solution is provided in the official REST API:

  • Product Family

Moving CLI

A recent PR included a CLI. We will be moving it out into a separate repository. Do not rely on using it in this repo.

Future Improvements

The following are improvements we would like to make, or would like PRs to address (reach out to us first to make sure no one else has started working on it though!):

  • Migrate all makeCall and makeEventsCall invocations to the new makeAPICall function. This includes modifying the INTERNAL allocation to the options struct.

  • Update calls to take options structs with pointers; add new functions where deprecation would occur so we can maintain backwards compatibility.

Implemented Endpoints

Note that Chargify changes their API doc URLs regularly, so we have stopped providing links directly to the end points.

Customers
  • Create Customer
  • Delete Customer
  • Get Customers
  • Search for Customers
Events
  • List Events
  • List Events for Subscription
  • Total Event Count
  • Event Ingestion
  • Bulk Event Ingestion
Payment Profiles
  • Create Payment Profile
  • Delete Payment Profile
Product Families
  • Create Product Family
  • Get Product Family
  • Read Component By ID
  • Read Component By Handle
  • List Comonents for Product Family
  • List Product Familiy via Site
Products
  • Create a Product
  • Archive a Product
  • Update a Product
  • Get a Product By ID
  • Get a Product By Handle
  • Get a Product In Family
Subscriptions
  • Create Subscription
  • Update Subscription
  • Cancel Subscription - Immediately
  • Cancel Subscription - Delayed
  • Remove Delayed Cancellation
  • List Subscriptions
  • Purge a Subscription (only works in test mode!)
Coupons
  • Create a Coupon
  • Find a Coupon
  • Archive a Coupon
  • List Coupons

Hiring

Want to join an awesome team building cool products to improve the lives of pets and their owners? Send an email to engineering@wagz.com and let's find out if we're a good match! We are a remote-first company based in New Hampshire.

Contributing

Pull Requests are welcome! See our CONTRIBUTING.md file for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveCoupon added in v0.9.0

func ArchiveCoupon(productFamilyID, couponID int64) error

ArchiveCoupon archives a coupon on use or expiration

func ArchiveProduct

func ArchiveProduct(productID int64) error

ArchiveProduct archives a product

func CancelSubscription

func CancelSubscription(subscriptionID int64, cancelImmediately bool, reasonCode string, cancellationMessage string) error

CancelSubscription cancels a subscription. You can choose to cancel now or delay it. If you choose to delay, you can provide a reason code and message

func ConvertJSONFloatToInt

func ConvertJSONFloatToInt(input interface{}) (int64, error)

ConvertJSONFloatToInt converts a float64 to an int64 from the JSON field interface

func CreateProduct

func CreateProduct(productFamilyID int64, input *Product) error

CreateProduct creates a new product and places the result in the input

func DeleteCustomerByID

func DeleteCustomerByID(id int64) error

DeleteCustomerByID deletes a customer from chargify permanently

func DeletePaymentProfile

func DeletePaymentProfile(subscriptionID int64, profileID int64) error

DeletePaymentProfile deletes a payment profile

func EnableBillingPortal added in v0.6.0

func EnableBillingPortal(customerID int64, sendInvitation bool) error

EnableBillingPortal enables billing portal management for the customer. Note that it will return an error if the portal is already enabled. Confusingly, the decision to send an invite is a query string parameter here rather than a HTTP body data object: https://reference.chargify.com/v1/billing-portal/enabling-billing-portal-for-customer

func FromBool added in v0.12.0

func FromBool(input bool) *bool

FromBool converts a value to a pointer

func FromFloat64 added in v0.12.0

func FromFloat64(input float64) *float64

FromFloat64 converts a value to a pointer

func FromInt added in v0.12.0

func FromInt(input int) *int

FromInt converts a value to a pointer

func FromInt64 added in v0.12.0

func FromInt64(input int64) *int64

FromInt64 converts a value to a pointer

func FromString added in v0.12.0

func FromString(input string) *string

FromString converts a value to a pointer

func MigrateSubscription added in v0.2.0

func MigrateSubscription(targetProductHandle string, currentSubscriptionID int64, includeTrial bool, includeInitialCharge bool, includeCoupons bool, preservePeriod bool) error

MigrateSubscription migrates an existing subscription to a new subscription

func PostBulkEventsIngestion added in v0.10.0

func PostBulkEventsIngestion(body interface{}, pathParams *map[string]string, queryParams *EventsIngestQueryParams) error

PostBulkEventsIngestion ...

func PostEventsIngestion added in v0.10.0

func PostEventsIngestion(body interface{}, pathParams *map[string]string, queryParams *EventsIngestQueryParams) error

PostEventsInjestion ...

func PurgeSubscription added in v0.12.0

func PurgeSubscription(subscriptionID int64, customerID int64, cascadeCustomer bool, cascadePayment bool) error

PurgeSubscription purges a subscription from an account IN TEST MODE. This WILL NOT WORK on production environments.

func RemoveDelayedSubscriptionCancellation

func RemoveDelayedSubscriptionCancellation(subscriptionID int64) error

RemoveDelayedSubscriptionCancellation removes a delayed cancellation request, ensuring the subscription does not cancel

func SavePaymentProfileForCustomer

func SavePaymentProfileForCustomer(customerID int64, input *PaymentProfile) error

SavePaymentProfileForCustomer saves a new payment profile. Note that this is a raw save; for ease of use it may be better to use one of the other SavePaymentProfile* methods

func SetCredentials added in v0.7.0

func SetCredentials(subdomain, apiKey string)

SetCredentials allows changing the credentials after initialization, such as when testing and the environment isn't setup

func ToBool added in v0.12.0

func ToBool(input *bool) bool

ToBool takes a pointer and gives the value

func ToFloat64 added in v0.12.0

func ToFloat64(input *float64) float64

ToFloat64 takes a pointer and gives the value

func ToInt added in v0.12.0

func ToInt(input *int) int

ToInt takes a pointer and gives the value

func ToInt64 added in v0.12.0

func ToInt64(input *int64) int64

ToInt64 takes a pointer and gives the value

func ToString added in v0.12.0

func ToString(input *string) string

ToString takes a pointer and gives the value

func UpdateCustomer added in v0.8.2

func UpdateCustomer(input *Customer) error

UpdateCustomer updates a customer in chargify

func UpdatePaymentProfile

func UpdatePaymentProfile(input *PaymentProfile) error

UpdatePaymentProfile updates a payment profile

func UpdateProduct

func UpdateProduct(productID int64, input *Product) error

UpdateProduct updates a product

func UpdateSubscription added in v0.8.3

func UpdateSubscription(subscriptionID int64, productHandle string) error

UpdateSubscription updates a subscription for a customer

Types

type APIReturn

type APIReturn struct {
	StatusCode string      `json:"statusCode"`
	HTTPCode   int         `json:"httpCode"`
	Body       interface{} `json:"body"`
}

APIReturn represents the return of the API calls

type AllocationDetail added in v0.10.0

type AllocationDetail struct {
	AllocationID  int `json:"allocation_id" mapstructure:"allocation_id"`
	ChargeID      int `json:"charge_id" mapstructure:"charge_id"`
	UsageQuantity int `json:"usage_quantity" mapstructure:"usage_quantity"`
}

type BillingPortal added in v0.6.0

type BillingPortal struct {
	URL                string `json:"url" mapstructure:"url"`
	FetchCount         int64  `json:"fetch_count" mapstructure:"fetch_count"`
	CreatedAt          string `json:"created_at" mapstructure:"created_at"`
	NewLinkAvailableAt string `json:"new_link_available_at" mapstructure:"new_link_available_at"`
	ExpiresAt          string `json:"expires_at" mapstructure:"expires_at"`
}

BillingPortal represents a self-service management portal on the Chargify web site. 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.

func GetBillingPortal added in v0.6.0

func GetBillingPortal(customerID int64) (*BillingPortal, error)

GetBillingPortal gets the billing portal information for the customer

type Count added in v0.10.0

type Count struct {
	Count int `json:"count,omitempty" mapstructure:"count,omitempty"`
}

func GetEventsCount added in v0.10.0

func GetEventsCount(queryParams *ListEventsCountQueryParams) (response *Count, err error)

GetEventsCount ...

type Coupon added in v0.9.0

type Coupon struct {
	ID              int64  `json:"id"`
	Name            string `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string `json:"description" mapstructure:"description"`             // The (optionally required?) description for the coupon
	Percentage      int    `json:"percentage" mapstructure:"percentage"`               //	The percentage value of the coupon
	AmountInCents   int64  `json:"amount_in_cents" mapstructure:"amount_in_cents"`     //	The amount_in_cents value of the coupon
	Recurring       string `json:"recurring" mapstructure:"recurring"`                 //	A string value for the boolean of whether or not this coupon is recurring
	ProductFamilyID string `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

Coupon is a coupons structure

type CouponReturn added in v0.11.0

type CouponReturn struct {
	ID              int64   `json:"id"`
	Name            string  `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string  `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string  `json:"description" mapstructure:"description"`             // The (optionally required?) description for the coupon
	Percentage      string  `json:"percentage" mapstructure:"percentage"`               //	The percentage value of the coupon
	AmountInCents   int64   `json:"amount_in_cents" mapstructure:"amount_in_cents"`     //	The amount_in_cents value of the coupon
	Recurring       bool    `json:"recurring" mapstructure:"recurring"`                 //	A string value for the boolean of whether or not this coupon is recurring
	ProductFamilyID float64 `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

CouponReturn is what we give back on the request

func GetCouponByCode added in v0.9.0

func GetCouponByCode(productFamilyID int64, code string) (*CouponReturn, error)

GetCouponByCode gets a coupon by its code

func ListCoupons added in v0.12.0

func ListCoupons(params *ListCouponsQueryParams) ([]CouponReturn, error)

ListCoupons lists out the coupons based upon the result of the passed in query params

type Customer

type Customer struct {
	ID                         int64    `json:"id" mapstructure:"id"`                 //	The customer ID in Chargify
	FirstName                  string   `json:"first_name" mapstructure:"first_name"` //	The first name of the customer
	LastName                   string   `json:"last_name" mapstructure:"last_name"`   //	The last name of the customer
	Email                      string   `json:"email" mapstructure:"email"`           //	The email address of the customer
	CCEmailsRaw                string   `json:"cc_emails" mapstructure:"cc_emails"`   //	(Optional) A comma-separated list of emails that should be cc’d on all customer communications (i.e. “joe@example.com, sue@example.com”)
	CCEmails                   []string // the proccessed CC emails
	Organization               string   `json:"organization" mapstructure:"organization"`                                     //	The organization of the customer
	Reference                  string   `json:"reference" mapstructure:"reference"`                                           //	The unique identifier used within your own application for this customer
	CreatedAt                  string   `json:"created_at" mapstructure:"created_at"`                                         //	The timestamp in which the customer object was created in Chargify
	UpdatedAt                  string   `json:"updated_at" mapstructure:"updated_at"`                                         //	The timestamp in which the customer object was last edited
	Address                    string   `json:"address" mapstructure:"address"`                                               //	The customer’s shipping street address (i.e. “123 Main St.”)
	Address2                   string   `json:"address_2" mapstructure:"address_2"`                                           //	Second line of the customer’s shipping address i.e. “Apt. 100”
	City                       string   `json:"city" mapstructure:"city"`                                                     //	The customer’s shipping address city (i.e. “Boston”)
	State                      string   `json:"state" mapstructure:"state"`                                                   //	The customer’s shipping address state (i.e. “MA”)
	Zip                        string   `json:"zip" mapstructure:"zip"`                                                       //	The customer’s shipping address zip code (i.e. “12345”)
	Country                    string   `json:"country" mapstructure:"country"`                                               //	The customer shipping address country, perferably in  format (i.e. “US”)
	Phone                      string   `json:"phone" mapstructure:"phone"`                                                   //	The phone number of the customer
	Verified                   bool     `json:"verified" mapstructure:"verified"`                                             //	Is the customer verified to use ACH as a payment method. Available only on Authorize.Net gateway
	PortalCustomerCreatedAt    string   `json:"portal_customer_created_at" mapstructure:"portal_customer_created_at"`         //	The timestamp of when the Billing Portal entry was created at for the customer
	PortalInviteLastSentAt     string   `json:"portal_invite_last_sent_at" mapstructure:"portal_invite_last_sent_at"`         //	The timestamp of when the Billing Portal invite was last sent at
	PortalInviteLastAcceptedAt string   `json:"portal_invite_last_accepted_at" mapstructure:"portal_invite_last_accepted_at"` //	The timestamp of when the Billing Portal invite was last accepted
	TaxExempt                  bool     `json:"tax_exempt" mapstructure:"tax_exempt"`                                         //	(Optional) The tax exempt status for the customer. Acceptable values are true or 1 for true and false or 0 for false.
	VatNumber                  string   `json:"vat_number" mapstructure:"vat_number"`                                         //	(Optional) The VAT number, if applicable
}

Customer is a single customer in the chargify account

func CreateCustomer

func CreateCustomer(input *Customer) (*Customer, error)

CreateCustomer creates a new customer on chargify

func GetCustomerByID added in v0.10.0

func GetCustomerByID(id int) (*Customer, error)

GetCustomerByID gets a customer by chargify id

func GetCustomerByReference added in v0.10.0

func GetCustomerByReference(reference string) (*Customer, error)

GetCustomerByReference gets a customer by reference

func GetCustomers

func GetCustomers(page int, sortDir string) (found []Customer, err error)

GetCustomers gets the customers for the site

func SearchForCustomerByReference

func SearchForCustomerByReference(reference string) (Customer, error)

SearchForCustomerByReference searches for a customer by it's reference value. It first performs the large search then looks for the substring in the returned values

func SearchForCustomersByEmail

func SearchForCustomersByEmail(email string) ([]Customer, error)

SearchForCustomersByEmail searches for customers with a specific email address; multiple can exist

func SearchForCustomersByReference added in v0.7.2

func SearchForCustomersByReference(reference string) ([]Customer, error)

SearchForCustomersByReference searches all of the customers for a specific reference

type Event added in v0.10.0

type Event struct {
	ID                int64             `json:"id" mapstructure:"id"` //	The customer ID in Chargify
	Key               string            `json:"key" mapstructure:"key"`
	Message           string            `json:"message" mapstructure:"message"`
	Subscription_id   int               `json:"subscription_id" mapstructure:"subscription_id"`
	CustomerID        int               `json:"customer_id" mapstructure:"customer_id"`
	CreatedAt         string            `json:"created_at" mapstructure:"created_at"`
	EventSpecificData EventSpecificData `json:"event_specific_data" mapstructure:"event_specific_data"`
}

func ListEvents added in v0.10.0

func ListEvents(queryParams *ListEventsQueryParams) (found []Event, err error)

GetCustomerByID gets a customer by chargify id

func ListSubscriptionEvents added in v0.10.0

func ListSubscriptionEvents(subscriptionID int, queryParams *ListSubscriptionEventsQueryParams) (found []Event, err error)

GetCustomerByID gets a customer by chargify id

type EventSpecificData added in v0.10.0

type EventSpecificData struct {
	PreviousUnitBalance        string             `json:"previous_unit_balance" mapstructure:"previous_unit_balance"`
	PreviousOverageUnitBalance string             `json:"previous_overage_unit_balance" mapstructure:"previous_overage_unit_balance"`
	NewUnitBalance             int                `json:"new_unit_balance" mapstructure:"new_unit_balance"`
	NewOverageUnitBalance      int                `json:"new_overage_unit_balance" mapstructure:"new_overage_unit_balance"`
	UsageQuantity              int                `json:"usage_quantity" mapstructure:"usage_quantity"`
	OverageUsageQuantity       int                `json:"overage_usage_quantity" mapstructure:"overage_usage_quantity"`
	ComponentID                int                `json:"component_id" mapstructure:"component_id"`
	ComponentHandle            string             `json:"component_handle" mapstructure:"component_handle"`
	Memo                       string             `json:"memo" mapstructure:"memo"`
	AllocationDetails          []AllocationDetail `json:"allocation_details" mapstructure:"allocation_details"`
}

type EventsIngestQueryParams added in v0.10.0

type EventsIngestQueryParams struct {
	StoreUID *string `json:"store_uid,omitempty" mapstructure:"store_uid,omitempty"`
}

type FlatCoupon added in v0.9.1

type FlatCoupon struct {
	Name            string `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string `json:"description" mapstructure:"description"`             //   The (optionally required?) description for the coupon
	AmountInCents   int64  `json:"amount_in_cents" mapstructure:"amount_in_cents"`     //	The amount_in_cents value of the coupon
	Recurring       string `json:"recurring" mapstructure:"recurring"`                 //	A string value for the boolean of whether or not this coupon is recurring
	ProductFamilyID string `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

FlatCoupon is the structure of what we need to send to Chargify when creating a flat rate coupon

type FlatCouponReturn added in v0.9.1

type FlatCouponReturn struct {
	Name            string  `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string  `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string  `json:"description" mapstructure:"description"`             //  The (optionally required?) description for the coupon
	AmountInCents   int64   `json:"amount_in_cents" mapstructure:"amount_in_cents"`     //	The amount_in_cents value of the coupon
	Recurring       bool    `json:"recurring" mapstructure:"recurring"`                 //	A boolean of whether or not this coupon is recurring
	ProductFamilyID float64 `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

FlatCouponReturn is here because Chargify send back different types than what it asks for

func CreateFlatCoupon added in v0.9.1

func CreateFlatCoupon(productFamilyID int64, input *FlatCoupon) (*FlatCouponReturn, error)

CreateFlatCoupon creates a new flat rate coupon

type Invoice added in v0.8.0

type Invoice struct {
	UID               string    `json:"uid,omitempty" mapstructure:"uid"`
	SiteID            int64     `json:"site_id,omitempty" mapstructure:"site_id"`
	CustomerID        int64     `json:"customer_id,omitempty" mapstructure:"customer_id"`
	SubscriptionID    int64     `json:"subscription_id,omitempty" mapstructure:"subscription_id"`
	Number            string    `json:"number,omitempty" mapstructure:"number"`
	SequenceNumber    int64     `json:"sequence_number,omitempty" mapstructure:"sequence_number"`
	IssueDate         string    `json:"issue_date,omitempty" mapstructure:"issue_date"`
	DueDate           string    `json:"due_date,omitempty" mapstructure:"due_date"`
	PaidDate          string    `json:"paid_date,omitempty" mapstructure:"paid_date"`
	Status            string    `json:"status,omitempty" mapstructure:"status"`
	Currency          string    `json:"currency,omitempty" mapstructure:"currency"`
	ProductName       string    `json:"product_name,omitempty" mapstructure:"product_name"`
	ProductFamilyName string    `json:"product_family_name,omitempty" mapstructure:"product_family_name"`
	Customer          Customer  `json:"customer,omitempty" mapstructure:"customer"`
	Payments          []Payment `json:"payments,omitempty" mapstructure:"payments"`
	Refunds           []Refund  `json:"refunds,omitempty" mapstructure:"refunds"`
}

Invoice is a relationship invoice on Chargify. Note that not all fields are currently implemented, as there are over 145 properties on an invoice

func GetInvoiceByID added in v0.8.0

func GetInvoiceByID(invoiceID int64) (*Invoice, error)

GetInvoiceByID gets a single relationship invoice

func GetInvoices added in v0.8.0

func GetInvoices(queryParams *InvoiceQueryParams) ([]Invoice, error)

GetInvoices searched for invoices based upon passed-in params

func RefundInvoice added in v0.8.0

func RefundInvoice(invoiceID, amount, memo string, paymentID int64, external, applyCredit, voidInvoice bool) (*Invoice, error)

RefundInvoice refunds a single invoice. Note that the amount is a string, which expects a decimal. This is unusual and will catch you off guard if you are not carefule. So, for example, pass in "10.50" for ten dollars and fifty cents. Also note that the required fields are amount, memo, and paymentID

type InvoiceQueryParams added in v0.8.0

type InvoiceQueryParams struct {
	StartDate      string `json:"start_date,omitempty" mapstructure:"start_date"`
	EndDate        string `json:"end_date,omitempty" mapstructure:"end_date"`
	Status         string `json:"status,omitempty" mapstructure:"status"`
	SubscriptionID int64  `json:"subscription_id,omitempty" mapstructure:"subscription_id"`
	Page           int64  `json:"page,omitempty" mapstructure:"page"`
	PerPage        int64  `json:"per_page,omitempty" mapstructure:"per_page"`
	Direction      string `json:"direction,omitempty" mapstructure:"direction"`
}

InvoiceQueryParams are a collection of implemented query params to pass in to the invoice get call

type ListCouponsQueryParams added in v0.12.0

type ListCouponsQueryParams struct {
	CurrencyPrices *bool    `json:"currency_prices"`
	Page           *int     `json:"page"`
	PerPage        *int     `json:"per_page"`
	Codes          []string `json:"codes"`
	DateField      *string  `json:"date_field"`
	EndDate        *string  `json:"end_date"`
	EndDateTime    *string  `json:"end_datetime"`
	IDs            []string `json:"ids"`
	StartDate      *string  `json:"start_date"`
	StartDateTime  *string  `json:"start_date_time"`
}

ListCouponsQueryParams are the query params for coupon listing. Note that a lot of the fields were deprecated as they now prefer a query string array of filter indexes, but we expose the higher-level fields and consolidate it on the call

type ListEventsCountQueryParams added in v0.10.0

type ListEventsCountQueryParams struct {
	Page      *int    `json:"page,omitempty" mapstructure:"page,omitempty"`
	PerPage   *int    `json:"per_page,omitempty" mapstructure:"per_page,omitempty"`
	SinceID   *int    `json:"since_id,omitempty" mapstructure:"since_id,omitempty"`
	MaxID     *int    `json:"max_id,omitempty" mapstructure:"max_id,omitempty"`
	Direction *string `json:"direction,omitempty" mapstructure:"direction,omitempty"`
	Filter    *string `json:"filter,omitempty" mapstructure:"filter,omitempty"`
}

type ListEventsQueryParams added in v0.10.0

type ListEventsQueryParams struct {
	Page          *int    `json:"page,omitempty" mapstructure:"page,omitempty"`
	PerPage       *int    `json:"per_page,omitempty" mapstructure:"per_page,omitempty"`
	SinceID       *int    `json:"since_id,omitempty" mapstructure:"since_id,omitempty"`
	MaxID         *int    `json:"max_id,omitempty" mapstructure:"max_id,omitempty"`
	Direction     *string `json:"direction,omitempty" mapstructure:"direction,omitempty"`
	Filter        *string `json:"filter,omitempty" mapstructure:"filter,omitempty"`
	DateField     *string `json:"date_field,omitempty" mapstructure:"date_field,omitempty"`
	StartDate     *string `json:"start_date,omitempty" mapstructure:"start_date,omitempty"`
	EndDate       *string `json:"end_date,omitempty" mapstructure:"end_date,omitempty"`
	StartDatetime *string `json:"start_datetime,omitempty" mapstructure:"start_datetime,omitempty"`
	EndDatetime   *string `json:"end_datetime,omitempty" mapstructure:"end_datetime,omitempty"`
}

type ListSubscriptionEventsQueryParams added in v0.10.0

type ListSubscriptionEventsQueryParams struct {
	Page      *int    `json:"page,omitempty" mapstructure:"page,omitempty"`
	PerPage   *int    `json:"per_page,omitempty" mapstructure:"per_page,omitempty"`
	SinceID   *int    `json:"since_id,omitempty" mapstructure:"since_id,omitempty"`
	MaxID     *int    `json:"max_id,omitempty" mapstructure:"max_id,omitempty"`
	Direction *string `json:"direction,omitempty" mapstructure:"direction,omitempty"`
	Filter    *string `json:"filter,omitempty" mapstructure:"filter,omitempty"`
}

type ListSubscriptionsQueryParams added in v0.12.0

type ListSubscriptionsQueryParams struct {
	Coupon              *int64  `json:"coupon"`
	DateField           *string `json:"date_field"`
	Direction           *string `json:"direction"`
	EndDate             *string `json:"end_date"`
	EndDateTime         *string `json:"end_datetime"`
	Page                *int    `json:"page"`
	PerPage             *int    `json:"per_page"`
	Product             *string `json:"product"`
	ProductPricePointID *int64  `json:"product_price_point_id"`
	Sort                *string `json:"sort"`
	StartDate           *string `json:"start_date"`
	StartDateTime       *string `json:"start_datetime"`
	State               *string `json:"state"`
}

ListSubscriptionsQueryParams are the query parameters for listing subscriptions; see: https://developers.chargify.com/docs/api-docs/51c68dd4dcb2b-list-subscriptions

type MetaData added in v0.6.0

type MetaData struct {
	TotalCount  int64           `json:"total_count" mapstructure:"total_count"`
	CurrentPage int64           `json:"current_page" mapstructure:"current_page"`
	TotalPages  int64           `json:"total_pages" mapstructure:"total_pages"`
	PerPage     int64           `json:"per_page" mapstructure:"per_page"`
	MetaData    []MetaDataEntry `json:"metadata" mapstructure:"metadata"`
}

MetaData represents a pageable return of a metadata request

func GetSubscriptionMetaData added in v0.6.0

func GetSubscriptionMetaData(subscriptionID int64) (*MetaData, error)

GetSubscriptionMetaData gets the subscription metadata

type MetaDataEntry added in v0.6.0

type MetaDataEntry struct {
	Value      string `json:"value" mapstructure:"value"`
	ResourceID int64  `json:"resource_id" mapstructure:"resource_id"`
	Name       string `json:"name" mapstructure:"name"`
}

MetaDataEntry represents a single key/value meta data entry

type Payment added in v0.8.0

type Payment struct {
	TransactionTime string        `json:"transaction_time" mapstructure:"transaction_time"`
	Memo            string        `json:"memo" mapstructure:"memo"`
	OriginalAmount  string        `json:"original_amount" mapstructure:"original_amount"`
	AppliedAmount   string        `json:"applied_amount" mapstructure:"applied_amount"`
	TransactionID   int64         `json:"transaction_id" mapstructure:"transaction_id"`
	Prepayment      bool          `json:"prepayment" mapstructure:"prepayment"`
	PaymentMethod   PaymentMethod `json:"payment_method" mapstructure:"payment_method"`
}

Payment represents a single payment on an invoice, for example

type PaymentMethod added in v0.8.0

type PaymentMethod struct {
	Details          string `json:"details" mapstructure:"details"`
	Kind             string `json:"kind" mapstructure:"kind"`
	Memo             string `json:"memo" mapstructure:"memo"`
	PaymentType      string `json:"payment_type" mapstructure:"payment_type"`
	CardBrand        string `json:"card_brand" mapstructure:"card_brand"`
	CardExpiration   string `json:"card_expiration" mapstructure:"card_expiration"`
	LastFour         string `json:"last_four" mapstructure:"last_four"`
	MaskedCardNumber string `json:"masked_card_number" mapstructure:"masked_card_number"`
}

PaymentMethod represents a payment method, found on a payment struct

type PaymentProfile

type PaymentProfile struct {
	ID                    int64       `json:"id" mapstructure:"id"`                                             // the id after the profile is created
	SubscriptionID        int64       `json:"subscription" mapstructure:"subscription"`                         // the subscription id after the profile is created
	PaymentType           string      `json:"payment_type" mapstructure:"payment_type"`                         // (Optional) Default is credit_card. May be bank_account or credit_card or paypal_account.
	CustomerID            int64       `json:"customer_id" mapstructure:"customer_id"`                           // 	(Required when creating a new payment profile) The Chargify customer id.
	FirstName             string      `json:"first_name" mapstructure:"first_name"`                             // 	First name on card or bank account
	LastName              string      `json:"last_name" mapstructure:"last_name"`                               // 	Last name on card or bank account
	FullNumber            string      `json:"full_number" mapstructure:"full_number"`                           // 	(Required when payment_type is credit_card unless you provide the vault_token) The full credit card number (string representation, i.e. 5424000000000015)
	ExpirationMonth       string      `json:"expiration_month" mapstructure:"expiration_month"`                 // 	(Required when payment_type is credit_card unless you provide the vault_token) The 1- or 2-digit credit card expiration month, as an integer or string, i.e. 5
	ExpirationYear        string      `json:"expiration_year" mapstructure:"expiration_year"`                   // 	(Required when payment_type is credit_card unless you provide the vault_token) The 4-digit credit card expiration year, as an integer or string, i.e. 2012
	CVV                   string      `json:"cvv" mapstructure:"cvv"`                                           // 	(Optional, may be required by your gateway settings) The 3- or 4-digit Card Verification Value. This value is merely passed through to the payment gateway.
	BillingAddress        string      `json:"billing_address" mapstructure:"billing_address"`                   // 	(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing street address (i.e. 123 Main St.). This value is merely passed through to the payment gateway.
	BillingAddress2       string      `json:"billing_address_2" mapstructure:"billing_address_2"`               // 	(Optional) Second line of the customer’s billing address i.e. Apt. 100
	BillingCity           string      `json:"billing_city" mapstructure:"billing_city"`                         // 	(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address city (i.e. Boston). This value is merely passed through to the payment gateway.
	BillingState          string      `json:"billing_state" mapstructure:"billing_state"`                       // 	(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway.
	BillingZip            string      `json:"billing_zip" mapstructure:"billing_zip"`                           // 	(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address zip code (i.e. “12345”). This value is merely passed through to the payment gateway.
	BillingCountry        string      `json:"billing_country" mapstructure:"billing_country"`                   // 	(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, preferably in  format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time.
	BankName              string      `json:"bank_name" mapstructure:"bank_name"`                               // 	(Required when creating a subscription with ACH) The name of the bank where the customer’s account resides
	BankRouting           string      `json:"bank_routing_number" mapstructure:"bank_routing_number"`           // 	(Required when creating a subscription with ACH) The routing number of the bank
	BankAccount           string      `json:"bank_account_number" mapstructure:"bank_account_number"`           // 	Required when creating a subscription with ACH) The customer’s bank account number
	BankAccountType       string      `json:"bank_account_type" mapstructure:"bank_account_type"`               // 	When payment_type is bank_account, this defaults to checking and cannot be changed
	BankAccountHolderType string      `json:"bank_account_holder_type" mapstructure:"bank_account_holder_type"` // 	When payment_type is bank_account, may be personal (default) or business
	Verified              bool        `json:"verified,omitempty" mapstructure:"verified"`                       // 	When payment type is bank_account and current_vault is stripe_connect, may be set to true to indicate that the bank account has already been verified.
	PaypalEmail           string      `json:"paypal_email" mapstructure:"paypal_email"`                         //
	PaymentMethodNonce    string      `json:"payment_method_nonce" mapstructure:"payment_method_nonce"`         //
	VaultToken            string      `json:"vault_token" mapstructure:"vault_token"`                           // 	(Only allowed during the creation of a new payment profile.) If you have an existing vault_token from your gateway, you may associate it with this new payment profile.
	ChargifyToken         string      `json:"chargify_token" mapstructure:"chargify_token"`                     // 	(Optional) Token received after sending billing informations using . This token must be passed along with customer_id attribute (i.e. tok_9g6hw85pnpt6knmskpwp4ttt)
	CurrentVault          VaultMethod `json:"current_vault" mapstructure:"current_vault"`                       // 	(Required when you pass in a vault_token.) Will be one of the following: bogus (for testing), authorizenet, authorizenet_cim, beanstream, bpoint, braintree_blue, chargify, cybersource, elavon, eway, eway_rapid_std , firstdata, fusebox, litle, moneris, moneris_us, orbital, payment_express, paymill, pin, quickpay, square, stripe_connect, trust_commerce, wirecard. Provides a hint about where the credit card details represented by vault_token are stored, however transactions will always be sent to the gateway configured in the Site's settings.
	CardType              string      `json:"card_type" mapstructure:"card_type"`                               // 	Can be any of the following visa, master, discover, american_express, diners_club, jcb, switch, solo, dankort, maestro, forbrugsforeningen, laser
}

PaymentProfile represents a payment profile. Note that many of the fields that are "numbers" are actually strings due to leading 0s. A lot of these are omitempty since certain fields are only used in certain calls and the API can get confused easily

func SavePaymentProfileACH

func SavePaymentProfileACH(customerID int64, bankName, bankRoutingNumber, bankAccountNumber, bankAccountType, bankAccountHolderType string) (*PaymentProfile, error)

SavePaymentProfileACH saves a payment profile using ACH

func SavePaymentProfileVault

func SavePaymentProfileVault(customerID int64, vault VaultMethod, vaultToken string) (*PaymentProfile, error)

SavePaymentProfileVault saves a payment profile using a vault

type PercentageCoupon added in v0.9.1

type PercentageCoupon struct {
	Name            string `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string `json:"description" mapstructure:"description"`             //   The (optionally required?) description for the coupon
	Percentage      int    `json:"percentage" mapstructure:"percentage"`               //	The percentage value of the coupon
	Recurring       string `json:"recurring" mapstructure:"recurring"`                 //	A string value for the boolean of whether or not this coupon is recurring
	ProductFamilyID string `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

PercentageCoupon is the structure of what we need to send to Chargify when creating a percentage-based coupon

type PercentageCouponReturn added in v0.9.1

type PercentageCouponReturn struct {
	Name            string  `json:"name" mapstructure:"name"`                           //	The coupon name
	Code            string  `json:"code" mapstructure:"code"`                           //	The coupon code
	Description     string  `json:"description" mapstructure:"description"`             //  The (optionally required?) description for the coupon
	Percentage      string  `json:"percentage" mapstructure:"percentage"`               //	The percentage value of the coupon
	Recurring       bool    `json:"recurring" mapstructure:"recurring"`                 //	A boolean of whether or not this coupon is recurring
	ProductFamilyID float64 `json:"product_family_id" mapstructure:"product_family_id"` //	The id for the product family
}

PercentageCouponReturn is here because Chargify send back different types than what it asks for

func CreatePercentageCoupon added in v0.9.1

func CreatePercentageCoupon(productFamilyID int64, input *PercentageCoupon) (*PercentageCouponReturn, error)

CreateCoupon creates a new percent based coupon

type Price added in v0.10.0

type Price struct {
	ID                 int64  `json:"id"`
	ComponentID        int64  `json:"component_id" mapstructure:"component_id"`
	StartingQuantity   int64  `json:"starting_quantity" mapstructure:"starting_quantity"`
	EndingQuantity     int64  `json:"ending_quantity" mapstructure:"ending_quantity"`
	UnitPrice          string `json:"unit_price" mapstructure:"unit_price"`
	PricePointID       int64  `json:"price_point_id" mapstructure:"price_point_id"`
	FormattedUnitPrice string `json:"formatted_unit_price" mapstructure:"formatted_unit_price"`
}

type Product

type Product struct {
	ID                      int64           `json:"id"`
	PriceInCents            int             `json:"price_in_cents" mapstructure:"price_in_cents"`                       //	The product price, in integer cents
	Name                    string          `json:"name" mapstructure:"name"`                                           //	The product name
	Handle                  string          `json:"handle" mapstructure:"handle"`                                       //	The product API handle
	Description             string          `json:"description" mapstructure:"description"`                             //	The product description
	ProductFamily           *ProductFamily  `json:"product_family" mapstructure:"product_family"`                       //	Nested attributes pertaining to the product family to which this product belongs
	IntervalUnit            ProductInterval `json:"interval_unit" mapstructure:"interval_unit"`                         // A string representing the interval unit for this product, either month or day
	IntervalValue           int             `json:"interval,omitempty" mapstructure:"interval"`                         // The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product would renew every 30 days
	InitialChargeInCents    int             `json:"initial_charge_in_cents" mapstructure:"initial_charge_in_cents"`     // The up front charge you have specified.
	TrialPriceInCents       *int            `json:"trial_price_in_cents,omitempty" mapstructure:"trial_price_in_cents"` // The price of the trial period for a subscription to this product, in integer cents.
	TrialIntervalValue      *int            `json:"trial_interval,omitempty" mapstructure:"trial_interval"`             // A numerical interval for the length of the trial period of a subscription to this product. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval
	TrialIntervalUnit       ProductInterval `json:"trial_interval_unit" mapstructure:"trial_interval_unit"`             // A string representing the trial interval unit for this product, either month or day
	ExpirationIntervalValue *int            `json:"expiration_interval,omitempty" mapstructure:"expiration_interval"`   // A numerical interval for the length a subscription to this product will run before it expires. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval
	ExpirationIntervalUnit  ProductInterval `json:"expiration_interval_unit" mapstructure:"expiration_interval_unit"`   // A string representing the trial interval unit for this product, either month or day
	VersionNumber           float64         `json:"version_number" mapstructure:"version_number"`                       // The version of the product
	UpdateReturnURL         string          `json:"update_return_url" mapstructure:"update_return_url"`                 // The url to which a customer will be returned after a successful account update
	UpdateReturnParams      string          `json:"update_return_params" mapstructure:"update_return_params"`           // The parameters will append to the url after a successful account update
	RequireCreditCard       bool            `json:"require_credit_card" mapstructure:"require_credit_card"`             // Boolean
	RequestCreditCard       bool            `json:"request_credit_card" mapstructure:"request_credit_card"`             // Boolean
	CreatedAt               string          `json:"created_at" mapstructure:"created_at"`                               // Timestamp indicating when this product was created
	UpdatedAt               string          `json:"updated_at" mapstructure:"updated_at"`                               // Timestamp indicating when this product was last updated
	Archived                string          `json:"archived_at" mapstructure:"archived_at"`                             // Timestamp indicating when this product was archived
	SignupPages             *[]SignupPage   `json:"public_signup_pages" mapstructure:"public_signup_pages"`             // An array of signup pages
	AutoCreateSignupPage    bool            `json:"auto_create_signup_page" mapstructure:"auto_create_signup_page"`     // Whether or not to create a signup page
	TaxCode                 string          `json:"tax_code" mapstructure:"tax_code"`                                   // A string representing the tax code related to the product type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters.

}

Product represents a single product

func GetProductByHandle

func GetProductByHandle(handle string) (*Product, error)

GetProductByHandle gets a product by its handle

func GetProductByID

func GetProductByID(productID int64) (*Product, error)

GetProductByID gets a single product by id

func GetProductFamilyProducts added in v0.10.0

func GetProductFamilyProducts(id int64) ([]Product, error)

GetProductFamilyProducts gets products in a family

func GetProductsInFamily

func GetProductsInFamily(productFamilyID int64) ([]Product, error)

GetProductsInFamily gets all of the products in a family

type ProductFamily

type ProductFamily struct {
	ID             int64  `json:"id"`
	Name           string `json:"name" mapstructure:"name"`                       //	The product family name
	Handle         string `json:"handle" mapstructure:"handle"`                   //	The product family API handle
	AccountingCode string `json:"accounting_code" mapstructure:"accounting_code"` // The product family accounting code (has no bearing in Chargify, may be used within your app)
	Description    string `json:"description" mapstructure:"description"`         // The product family description
	CreatedAt      string `json:"created_at" mapstructure:"created_at"`
	UpdatedAt      string `json:"updated_at" mapstructure:"updated_at"`
}

ProductFamily represents a product family

func CreateProductFamily

func CreateProductFamily(name, description, handle string, accountingCode string) (*ProductFamily, error)

CreateProductFamily creates a new product family

func GetProductFamilies added in v0.10.0

func GetProductFamilies() ([]ProductFamily, error)

GetProductFamily gets a product family

func GetProductFamily

func GetProductFamily(productFamilyID int64) (*ProductFamily, error)

GetProductFamily gets a product family

type ProductFamilyComponent added in v0.13.0

type ProductFamilyComponent struct {
	ID                        int64   `json:"id"`
	Name                      string  `json:"name" mapstructure:"name"`
	Handle                    string  `json:"handle" mapstructure:"handle"`
	Description               string  `json:"description" mapstructure:"description"`
	PricingScheme             string  `json:"pricing_scheme" mapstructure:"pricing_scheme"`
	UnitName                  string  `json:"unit_name" mapstructure:"unit_name"`
	UnitPrice                 *string `json:"unit_price" mapstructure:"unit_price"`
	ProductFamilyID           int64   `json:"product_family_id" mapstructure:"product_family_id"`
	ProductFamilyName         string  `json:"product_family_name" mapstructure:"product_family_name"`
	Kind                      string  `json:"kind" mapstructure:"kind"`
	Archived                  bool    `json:"archived" mapstructure:"archived"`
	Taxable                   bool    `json:"taxable" mapstructure:"taxable"`
	DefaultPricePointID       int64   `json:"default_price_point_id" mapstructure:"default_price_point_id"`
	PricePointCount           int64   `json:"price_point_count" mapstructure:"price_point_count"`
	PricePointsUrl            string  `json:"price_points_url" mapstructure:"price_points_url"`
	TaxCode                   int64   `json:"tax_code" mapstructure:"tax_code"`
	Recurring                 bool    `json:"recurring" mapstructure:"recurring"`
	UpgradeCharge             *string `json:"upgrade_charge" mapstructure:"upgrade_charge"`
	DowngradeCredit           *string `json:"downgrade_credit" mapstructure:"downgrade_credit"`
	DefaultPricePointName     string  `json:"default_price_point_name" mapstructure:"default_price_point_name"`
	HideDateRangeOnInvoice    bool    `json:"hide_date_range_on_invoice" mapstructure:"hide_date_range_on_invoice"`
	Prices                    []Price `json:"prices" mapstructure:"prices"`
	OveragePrices             []Price `json:"overage_prices" mapstructure:"overage_prices"`
	CreatedAt                 string  `json:"created_at" mapstructure:"created_at"`
	UpdatedAt                 string  `json:"updated_at" mapstructure:"updated_at"`
	AllowFractionalQuantities bool    `json:"allow_fractional_quantities" mapstructure:"allow_fractional_quantities"`
}

ProductFamilyComponent represents a single component for a product family

func GetProductFamilyComponentByHandle added in v0.10.0

func GetProductFamilyComponentByHandle(familyID int64, handle string) (*ProductFamilyComponent, error)

GetProductFamilyComponentByHandle gets components in a family

func GetProductFamilyComponentById added in v0.10.0

func GetProductFamilyComponentById(familyID int64, componentID int64) (*ProductFamilyComponent, error)

GetProductFamilyProducts gets products in a family

func GetProductFamilyComponents added in v0.10.0

func GetProductFamilyComponents(id int64) ([]ProductFamilyComponent, error)

GetProductFamilyProducts gets products in a family

type ProductInterval

type ProductInterval string

ProductInterval represents an interval used for various calculations in a product

var (
	// ProductIntervalMonth represents an interval of month
	ProductIntervalMonth ProductInterval = "month"
	// ProductIntervalDay represents an interval of day
	ProductIntervalDay ProductInterval = "day"
)

type Refund added in v0.8.0

type Refund struct {
	TransactionID  int64  `json:"transaction_id,omitempty" mapstructure:"transaction_id"`
	PaymentID      int64  `json:"payment_id,omitempty" mapstructure:"payment_id"`
	Memo           string `json:"memo,omitempty" mapstructure:"memo"`
	OriginalAmount string `json:"original_amount,omitempty" mapstructure:"original_amount"`
	AppliedAmount  string `json:"applied_amount,omitempty" mapstructure:"applied_amount"`
}

Refund is a single refund issued against an invoice

func RefundSubscriptionPayment added in v0.8.1

func RefundSubscriptionPayment(subscriptionID string, paymentID string, amount string, memo string) (*Refund, error)

RefundSubscriptionPayment refunds a specific payment for a subscription. This is supposedly deprecated to support relationship invoicing

type SignupPage

type SignupPage struct {
	ID           int64  `json:"id"`                                         // The id of the signup page (public_signup_pages only)
	URL          string `json:"url" mapstructure:"url"`                     // The url where the signup page can be viewed (public_signup_pages only)
	ReturnURL    string `json:"return_url" mapstructure:"return_url"`       // The url to which a customer will be returned after a successful signup (public_signup_pages only)
	ReturnParams string `json:"return_params" mapstructure:"return_params"` // The params to be appended to the return_url (public_signup_pages only)
}

SignupPage represents a product's signup page, if needed

type Subscription

type Subscription struct {
	ID                            int64     `json:"id"`
	CancellationMessage           string    `json:"cancellation_message" mapstructure:"cancellation_message"`                                   // (Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about the reason for cancellation.
	CancellationMethod            string    `json:"cancellation_method" mapstructure:"cancellation_method"`                                     // (Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about how the subscription was canceled.
	ReasonCode                    string    `json:"reason_code" mapstructure:"reason_code"`                                                     // (Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to indicate why a subscription was canceled.
	NextBillingAt                 string    `json:"next_billing_at" mapstructure:"next_billing_at"`                                             // (Optional) Set this attribute to a future date/time to sync imported subscriptions to your existing renewal schedule. See the notes on “Date/Time Format” at https://help.chargify.com/subscriptions/subscriptions-import.html. If you provide a next_billing_at timestamp that is in the future, no trial or initial charges will be applied when you create the subscription. In fact, no payment will be captured at all. The first payment will be captured, according to the prices defined by the product, near the time specified by next_billing_at. If you do not provide a value for next_billing_at, any trial and/or initial charges will be assessed and charged at the time of subscription creation. If the card cannot be successfully charged, the subscription will not be created. See further notes in the section on Importing Subscriptions.
	ExpiresAt                     string    `json:"expires_at" mapstructure:"expires_at"`                                                       // Timestamp giving the expiration date of this subscription (if any). You may manually change the expiration date at any point during a subscription period.
	ExpirationTracksChange        bool      `json:"expiration_tracks_next_billing_change" mapstructure:"expiration_tracks_next_billing_change"` // (Optional, default false) When set to true, and when next_billing_at is present, if the subscription expires, the expires_at will be shifted by the same amount of time as the difference between the old and new “next billing” dates.
	VATNumber                     string    `json:"vat_number" mapstructure:"vat_number"`                                                       // (Optional) Supplying the VAT number allows EU customer’s to opt-out of the Value Added Tax assuming the merchant address and customer billing address are not within the same EU country. It’s important to omit the country code from the VAT number upon entry. Otherwise, taxes will be assessed upon the purchase.
	CouponCode                    string    `json:"coupon_code" mapstructure:"coupon_code"`                                                     // (Optional) The coupon code of the coupon to apply ()
	PaymentCollectionMethod       string    `json:"payment_collection_method" mapstructure:"payment_collection_method"`                         // (Optional) The type of payment collection to be used in the subscription. May be automatic, or invoice.
	AgreementTerms                string    `json:"agreement_terms" mapstructure:"agreement_terms"`                                             // (Optional) The ACH authorization agreement terms. If enabled, an email will be sent to the customer with a copy of the terms.
	ACHFirstName                  string    `json:"authorizer_first_name" mapstructure:"authorizer_first_name"`                                 // (Optional) The first name of the person authorizing the ACH agreement.
	ACHLastName                   string    `json:"authorizer_last_name" mapstructure:"authorizer_last_name"`                                   // (Optional) The last name of the person authorizing the ACH agreement.
	ChangeDelayed                 bool      `json:"product_change_delayed" mapstructure:"product_change_delayed"`                               // (Optional, used only for https://reference.chargify.com/v1/subscriptions-product-changes-migrations-upgrades-downgrades/update-subscription-product-change When set to true, indicates that a changed value for product_handle should schedule the product change to the next subscription renewal.
	CalendarBilling               string    `json:"calendar_billing" mapstructure:"calendar_billing"`                                           // (Optional, see https://reference.chargify.com/v1/subscriptions/subscriptions-intro#https://help.chargify.com/subscriptions/billing-dates.html#calendar-billing for more details). Cannot be used when also specifying next_billing_at
	SnapDay                       int       `json:"snap_day" mapstructure:"snap_day"`                                                           // A value between 1 and 28, or end
	CalendarBillingFirstDayCharge string    `json:"calendar_billing_first_charge" mapstructure:"calendar_billing_first_charge"`                 // (Optional) One of “prorated” (the default – the prorated product price will be charged immediately), “immediate” (the full product price will be charged immediately), or “delayed” (the full product price will be charged with the first scheduled renewal).
	ReceivesInvoiceEmails         bool      `json:"receives_invoice_emails" mapstructure:"receives_invoice_emails"`                             // (Optional) Default: True - Whether or not this subscription is set to receive emails related to this subscription.
	Customer                      *Customer `json:"customer,omitempty" mapstructure:"customer"`
	Product                       *Product  `json:"product,omitempty" mapstructure:"product"`
	// some of these are only used on the return
	State string `json:"state,omitempty" mapstructure:"state"` // the state of the subscription
}

Subscription represents a subscription

func CreateSubscriptionForCustomer

func CreateSubscriptionForCustomer(customerReference, productHandle string, paymentProfileID int64, subscriptionOptions *Subscription) (*Subscription, error)

CreateSubscriptionForCustomer creates a new subscription. When creating a subscription, you must specify a product and a customer. The product should be specificed by productHandle and the customer should be specified with customerReference. The subscriptionOptions pointer is useful for specifying select additional options. Right now, only NextChargeAt is supported. The paymentProfileID is optional and is used to associate the subscription with a payment profile. If one is already setup, pass in 0.

func GetCustomerSubscriptions added in v0.10.0

func GetCustomerSubscriptions(customerID int) (found []Subscription, err error)

GetCustomerSubscriptions

func GetSubscription added in v0.5.0

func GetSubscription(subscriptionID int64) (*Subscription, error)

GetSubscription gets a subscription. The docs show it comes back as an array, but as of this implementation it comes back as a map

func ListSubscriptions added in v0.12.0

func ListSubscriptions(params *ListSubscriptionsQueryParams) ([]Subscription, error)

ListSubscriptions lists out the subscriptions based upon the result of the passed in query params

type SubscriptionComponent added in v0.13.0

type SubscriptionComponent struct {
	ComponentID       int64  `json:"component_id" mapstructure:"component_id"`
	SubscriptionID    int64  `json:"subscription_id" mapstructure:"subscription_id"`
	AllocatedQuantity int64  `json:"allocated_quantity" mapstructure:"allocated_quantity"`
	PricingScheme     string `json:"pricing_scheme" mapstructure:"pricing_scheme"`
	Name              string `json:"name" mapstructure:"name"`
	Kind              string `json:"kind" mapstructure:"kind"`
	UnitName          string `json:"unit_name" mapstructure:"unit_name"`
	PricePointID      int64  `json:"price_point_id" mapstructure:"price_point_id"`
	PricePointHandle  string `json:"price_point_handle" mapstructure:"price_point_handle"`
	PricePointType    string `json:"price_point_type" mapstructure:"price_point_type"`
	PricePointName    string `json:"price_point_type" mapstructure:"price_point_type"`
	Enabled           bool   `json:"enabled" mapstructure:"enabled"`
	UnitBalance       int64  `json:"unit_balance" mapstructure:"unit_balance"`
	ID                int64  `json:"id" mapstructure:"id"`
	CreatedAt         string `json:"created_at" mapstructure:"created_at"`
	UpdatedAt         string `json:"updated_at" mapstructure:"updated_at"`
	ComponentHandle   string `json:"component_handle" mapstructure:"component_handle"`
	ArchivedAt        string `json:"archived_at" mapstructure:"archived_at"`
}

func GetSubscriptionComponents added in v0.13.0

func GetSubscriptionComponents(subscriptionID int64) ([]SubscriptionComponent, error)

GetProductFamilyProducts gets products in a family

type VaultMethod

type VaultMethod string

VaultMethod represents one of the payment vaults for use with tokenization. This is generally the recommended way to handle payment methods.

var (
	// VaultBogus represents a bogus vault used for testing
	VaultBogus VaultMethod = "bogus"
	// VaultAuthorize represents the AuthorizeNet vault
	VaultAuthorize VaultMethod = "authorizenet"
	// VaultAuthorizeCIM represents the AuthorizeCIM vault
	VaultAuthorizeCIM VaultMethod = "authorizenet_cim"
	// VaultBeanStream represents the BeanStream vault
	VaultBeanStream VaultMethod = "beanstream"
	// VaultBPoint represents the BPoint vault
	VaultBPoint VaultMethod = "bpoint"
	// VaultBraintree represents the BrainTree vault
	VaultBraintree VaultMethod = "braintree_blue"
	// VaultChargify represents the Chargify vault
	VaultChargify VaultMethod = "chargify"
	// VaultCyberSource represents the CyberSource vault
	VaultCyberSource VaultMethod = "cybersource"
	// VaultElavon represents the Elavon vault
	VaultElavon VaultMethod = "elavon"
	// VaultEWay represents the EWay vault
	VaultEWay VaultMethod = "eway"
	// VaultEWayRapid represents the EWayRapid vault
	VaultEWayRapid VaultMethod = "eway_rapid_std"
	// VaultFirstData represents the FirstData vault
	VaultFirstData VaultMethod = "firstdata"
	// VaultFuseBox represents the FuseBox vault
	VaultFuseBox VaultMethod = "fusebox"
	// VaultLittle represents the Little vault
	VaultLittle VaultMethod = "litle"
	// VaultMoneris represents the Moneris vault
	VaultMoneris VaultMethod = "moneris"
	// VaultMonerisUS represents the Moneris US vault
	VaultMonerisUS VaultMethod = "moneris_us"
	// VaultOrbital represents the Orbital vault
	VaultOrbital VaultMethod = "orbital"
	// VaultPaymentExpress represents the PaymentExpress vault
	VaultPaymentExpress VaultMethod = "payment_express"
	// VaultPaymill represents the PayMill vault
	VaultPaymill VaultMethod = "paymill"
	// VaultPIN represents the PIN vault
	VaultPIN VaultMethod = "pin"
	// VaultQuickPay represents the QuickPay vault
	VaultQuickPay VaultMethod = "quickpay"
	// VaultSquare represents the Square vault
	VaultSquare VaultMethod = "square"
	// VaultStripe represents the Stripe vault
	VaultStripe VaultMethod = "stripe_connect"
	// VaultTrustCommerce represents the TrustCommerce vault
	VaultTrustCommerce VaultMethod = "trust_commerce"
	// VaultWireCard represents the WireCard vault
	VaultWireCard VaultMethod = "wirecard"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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