Documentation ¶
Index ¶
- func ArchiveCoupon(productFamilyID, couponId int64) error
- func ArchiveProduct(productID int64) error
- func CancelSubscription(subscriptionID int64, cancelImmediately bool, reasonCode string, ...) error
- func ConvertJSONFloatToInt(input interface{}) (int64, error)
- func CreateCoupon(productFamilyID int64, input *Coupon) error
- func CreateProduct(productFamilyID int64, input *Product) error
- func DeleteCustomerByID(id int64) error
- func DeletePaymentProfile(subscriptionID int64, profileID int64) error
- func EnableBillingPortal(customerID int64, sendInvitation bool) error
- func MigrateSubscription(targetProductHandle string, currentSubscriptionID int64, includeTrial bool, ...) error
- func RemoveDelayedSubscriptionCancellation(subscriptionID int64) error
- func SavePaymentProfileForCustomer(customerID int64, input *PaymentProfile) error
- func SetCredentials(subdomain, apiKey string)
- func UpdateCustomer(input *Customer) error
- func UpdatePaymentProfile(input *PaymentProfile) error
- func UpdateProduct(productID int64, input *Product) error
- func UpdateSubscription(subscriptionID int64, productHandle string) error
- type APIReturn
- type BillingPortal
- type Coupon
- type Customer
- func CreateCustomer(input *Customer) (*Customer, error)
- func GetCustomers(page int, sortDir string) (found []Customer, err error)
- func SearchForCustomerByReference(reference string) (Customer, error)
- func SearchForCustomersByEmail(email string) ([]Customer, error)
- func SearchForCustomersByReference(reference string) ([]Customer, error)
- type Invoice
- type InvoiceQueryParams
- type MetaData
- type MetaDataEntry
- type Payment
- type PaymentMethod
- type PaymentProfile
- type Product
- type ProductFamily
- type ProductInterval
- type Refund
- type SignupPage
- type Subscription
- type VaultMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArchiveCoupon ¶ added in v0.9.0
ArchiveCoupon archives a coupon on use or expiration
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 ¶
ConvertJSONFloatToInt converts a float64 to an int64 from the JSON field interface
func CreateCoupon ¶ added in v0.9.0
CreateCoupon creates a new percent based coupon
func CreateProduct ¶
CreateProduct creates a new product and places the result in the input
func DeleteCustomerByID ¶
DeleteCustomerByID deletes a customer from chargify permanently
func DeletePaymentProfile ¶
DeletePaymentProfile deletes a payment profile
func EnableBillingPortal ¶ added in v0.6.0
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 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 RemoveDelayedSubscriptionCancellation ¶
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 UpdateCustomer ¶ added in v0.8.2
UpdateCustomer updates a customer in chargify
func UpdatePaymentProfile ¶
func UpdatePaymentProfile(input *PaymentProfile) error
UpdatePaymentProfile updates a payment profile
func UpdateProduct ¶
UpdateProduct updates a product
func UpdateSubscription ¶ added in v0.8.3
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 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 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 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 }
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 ¶
CreateCustomer creates a new customer on chargify
func GetCustomers ¶
GetCustomers gets the customers for the site
func SearchForCustomerByReference ¶
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 ¶
SearchForCustomersByEmail searches for customers with a specific email address; multiple can exist
func SearchForCustomersByReference ¶ added in v0.7.2
SearchForCustomersByReference searches all of the customers for a specific reference
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
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 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
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 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 ¶
GetProductByHandle gets a product by its handle
func GetProductByID ¶
GetProductByID gets a single product by id
func GetProductsInFamily ¶
GetProductsInFamily gets all of the products in a family
type ProductFamily ¶
type ProductFamily struct { ID int64 `json:"id"` Name string `json:"name"` // The product family name Handle string `json:"handle"` // The product family API handle AccountingCode string `json:"accounting_code"` // The product family accounting code (has no bearing in Chargify, may be used within your app) Description string `json:"description"` // The product family description }
ProductFamily represents a product family
func CreateProductFamily ¶
func CreateProductFamily(name, description, handle string, accountingCode string) (*ProductFamily, error)
CreateProductFamily creates a new product family
func GetProductFamily ¶
func GetProductFamily(productFamilyID int64) (*ProductFamily, error)
GetProductFamily gets a product 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"` // The url where the signup page can be viewed (public_signup_pages only) ReturnURL string `json:"return_url"` // The url to which a customer will be returned after a successful signup (public_signup_pages only) ReturnParams string `json:"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"` }
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 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
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" )