Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
de24b51
Replace deprecated property in postpone subscription
shulst Jun 27, 2019
1209318
rebase to autopilot3
shulst Jun 27, 2019
ba4052f
Make it possible to have zero price addons
Draal Jul 1, 2019
be4d3d2
Merge branch 'ap3-billing'
shulst Jul 1, 2019
6d5d7ad
API has the ability to set trial without billing info
shulst Jul 6, 2019
7b699ee
Try if this is enough to fix webhooks
shulst Jul 9, 2019
9d26004
And place it so the parser uses it
shulst Jul 9, 2019
35eea9a
feat(billing): move number to int64
mmoustai Jul 10, 2019
dfaaf97
feat(billing): remove int64
mmoustai Jul 10, 2019
09057d8
Fix bool omitempty for AutoRenew
shulst Jul 17, 2019
91eaeed
feat(billing): update cvc to string type
mmoustai Jul 22, 2019
296fbe1
Merge branch 'master' of https://github.com/autopilot3/recurly
mmoustai Jul 22, 2019
51cd177
feat(billing): int -> string type
mmoustai Jul 22, 2019
f0321d4
feat(billing): fix type
mmoustai Jul 22, 2019
4a604f6
feat(billing): types
mmoustai Jul 22, 2019
726b070
Add closed_invoice_notification notification type
Draal Jul 22, 2019
16dfd79
Merge pull request #1 from autopilot3/closed_invoice_notification
Draal Jul 22, 2019
4febd76
Add updated invoice notification
Draal Jul 24, 2019
76e23cd
feat(webhooks): add UpdatedChargeInvoiceNotification && PendingInvoic…
mmoustai Jul 24, 2019
9d9eafb
feat(recurly): correct use of error pointer && add 3d secure token
mmoustai Jul 26, 2019
e622add
feat(billing): bump version && add 3d token
mmoustai Jul 30, 2019
a6c87ea
Merge branch 'master' of https://github.com/blacklightcms/recurly int…
Draal Sep 3, 2020
79fad6c
Merge pull request #3 from autopilot3/blacklightcms-master
Draal Sep 3, 2020
caddb20
add new notif
mmoustai Feb 28, 2021
7e0af50
Merge pull request #4 from autopilot3/feat/pre-renewal
mmoustai Feb 28, 2021
54b6938
New dummy event
mmoustai Apr 26, 2021
9e1908c
add 2nd missing notif
mmoustai Apr 26, 2021
55c5146
fix notification
mmoustai Apr 26, 2021
41c33da
remove file && move type
mmoustai Apr 26, 2021
8740eb6
Merge pull request #5 from autopilot3/feat/new-shipping-address
mmoustai Apr 26, 2021
f4214a4
Add updated_credit_invoice_notification notification
Aug 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Recurly Client for Go

[![Build Status](https://travis-ci.org/blacklightcms/recurly.svg?branch=master)](https://travis-ci.org/blacklightcms/recurly) [![GoDoc](https://godoc.org/github.com/blacklightcms/recurly?status.svg)](https://godoc.org/github.com/blacklightcms/recurly/)
[![Build Status](https://travis-ci.org/blacklightcms/recurly.svg?branch=master)](https://travis-ci.org/blacklightcms/recurly) [![GoDoc](https://godoc.org/github.com/autopilot3/recurly?status.svg)](https://godoc.org/github.com/autopilot3/recurly/)

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

Expand All @@ -25,20 +25,20 @@
Install:

```shell
go get github.com/blacklightcms/recurly
go get github.com/autopilot3/recurly
```

Import:
```go
import "github.com/blacklightcms/recurly"
import "github.com/autopilot3/recurly"
```

Resources:
- [API Docs](https://godoc.org/github.com/blacklightcms/recurly/)
- [Examples](https://godoc.org/github.com/blacklightcms/recurly/#pkg-examples)
- [API Docs](https://godoc.org/github.com/autopilot3/recurly/)
- [Examples](https://godoc.org/github.com/autopilot3/recurly/#pkg-examples)

## 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](https://github.com/blacklightcms/recurly/wiki/v1-Migration-Guide) for steps on how to migrate to the latest version.
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](https://github.com/autopilot3/recurly/wiki/v1-Migration-Guide) for steps on how to migrate to the latest version.

This is recommended for all users.

Expand All @@ -54,7 +54,7 @@ a, err := client.Accounts.Get(context.Background(), "1")
```

## Examples and How To
Please go through [examples](https://godoc.org/github.com/blacklightcms/recurly/#pkg-examples) for detailed examples of using this package.
Please go through [examples](https://godoc.org/github.com/autopilot3/recurly/#pkg-examples) for detailed examples of using this package.

The examples explain important cases like:

Expand Down Expand Up @@ -152,7 +152,7 @@ The usage is to parse the webhook from a reader, then use a switch statement
to determine the type of webhook received.

```go
// import "github.com/blacklightcms/recurly/webhooks"
// import "github.com/autopilot3/recurly/webhooks"

hook, err := webhooks.Parse(r)
if e, ok := err.(*webhooks.ErrUnknownNotification); ok {
Expand Down Expand Up @@ -186,7 +186,7 @@ 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](https://godoc.org/github.com/blacklightcms/recurly/mock/).
For examples of how to test your code using mocks, visit the [GoDoc examples](https://godoc.org/github.com/autopilot3/recurly/mock/).

> **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.

Expand Down
5 changes: 3 additions & 2 deletions accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down Expand Up @@ -476,7 +476,8 @@ func NewTestAccountBalance() *recurly.AccountBalance {
XMLName: xml.Name{Local: "account_balance"},
PastDue: false,
Balance: recurly.UnitAmount{
USD: 3000,
USD: recurly.NewAmount(3000),
EUR: recurly.NewAmount(0),
},
}
}
Expand Down
16 changes: 10 additions & 6 deletions add_ons.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,23 @@ type AddOn struct {
CreatedAt NullTime `xml:"created_at,omitempty"`
}

func NewAmount(i int) *int {
return &i
}

// UnitAmount can read or write amounts in various currencies.
type UnitAmount struct {
USD int `xml:"USD,omitempty"`
EUR int `xml:"EUR,omitempty"`
GBP int `xml:"GBP,omitempty"`
CAD int `xml:"CAD,omitempty"`
AUD int `xml:"AUD,omitempty"`
USD *int `xml:"USD,omitempty"`
EUR *int `xml:"EUR,omitempty"`
GBP *int `xml:"GBP,omitempty"`
CAD *int `xml:"CAD,omitempty"`
AUD *int `xml:"AUD,omitempty"`
}

// MarshalXML ensures UnitAmount is not marshaled unless one or more currencies
// has a value greater than zero.
func (u UnitAmount) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if u.USD > 0 || u.EUR > 0 || u.CAD > 0 || u.GBP > 0 || u.AUD > 0 {
if u.USD != nil || u.EUR != nil || u.CAD != nil || u.GBP != nil || u.AUD != nil {
type uaAlias UnitAmount
e.EncodeElement(uaAlias(u), start)
}
Expand Down
22 changes: 11 additions & 11 deletions add_ons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down Expand Up @@ -81,7 +81,7 @@ func TestAddOns_Encoding(t *testing.T) {
`),
},
{
v: recurly.AddOn{UnitAmountInCents: recurly.UnitAmount{USD: 200}},
v: recurly.AddOn{UnitAmountInCents: recurly.UnitAmount{USD: recurly.NewAmount(200)}},
expected: MustCompactString(`
<add_on>
<unit_amount_in_cents>
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestUnitAmount(t *testing.T) {
{
expected: "<s></s>",
},
{v: s{Amount: recurly.UnitAmount{USD: 1000}},
{v: s{Amount: recurly.UnitAmount{USD: recurly.NewAmount(1000)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -189,7 +189,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{USD: 800, EUR: 650}},
{v: s{Amount: recurly.UnitAmount{USD: recurly.NewAmount(800), EUR: recurly.NewAmount(650)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -199,7 +199,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{EUR: 650}},
{v: s{Amount: recurly.UnitAmount{EUR: recurly.NewAmount(650)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -208,7 +208,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{GBP: 3000}},
{v: s{Amount: recurly.UnitAmount{GBP: recurly.NewAmount(3000)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -217,7 +217,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{CAD: 300}},
{v: s{Amount: recurly.UnitAmount{CAD: recurly.NewAmount(300)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -226,7 +226,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{AUD: 400}},
{v: s{Amount: recurly.UnitAmount{AUD: recurly.NewAmount(400)}},
expected: MustCompactString(`
<s>
<amount>
Expand All @@ -235,7 +235,7 @@ func TestUnitAmount(t *testing.T) {
</s>
`),
},
{v: s{Amount: recurly.UnitAmount{USD: 1}},
{v: s{Amount: recurly.UnitAmount{USD: recurly.NewAmount(1)}},
expected: MustCompactString(`
<s>
<amount>
Expand Down Expand Up @@ -385,7 +385,7 @@ func NewTestAddOn() *recurly.AddOn {
DisplayQuantityOnHostedPage: recurly.NewBool(false),
TaxCode: "digital",
UnitAmountInCents: recurly.UnitAmount{
USD: 200,
USD: recurly.NewAmount(200),
},
TierType: "volume",
Tiers: &[]recurly.Tier{*NewTestTier()},
Expand All @@ -399,7 +399,7 @@ func NewTestTier() *recurly.Tier {
XMLName: xml.Name{Local: "tier"},
EndingQuantity: 500,
UnitAmountInCents: recurly.UnitAmount{
USD: 100,
USD: recurly.NewAmount(100),
},
}
}
2 changes: 1 addition & 1 deletion adjustments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down
2 changes: 1 addition & 1 deletion automated_exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down
4 changes: 2 additions & 2 deletions billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ type Billing struct {
FirstSix string `xml:"first_six,omitempty"`
LastFour string `xml:"last_four,omitempty"`
CardType string `xml:"card_type,omitempty"`
Number int `xml:"number,omitempty"`
Number string `xml:"number,omitempty"`
Month int `xml:"month,omitempty"`
Year int `xml:"year,omitempty"`
VerificationValue int `xml:"verification_value,omitempty"` // Create/update only
VerificationValue string `xml:"verification_value,omitempty"` // Create/update only

// Paypal
PaypalAgreementID string `xml:"paypal_billing_agreement_id,omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down Expand Up @@ -115,7 +115,7 @@ func TestBilling_Encoding(t *testing.T) {
`),
},
{
v: recurly.Billing{Number: 4111111111111111, Month: 5, Year: 2020, VerificationValue: 111},
v: recurly.Billing{Number: "4111111111111111", Month: 5, Year: 2020, VerificationValue: "111"},
expected: MustCompactString(`
<billing_info>
<number>4111111111111111</number>
Expand Down Expand Up @@ -352,7 +352,7 @@ func TestBilling_Create(t *testing.T) {
State: "CA",
Zip: "94105",
Country: "US",
Number: 4111111111111111,
Number: "4111111111111111",
Month: 10,
Year: 2020,
}); !s.Invoked {
Expand Down Expand Up @@ -480,7 +480,7 @@ func TestBilling_Update(t *testing.T) {
State: "CA",
Zip: "94105",
Country: "US",
Number: 4111111111111111,
Number: "4111111111111111",
Month: 10,
Year: 2020,
}); !s.Invoked {
Expand Down
10 changes: 5 additions & 5 deletions coupons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down Expand Up @@ -102,7 +102,7 @@ func TestCoupons_Encoding(t *testing.T) {
Type: "single_code",
Name: "Special 10% off",
DiscountType: "dollars",
DiscountInCents: &recurly.UnitAmount{USD: 100},
DiscountInCents: &recurly.UnitAmount{USD: recurly.NewAmount(100)},
MaxRedemptions: recurly.NewInt(2),
MaxRedemptionsPerAccount: recurly.NewInt(1),
},
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestCoupons_Update(t *testing.T) {
State: "redeemable",
Type: "bulk",
DiscountType: "dollars",
DiscountInCents: &recurly.UnitAmount{USD: 2000},
DiscountInCents: &recurly.UnitAmount{USD: recurly.NewAmount(2000)},
RedemptionResource: "account",
AppliesToAllPlans: false,
UniqueCodeTemplate: "'savemore'99999999",
Expand Down Expand Up @@ -354,7 +354,7 @@ func TestCoupons_Restore(t *testing.T) {
State: "redeemable",
Type: "bulk",
DiscountType: "dollars",
DiscountInCents: &recurly.UnitAmount{USD: 2000},
DiscountInCents: &recurly.UnitAmount{USD: recurly.NewAmount(2000)},
RedemptionResource: "account",
AppliesToAllPlans: false,
UniqueCodeTemplate: "'savemore'99999999",
Expand Down Expand Up @@ -477,7 +477,7 @@ func NewTestCoupon() *recurly.Coupon {
State: "redeemable",
Type: "bulk",
DiscountType: "dollars",
DiscountInCents: &recurly.UnitAmount{USD: 2000},
DiscountInCents: &recurly.UnitAmount{USD: recurly.NewAmount(2000)},
RedeemByDate: recurly.NewTime(MustParseTime("2014-01-01T07:00:00Z")),
RedemptionResource: "account",
MaxRedemptions: recurly.NewInt(10),
Expand Down
2 changes: 1 addition & 1 deletion credit_payments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Usage
Construct a new Recurly client, then use the various services on the client to
access different parts of the Recurly API. For example:

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

func main() {
client := recurly.NewClient("your-subdomain", "APIKEY")
Expand Down
2 changes: 1 addition & 1 deletion doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"time"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
)

var client *recurly.Client
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/autopilot3/recurly

go 1.15

require github.com/google/go-cmp v0.2.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
2 changes: 1 addition & 1 deletion invoices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down
2 changes: 1 addition & 1 deletion items_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"testing"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
"github.com/google/go-cmp/cmp"
)

Expand Down
2 changes: 1 addition & 1 deletion mock/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mock
import (
"context"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
)

var _ recurly.AccountsService = &AccountsService{}
Expand Down
2 changes: 1 addition & 1 deletion mock/add_ons.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mock
import (
"context"

"github.com/blacklightcms/recurly"
"github.com/autopilot3/recurly"
)

var _ recurly.AddOnsService = &AddOnsService{}
Expand Down
Loading