All Projects → blacklightcms → recurly

blacklightcms / recurly

Licence: MIT license
A Recurly API client written in golang. Actively maintained and unit tested. No external dependencies.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to recurly

Stripe
A comprehensive PHP Library for the Stripe.
Stars: ✭ 256 (+540%)
Mutual labels:  subscription, payment, billing
drf-stripe-subscription
An out-of-box Django REST framework solution for payment and subscription management using Stripe.
Stars: ✭ 42 (+5%)
Mutual labels:  subscription, payment, billing
subscribie
Collect recurring payments online - subscription payments collection automation
Stars: ✭ 36 (-10%)
Mutual labels:  subscription, saas, billing
Laraplans
SaaS style recurring plans for Laravel.
Stars: ✭ 163 (+307.5%)
Mutual labels:  subscription, saas
Memberprism2
open source alternative to memberstack / memberspace , but with both front and backend member-only content protection
Stars: ✭ 171 (+327.5%)
Mutual labels:  subscription, saas
responsive-html-email-templates
Collection of Free responsive HTML templates for Startups
Stars: ✭ 187 (+367.5%)
Mutual labels:  subscription, saas
Jetstream Cashier Billing Portal
Jetstream Cashier Billing Portal is a simple scaffolding billing portal to manage subscriptions, invoices and payment methods, built on top of Jetstream & Cashier Register.
Stars: ✭ 45 (+12.5%)
Mutual labels:  payment, billing
wave
Wave - The Software as a Service Starter Kit, designed to help you build the SAAS of your dreams 🚀 💰
Stars: ✭ 3,646 (+9015%)
Mutual labels:  subscription, saas
Google-IAP
Android Library for easing Google Play Billing to your apps with support for Subscriptions, In-App Purchases and Consumables with a beautiful sample app.
Stars: ✭ 129 (+222.5%)
Mutual labels:  subscription, billing
Saas Boilerplate
SaaS boilerplate built in Laravel, Bootstrap 4 and VueJs.
Stars: ✭ 152 (+280%)
Mutual labels:  subscription, saas
Plans
Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countable features.
Stars: ✭ 326 (+715%)
Mutual labels:  subscription, saas
Vue Stripe
Stripe Checkout & Elements for Vue.js
Stars: ✭ 669 (+1572.5%)
Mutual labels:  subscription, payment
direct-stripe
Stripe payment button for WordPress websites
Stars: ✭ 12 (-70%)
Mutual labels:  subscription, payment
cashier-register
Cashier Register is a simple quota feature usage tracker for Laravel Cashier subscriptions.
Stars: ✭ 93 (+132.5%)
Mutual labels:  subscription, saas
Commerce billing
A payment processing library for Elixir
Stars: ✭ 170 (+325%)
Mutual labels:  payment, billing
Djaoapp
User login, billing, access control as part of a session proxy
Stars: ✭ 61 (+52.5%)
Mutual labels:  subscription, saas
HiveMind
HiveMind is a project management and ERP application for services organizations. It features project/task management, request tracking, time tracking, expenses, invoices/payments, general ledger, and content management (wiki). HiveMind is based on Moqui Framework, Mantle Business Artifacts, and Simple Screens.
Stars: ✭ 40 (+0%)
Mutual labels:  payment, billing
Gringotts
A complete payment library for Elixir and Phoenix Framework
Stars: ✭ 396 (+890%)
Mutual labels:  payment, billing
awesome-ecommerce
Collect and develop Open Source or Free Projects for building ecommerce platform easy and fast and free
Stars: ✭ 39 (-2.5%)
Mutual labels:  subscription, payment
In App Purchase
A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
Stars: ✭ 868 (+2070%)
Mutual labels:  subscription, billing

Recurly Client for Go

Build Status GoDoc

Recurly is a Go (golang) API Client for the Recurly API. It is actively maintained, unit tested, and uses no external dependencies. The vast majority of the API is implemented.

Supports:

  • Recurly API v2.27
  • Accounts
  • Add Ons
  • Adjustments
  • Billing
  • Coupons
  • Credit Payments
  • Invoices
  • Plans
  • Purchases
  • Redemptions
  • Shipping Addresses
  • Shipping Methods
  • Subscriptions
  • Transactions

Installation

Install:

go get github.com/blacklightcms/recurly

Import:

import "github.com/blacklightcms/recurly"

Resources:

Note on v1 and breaking changes

If migrating from a previous version of the library, there was a large refactor with breaking changes released to address some design issues with the library. See the migration guide for steps on how to migrate to the latest version.

This is recommended for all users.

Quickstart

Construct a new Recurly client, then use the various services on the client to access different parts of the Recurly API. For example:

client := recurly.NewClient("your-subdomain", "APIKEY")

// Retrieve an account
a, err := client.Accounts.Get(context.Background(), "1")

Examples and How To

Please go through examples for detailed examples of using this package.

The examples explain important cases like:

  • Null Types
  • Error Handling
  • Get Methods
  • Pagination

Here are a few snippets to demonstrate library usage.

Create Account

account, err := client.Accounts.Create(ctx, recurly.Account{
    Code: "1",
    FirstName: "Verena",
    LastName: "Example",
    Email: "[email protected]",
})

NOTE: An account can also be created along a subscription by embedding the account in the subscription during creation. The purchases API also supports this, and likely other endpoints. See Recurly's documentation for details.

Get Account

account, err := client.Accounts.Get(ctx, "1")
if err != nil {
    return err
} else if account == nil {
    // account not found
    // Note: this nil, nil response on 404s is unique to Get() methods
    // See GoDoc for details.
}

Create Billing Info

// Using token obtained with recurly.js
// If you want to set billing info directly, omit the token and set the
// corresponding fields on the recurly.Billing struct.
billing, err := client.Billing.Create("1", recurly.Billing{
    Token: token,
})

NOTE: See the error handling section in GoDoc for how to handle transaction errors

Creating Purchases

purchase, err := c.Client.Purchases.Create(ctx, recurly.Purchase{
    Account: recurly.Account{
	    Code: "1",
    },
    Adjustments: []recurly.Adjustment{{
	    UnitAmountInCents: recurly.NewInt(100),
	    Description:       "Purchase Description",
	    ProductCode:       "product_code",
    }},
    CollectionMethod: recurly.CollectionMethodAutomatic,
    Currency:         "USD",
})
if err != nil {
    // NOTE: See GoDoc for how to handle failed transaction errors
}

NOTE: The purchases API supports subscriptions, adjustments, shipping addresses, shipping fees, and more. This is one of many possible examples. See the underlying structs and Recurly's documentation for more info.

Creating Subscriptions

subscription, err := client.Subscriptions.Create(ctx, recurly.NewSubscription{
    PlanCode: "gold",
    Currency: "USD",
    Account: recurly.Account{
        // Note: Set the Code for an existing account
        // To create a new account, omit Code but provide other fields
    },
})
if err != nil {
    // NOTE: See GoDoc for how to handle failed transaction errors
    return err
}

NOTE: Recurly offers several other ways to create subscriptions, often embedded within other requests (such as the Purchases.Create() call). See Recurly's documentation for more details.

Webhooks

This library supports webhooks via the webhooks sub package.

The usage is to parse the webhook from a reader, then use a switch statement to determine the type of webhook received.

// import "github.com/blacklightcms/recurly/webhooks"

hook, err := webhooks.Parse(r)
if e, ok := err.(*webhooks.ErrUnknownNotification); ok {
    // e.Name() holds the name of the notification
} else if err != nil {
    // all other errors
}

// Use a switch statement to determine the type of webhook received.
switch h := hook.(type) {
case *webhooks.AccountNotification:
    // h.Account
case *webhooks.PaymentNotification:
    // h.Account
    // h.Transaction
case *webhooks.SubscriptionNotification:
    // h.Account
    // h.Subscription
default:
    // webhook not listed above
}

Testing

Once you've imported this library into your application, you will want to add tests.

Internally this library sets up a test HTTPs server and validates methods, paths, query strings, request body, and returns XML. You will not need to worry about those internals when testing your own code that uses this library.

Instead we recommend using the mock package. The mock package provides mocks for all of the different services in this library.

For examples of how to test your code using mocks, visit the GoDoc examples.

NOTE: If you need to go beyond mocks and test requests/responses, testing.go exports TestServer. This is how the library tests itself. See the GoDoc or the *_test.go files for usage examples.

Contributing

We use dep for dependency management. If you do not have it installed, see the installation instructions.

To contribute: fork and clone the repository, cd into the directory, and run:

dep ensure

That will ensure you have google/go-cmp which is used to run tests.

If you plan on submitting a patch, please write tests for it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].