Categorygithub.com/GetWagz/go-chargify
modulepackage
0.13.0
Repository: https://github.com/getwagz/go-chargify.git
Documentation: pkg.go.dev

# 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 [email protected] 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.

# Functions

ArchiveCoupon archives a coupon on use or expiration.
ArchiveProduct archives a product.
CancelSubscription cancels a subscription.
ConvertJSONFloatToInt converts a float64 to an int64 from the JSON field interface.
CreateCustomer creates a new customer on chargify.
CreateFlatCoupon creates a new flat rate coupon.
CreateCoupon creates a new percent based coupon.
CreateProduct creates a new product and places the result in the input.
CreateProductFamily creates a new product family.
CreateSubscriptionForCustomer creates a new subscription.
DeleteCustomerByID deletes a customer from chargify permanently.
DeletePaymentProfile deletes a payment profile.
EnableBillingPortal enables billing portal management for the customer.
FromBool converts a value to a pointer.
FromFloat64 converts a value to a pointer.
FromInt converts a value to a pointer.
FromInt64 converts a value to a pointer.
FromString converts a value to a pointer.
GetBillingPortal gets the billing portal information for the customer.
GetCouponByCode gets a coupon by its code.
GetCustomerByID gets a customer by chargify id.
GetCustomerByReference gets a customer by reference.
GetCustomers gets the customers for the site.
GetCustomerSubscriptions.
GetEventsCount ...
GetInvoiceByID gets a single relationship invoice.
GetInvoices searched for invoices based upon passed-in params.
GetProductByHandle gets a product by its handle.
GetProductByID gets a single product by id.
GetProductFamily gets a product family.
GetProductFamily gets a product family.
GetProductFamilyComponentByHandle gets components in a family.
GetProductFamilyProducts gets products in a family.
GetProductFamilyProducts gets products in a family.
GetProductFamilyProducts gets products in a family.
GetProductsInFamily gets all of the products in a family.
GetSubscription gets a subscription.
GetProductFamilyProducts gets products in a family.
GetSubscriptionMetaData gets the subscription metadata.
ListCoupons lists out the coupons based upon the result of the passed in query params.
GetCustomerByID gets a customer by chargify id.
GetCustomerByID gets a customer by chargify id.
ListSubscriptions lists out the subscriptions based upon the result of the passed in query params.
MigrateSubscription migrates an existing subscription to a new subscription.
PostBulkEventsIngestion ...
PostEventsInjestion ...
PurgeSubscription purges a subscription from an account IN TEST MODE.
RefundInvoice refunds a single invoice.
RefundSubscriptionPayment refunds a specific payment for a subscription.
RemoveDelayedSubscriptionCancellation removes a delayed cancellation request, ensuring the subscription does not cancel.
SavePaymentProfileACH saves a payment profile using ACH.
SavePaymentProfileForCustomer saves a new payment profile.
SavePaymentProfileVault saves a payment profile using a vault.
SearchForCustomerByReference searches for a customer by it's reference value.
SearchForCustomersByEmail searches for customers with a specific email address; multiple can exist.
SearchForCustomersByReference searches all of the customers for a specific reference.
SetCredentials allows changing the credentials after initialization, such as when testing and the environment isn't setup.
ToBool takes a pointer and gives the value.
ToFloat64 takes a pointer and gives the value.
ToInt takes a pointer and gives the value.
ToInt64 takes a pointer and gives the value.
ToString takes a pointer and gives the value.
UpdateCustomer updates a customer in chargify.
UpdatePaymentProfile updates a payment profile.
UpdateProduct updates a product.
UpdateSubscription updates a subscription for a customer.

# Variables

ProductIntervalDay represents an interval of day.
ProductIntervalMonth represents an interval of month.
VaultAuthorize represents the AuthorizeNet vault.
VaultAuthorizeCIM represents the AuthorizeCIM vault.
VaultBeanStream represents the BeanStream vault.
VaultBogus represents a bogus vault used for testing.
VaultBPoint represents the BPoint vault.
VaultBraintree represents the BrainTree vault.
VaultChargify represents the Chargify vault.
VaultCyberSource represents the CyberSource vault.
VaultElavon represents the Elavon vault.
VaultEWay represents the EWay vault.
VaultEWayRapid represents the EWayRapid vault.
VaultFirstData represents the FirstData vault.
VaultFuseBox represents the FuseBox vault.
VaultLittle represents the Little vault.
VaultMoneris represents the Moneris vault.
VaultMonerisUS represents the Moneris US vault.
VaultOrbital represents the Orbital vault.
VaultPaymentExpress represents the PaymentExpress vault.
VaultPaymill represents the PayMill vault.
VaultPIN represents the PIN vault.
VaultQuickPay represents the QuickPay vault.
VaultSquare represents the Square vault.
VaultStripe represents the Stripe vault.
VaultTrustCommerce represents the TrustCommerce vault.
VaultWireCard represents the WireCard vault.

# Structs

No description provided by the author
APIReturn represents the return of the API calls.
BillingPortal represents a self-service management portal on the Chargify web site.
No description provided by the author
Coupon is a coupons structure.
CouponReturn is what we give back on the request.
Customer is a single customer in the chargify account.
No description provided by the author
No description provided by the author
No description provided by the author
FlatCoupon is the structure of what we need to send to Chargify when creating a flat rate coupon.
FlatCouponReturn is here because Chargify send back different types than what it asks for.
Invoice is a relationship invoice on Chargify.
InvoiceQueryParams are a collection of implemented query params to pass in to the invoice get call.
ListCouponsQueryParams are the query params for coupon listing.
No description provided by the author
No description provided by the author
No description provided by the author
ListSubscriptionsQueryParams are the query parameters for listing subscriptions; see: https://developers.chargify.com/docs/api-docs/51c68dd4dcb2b-list-subscriptions.
MetaData represents a pageable return of a metadata request.
MetaDataEntry represents a single key/value meta data entry.
Payment represents a single payment on an invoice, for example.
PaymentMethod represents a payment method, found on a payment struct.
PaymentProfile represents a payment profile.
PercentageCoupon is the structure of what we need to send to Chargify when creating a percentage-based coupon.
PercentageCouponReturn is here because Chargify send back different types than what it asks for.
No description provided by the author
Product represents a single product.
ProductFamily represents a product family.
ProductFamilyComponent represents a single component for a product family.
Refund is a single refund issued against an invoice.
SignupPage represents a product's signup page, if needed.
Subscription represents a subscription.
No description provided by the author

# Type aliases

ProductInterval represents an interval used for various calculations in a product.
VaultMethod represents one of the payment vaults for use with tokenization.