From de24b5166925b0dd713370055ba81f8a73562f3a Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Thu, 27 Jun 2019 15:21:42 +1000 Subject: [PATCH 01/24] Replace deprecated property in postpone subscription --- subscriptions.go | 4 ++-- subscriptions_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/subscriptions.go b/subscriptions.go index 515214e..90ad154 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -489,8 +489,8 @@ func (s *subscriptionsImpl) Pause(ctx context.Context, uuid string, cycles int) func (s *subscriptionsImpl) Postpone(ctx context.Context, uuid string, dt time.Time, bulk bool) (*Subscription, error) { path := fmt.Sprintf("/subscriptions/%s/postpone", sanitizeUUID(uuid)) req, err := s.client.newQueryRequest("PUT", path, query{ - "bulk": bulk, - "next_renewal_date": dt, + "bulk": bulk, + "next_bill_date": dt, }, nil) if err != nil { return nil, err diff --git a/subscriptions_test.go b/subscriptions_test.go index a754ad1..dfeb77f 100644 --- a/subscriptions_test.go +++ b/subscriptions_test.go @@ -929,7 +929,7 @@ func TestSubscriptions_Postpone(t *testing.T) { defer s.Close() s.HandleFunc("PUT", "/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/postpone", func(w http.ResponseWriter, r *http.Request) { - if v := r.URL.Query().Get("next_renewal_date"); v != "2015-08-27T07:00:00Z" { + if v := r.URL.Query().Get("next_bill_date"); v != "2015-08-27T07:00:00Z" { t.Fatalf("unexpected input for next_renewal_date: %q", v) } else if v := r.URL.Query().Get("bulk"); v != "false" { t.Fatalf("unexpected input for bulk: %q", v) From 12093180916aa71ef6d20bb205646bc53ed333e9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Thu, 27 Jun 2019 16:31:19 +1000 Subject: [PATCH 02/24] rebase to autopilot3 --- accounts_test.go | 2 +- add_ons_test.go | 2 +- adjustments_test.go | 2 +- billing_test.go | 2 +- coupons_test.go | 2 +- credit_payments_test.go | 2 +- doc.go | 2 +- doc_test.go | 2 +- invoices_test.go | 2 +- mock/accounts.go | 2 +- mock/add_ons.go | 2 +- mock/adjustments.go | 2 +- mock/billing.go | 2 +- mock/client.go | 2 +- mock/coupons.go | 2 +- mock/credit_payments.go | 2 +- mock/doc.go | 2 +- mock/example_test.go | 4 ++-- mock/invoices.go | 2 +- mock/pager.go | 2 +- mock/plans.go | 2 +- mock/purchases.go | 2 +- mock/redemptions.go | 2 +- mock/shipping_address.go | 2 +- mock/shipping_methods.go | 2 +- mock/subscriptions.go | 2 +- mock/transactions.go | 2 +- pager_test.go | 2 +- plans_test.go | 2 +- purchases_test.go | 2 +- recurly.go | 2 +- recurly_test.go | 2 +- redemptions_test.go | 2 +- shipping_addresses_test.go | 2 +- shipping_methods_test.go | 2 +- subscriptions_test.go | 2 +- transactions_test.go | 2 +- webhooks/charge_invoices.go | 2 +- webhooks/credit_invoices.go | 2 +- webhooks/credit_payments.go | 2 +- webhooks/dunning_events.go | 2 +- webhooks/payments.go | 2 +- webhooks/subscriptions.go | 2 +- webhooks/webhooks_test.go | 4 ++-- xml_test.go | 2 +- 45 files changed, 47 insertions(+), 47 deletions(-) diff --git a/accounts_test.go b/accounts_test.go index 02ec602..af4c7f7 100644 --- a/accounts_test.go +++ b/accounts_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/add_ons_test.go b/add_ons_test.go index 2372834..d2c6a63 100644 --- a/add_ons_test.go +++ b/add_ons_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/adjustments_test.go b/adjustments_test.go index 9f9578c..f784342 100644 --- a/adjustments_test.go +++ b/adjustments_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/billing_test.go b/billing_test.go index 7ec53d4..1124652 100644 --- a/billing_test.go +++ b/billing_test.go @@ -9,7 +9,7 @@ import ( "strconv" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/coupons_test.go b/coupons_test.go index ea21d61..7c01cbb 100644 --- a/coupons_test.go +++ b/coupons_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/credit_payments_test.go b/credit_payments_test.go index 066af09..bec33a1 100644 --- a/credit_payments_test.go +++ b/credit_payments_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/doc.go b/doc.go index c537f7e..91517a2 100644 --- a/doc.go +++ b/doc.go @@ -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") diff --git a/doc_test.go b/doc_test.go index 4a64953..15a0f13 100644 --- a/doc_test.go +++ b/doc_test.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var client *recurly.Client diff --git a/invoices_test.go b/invoices_test.go index 78d628e..783df12 100644 --- a/invoices_test.go +++ b/invoices_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/mock/accounts.go b/mock/accounts.go index 0de250f..d988e88 100644 --- a/mock/accounts.go +++ b/mock/accounts.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.AccountsService = &AccountsService{} diff --git a/mock/add_ons.go b/mock/add_ons.go index ff4a984..b23d54e 100644 --- a/mock/add_ons.go +++ b/mock/add_ons.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.AddOnsService = &AddOnsService{} diff --git a/mock/adjustments.go b/mock/adjustments.go index 76bf4bb..3bfa000 100644 --- a/mock/adjustments.go +++ b/mock/adjustments.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.AdjustmentsService = &AdjustmentsService{} diff --git a/mock/billing.go b/mock/billing.go index 27a6731..67c28f3 100644 --- a/mock/billing.go +++ b/mock/billing.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.BillingService = &BillingService{} diff --git a/mock/client.go b/mock/client.go index bfe570a..c4e1767 100644 --- a/mock/client.go +++ b/mock/client.go @@ -1,7 +1,7 @@ package mock import ( - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) // Client is a test wrapper for recurly.Client holding mocks for diff --git a/mock/coupons.go b/mock/coupons.go index 617c82f..f1e5d48 100644 --- a/mock/coupons.go +++ b/mock/coupons.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.CouponsService = &CouponsService{} diff --git a/mock/credit_payments.go b/mock/credit_payments.go index 75f23e4..360fb6e 100644 --- a/mock/credit_payments.go +++ b/mock/credit_payments.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.CreditPaymentsService = &CreditPaymentsService{} diff --git a/mock/doc.go b/mock/doc.go index 3bea7a5..2ec2cab 100644 --- a/mock/doc.go +++ b/mock/doc.go @@ -82,7 +82,7 @@ Then in your test suite you might configure your own wrapper similar to mock.Cli "context" "github.com/your-project/foo" - "github.com/blacklightcms/recurly/mock" + "github.com/autopilot3/recurly/mock" ) // Provider is a test wrapper for foo.Provider. diff --git a/mock/example_test.go b/mock/example_test.go index 7370929..4f26fd5 100644 --- a/mock/example_test.go +++ b/mock/example_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/blacklightcms/recurly" - "github.com/blacklightcms/recurly/mock" + "github.com/autopilot3/recurly" + "github.com/autopilot3/recurly/mock" "github.com/google/go-cmp/cmp" ) diff --git a/mock/invoices.go b/mock/invoices.go index a313299..df61e8e 100644 --- a/mock/invoices.go +++ b/mock/invoices.go @@ -4,7 +4,7 @@ import ( "bytes" "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.InvoicesService = &InvoicesService{} diff --git a/mock/pager.go b/mock/pager.go index 1657f05..2cada8e 100644 --- a/mock/pager.go +++ b/mock/pager.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.Pager = &Pager{} diff --git a/mock/plans.go b/mock/plans.go index 447856c..0c0ec39 100644 --- a/mock/plans.go +++ b/mock/plans.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.PlansService = &PlansService{} diff --git a/mock/purchases.go b/mock/purchases.go index 5978775..e5c680c 100644 --- a/mock/purchases.go +++ b/mock/purchases.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.PurchasesService = &PurchasesService{} diff --git a/mock/redemptions.go b/mock/redemptions.go index ac01a93..67dda35 100644 --- a/mock/redemptions.go +++ b/mock/redemptions.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.RedemptionsService = &RedemptionsService{} diff --git a/mock/shipping_address.go b/mock/shipping_address.go index c843f2f..66a2746 100644 --- a/mock/shipping_address.go +++ b/mock/shipping_address.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.ShippingAddressesService = &ShippingAddressesService{} diff --git a/mock/shipping_methods.go b/mock/shipping_methods.go index 73a1c60..06f6431 100644 --- a/mock/shipping_methods.go +++ b/mock/shipping_methods.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.ShippingMethodsService = &ShippingMethodsService{} diff --git a/mock/subscriptions.go b/mock/subscriptions.go index 3685989..6eff46d 100644 --- a/mock/subscriptions.go +++ b/mock/subscriptions.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.SubscriptionsService = &SubscriptionsService{} diff --git a/mock/transactions.go b/mock/transactions.go index 2c1b09d..ef76063 100644 --- a/mock/transactions.go +++ b/mock/transactions.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) var _ recurly.TransactionsService = &TransactionsService{} diff --git a/pager_test.go b/pager_test.go index 7d70a62..955d22d 100644 --- a/pager_test.go +++ b/pager_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/plans_test.go b/plans_test.go index ef76a6b..8584ba6 100644 --- a/plans_test.go +++ b/plans_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/purchases_test.go b/purchases_test.go index e6e0ec2..d2fb481 100644 --- a/purchases_test.go +++ b/purchases_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/recurly.go b/recurly.go index e6d432f..2b27c7f 100644 --- a/recurly.go +++ b/recurly.go @@ -41,7 +41,7 @@ type Client struct { // userAgent sets the User-Agent header for requests so Recurly can // track usage of the client. - // See https://github.com/blacklightcms/recurly/issues/41 + // See https://github.com/autopilot3/recurly/issues/41 userAgent string // Client is the HTTP Client used to communicate with the API. diff --git a/recurly_test.go b/recurly_test.go index 6fea468..75ec62e 100644 --- a/recurly_test.go +++ b/recurly_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/redemptions_test.go b/redemptions_test.go index d46e42f..7438ce9 100644 --- a/redemptions_test.go +++ b/redemptions_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/shipping_addresses_test.go b/shipping_addresses_test.go index 02f9b79..aa86bd7 100644 --- a/shipping_addresses_test.go +++ b/shipping_addresses_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/shipping_methods_test.go b/shipping_methods_test.go index 4ec9767..0116a8a 100644 --- a/shipping_methods_test.go +++ b/shipping_methods_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/subscriptions_test.go b/subscriptions_test.go index dfeb77f..ba151f3 100644 --- a/subscriptions_test.go +++ b/subscriptions_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/transactions_test.go b/transactions_test.go index 707a682..7c77fd0 100644 --- a/transactions_test.go +++ b/transactions_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) diff --git a/webhooks/charge_invoices.go b/webhooks/charge_invoices.go index 5716d4c..87ead39 100644 --- a/webhooks/charge_invoices.go +++ b/webhooks/charge_invoices.go @@ -3,7 +3,7 @@ package webhooks import ( "encoding/xml" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) // Charge invoice notifications. diff --git a/webhooks/credit_invoices.go b/webhooks/credit_invoices.go index 6160502..e057ad1 100644 --- a/webhooks/credit_invoices.go +++ b/webhooks/credit_invoices.go @@ -3,7 +3,7 @@ package webhooks import ( "encoding/xml" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) // Credit invoice notifications. diff --git a/webhooks/credit_payments.go b/webhooks/credit_payments.go index 78df0cb..bd3879b 100644 --- a/webhooks/credit_payments.go +++ b/webhooks/credit_payments.go @@ -3,7 +3,7 @@ package webhooks import ( "encoding/xml" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) // Credit payment notifications. diff --git a/webhooks/dunning_events.go b/webhooks/dunning_events.go index f89dbdd..e07f178 100644 --- a/webhooks/dunning_events.go +++ b/webhooks/dunning_events.go @@ -1,6 +1,6 @@ package webhooks -import "github.com/blacklightcms/recurly" +import "github.com/autopilot3/recurly" // Dunning event constants. const ( diff --git a/webhooks/payments.go b/webhooks/payments.go index 41172cc..f5ef33d 100644 --- a/webhooks/payments.go +++ b/webhooks/payments.go @@ -3,7 +3,7 @@ package webhooks import ( "encoding/xml" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" ) // Payment notifications. diff --git a/webhooks/subscriptions.go b/webhooks/subscriptions.go index 5bf3907..6ffea38 100644 --- a/webhooks/subscriptions.go +++ b/webhooks/subscriptions.go @@ -1,6 +1,6 @@ package webhooks -import "github.com/blacklightcms/recurly" +import "github.com/autopilot3/recurly" // Subscription notifications. // https://dev.recurly.com/page/webhooks#subscription-notifications diff --git a/webhooks/webhooks_test.go b/webhooks/webhooks_test.go index 7675b1e..29c9c34 100644 --- a/webhooks/webhooks_test.go +++ b/webhooks/webhooks_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/blacklightcms/recurly" - "github.com/blacklightcms/recurly/webhooks" + "github.com/autopilot3/recurly" + "github.com/autopilot3/recurly/webhooks" "github.com/google/go-cmp/cmp" ) diff --git a/xml_test.go b/xml_test.go index 8fa28ba..b49991c 100644 --- a/xml_test.go +++ b/xml_test.go @@ -5,7 +5,7 @@ import ( "encoding/xml" "testing" - "github.com/blacklightcms/recurly" + "github.com/autopilot3/recurly" "github.com/google/go-cmp/cmp" ) From ba4052f8d86ab53a83e84039e87340c5d39fe13a Mon Sep 17 00:00:00 2001 From: Denys Misko Date: Mon, 1 Jul 2019 10:16:17 +1000 Subject: [PATCH 03/24] Make it possible to have zero price addons --- add_ons.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/add_ons.go b/add_ons.go index aa8f3e9..5f8d163 100644 --- a/add_ons.go +++ b/add_ons.go @@ -56,17 +56,17 @@ type AddOn struct { // 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) } From 6d5d7adee0bec0d5f6c534dfdde5de17a3caa50a Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Sat, 6 Jul 2019 11:39:47 +1000 Subject: [PATCH 04/24] API has the ability to set trial without billing info --- plans.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plans.go b/plans.go index 84ca4ac..963b5a6 100644 --- a/plans.go +++ b/plans.go @@ -57,6 +57,7 @@ type Plan struct { IntervalLength int `xml:"plan_interval_length,omitempty"` TrialIntervalUnit string `xml:"trial_interval_unit,omitempty"` TrialIntervalLength int `xml:"trial_interval_length,omitempty"` + TrialRequiresBillingInfo NullBool `xml:"trial_requires_billing_info,omitempty"` TotalBillingCycles NullInt `xml:"total_billing_cycles,omitempty"` AccountingCode string `xml:"accounting_code,omitempty"` CreatedAt NullTime `xml:"created_at,omitempty"` From 7b699ee7fdadc716b67bbe37a2234fcb7416fbb0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Tue, 9 Jul 2019 14:03:04 +1000 Subject: [PATCH 05/24] Try if this is enough to fix webhooks --- webhooks/charge_invoices.go | 1 + 1 file changed, 1 insertion(+) diff --git a/webhooks/charge_invoices.go b/webhooks/charge_invoices.go index 87ead39..fbb971d 100644 --- a/webhooks/charge_invoices.go +++ b/webhooks/charge_invoices.go @@ -11,6 +11,7 @@ import ( const ( NewChargeInvoice = "new_charge_invoice_notification" ProcessingChargeInvoice = "processing_charge_invoice_notification" + PastDueInvoice = "past_due_invoice_notification" PastDueChargeInvoice = "past_due_charge_invoice_notification" PaidChargeInvoice = "paid_charge_invoice_notification" FailedChargeInvoice = "failed_charge_invoice_notification" From 9d260045cbb10c7bb3144bd89e0f1307a69e2219 Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Tue, 9 Jul 2019 14:10:40 +1000 Subject: [PATCH 06/24] And place it so the parser uses it --- webhooks/webhooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 0c6e745..fce5c1e 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -55,7 +55,7 @@ func nameToNotification(name string) (interface{}, error) { case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, ResumedSubscription, ScheduledPauseSubscription, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil - case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice: + case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice: return &ChargeInvoiceNotification{Type: name}, nil case NewCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: return &CreditInvoiceNotification{Type: name}, nil From 35eea9ab0115ef9761a067d41726f79068f1b795 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Wed, 10 Jul 2019 17:52:58 +1000 Subject: [PATCH 07/24] feat(billing): move number to int64 --- billing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billing.go b/billing.go index 9c77b3a..aac85ba 100644 --- a/billing.go +++ b/billing.go @@ -82,7 +82,7 @@ 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 int64 `xml:"number,omitempty"` Month int `xml:"month,omitempty"` Year int `xml:"year,omitempty"` VerificationValue int `xml:"verification_value,omitempty"` // Create/update only From dfaaf9706fd925257bfc1f28768a944d874f5e72 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Wed, 10 Jul 2019 18:10:04 +1000 Subject: [PATCH 08/24] feat(billing): remove int64 --- billing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billing.go b/billing.go index aac85ba..9c77b3a 100644 --- a/billing.go +++ b/billing.go @@ -82,7 +82,7 @@ type Billing struct { FirstSix string `xml:"first_six,omitempty"` LastFour string `xml:"last_four,omitempty"` CardType string `xml:"card_type,omitempty"` - Number int64 `xml:"number,omitempty"` + Number int `xml:"number,omitempty"` Month int `xml:"month,omitempty"` Year int `xml:"year,omitempty"` VerificationValue int `xml:"verification_value,omitempty"` // Create/update only From 09057d8901ef8a9869b834b368fe7b54ae6825b8 Mon Sep 17 00:00:00 2001 From: Sebastiaan Hulst Date: Wed, 17 Jul 2019 16:10:59 +1000 Subject: [PATCH 09/24] Fix bool omitempty for AutoRenew --- subscriptions.go | 2 +- subscriptions_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/subscriptions.go b/subscriptions.go index 90ad154..e17767e 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -172,7 +172,7 @@ type NewSubscription struct { RenewalBillingCycles NullInt `xml:"renewal_billing_cycles"` NextBillDate NullTime `xml:"next_bill_date,omitempty"` CollectionMethod string `xml:"collection_method,omitempty"` - AutoRenew bool `xml:"auto_renew,omitempty"` + AutoRenew NullBool `xml:"auto_renew,omitempty"` NetTerms NullInt `xml:"net_terms,omitempty"` PONumber string `xml:"po_number,omitempty"` Bulk bool `xml:"bulk,omitempty"` diff --git a/subscriptions_test.go b/subscriptions_test.go index ba151f3..d229981 100644 --- a/subscriptions_test.go +++ b/subscriptions_test.go @@ -33,7 +33,7 @@ func TestSubscriptions_NewSubscription_Encoding(t *testing.T) { { v: recurly.NewSubscription{ PlanCode: "gold", - AutoRenew: true, + AutoRenew: recurly.NewBool(true), RenewalBillingCycles: recurly.NewInt(2), Account: recurly.Account{ Code: "123", From 91eaeed046809cb6af7874ca5eb25f95070a046f Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Mon, 22 Jul 2019 14:29:30 +1000 Subject: [PATCH 10/24] feat(billing): update cvc to string type --- billing.go | 2 +- billing_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/billing.go b/billing.go index 9c77b3a..df766fe 100644 --- a/billing.go +++ b/billing.go @@ -85,7 +85,7 @@ type Billing struct { Number int `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"` diff --git a/billing_test.go b/billing_test.go index 1124652..31ceaa4 100644 --- a/billing_test.go +++ b/billing_test.go @@ -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(` 4111111111111111 From 51cd177d197a1614928f76dba305bd3e71418759 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Mon, 22 Jul 2019 14:40:05 +1000 Subject: [PATCH 11/24] feat(billing): int -> string type --- billing.go | 6 +++--- billing_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/billing.go b/billing.go index df766fe..2339277 100644 --- a/billing.go +++ b/billing.go @@ -82,9 +82,9 @@ 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"` - Month int `xml:"month,omitempty"` - Year int `xml:"year,omitempty"` + Number string `xml:"number,omitempty"` + Month string `xml:"month,omitempty"` + Year string `xml:"year,omitempty"` VerificationValue string `xml:"verification_value,omitempty"` // Create/update only // Paypal diff --git a/billing_test.go b/billing_test.go index 31ceaa4..e730a9f 100644 --- a/billing_test.go +++ b/billing_test.go @@ -317,9 +317,9 @@ func TestBilling_Create(t *testing.T) { State: "CA", Zip: "94105", Country: "US", - Number: 4111111111111111, - Month: 10, - Year: 2020, + Number: "4111111111111111", + Month: "10", + Year: "2020", }); !s.Invoked { t.Fatal("expected fn invocation") } else if err != nil { @@ -419,9 +419,9 @@ func TestBilling_Update(t *testing.T) { State: "CA", Zip: "94105", Country: "US", - Number: 4111111111111111, - Month: 10, - Year: 2020, + Number: "4111111111111111", + Month: "10", + Year: "2020", }); !s.Invoked { t.Fatal("expected fn invocation") } else if err != nil { From f0321d40a6ae9e76bbcb0bbd4f787380f3b532ac Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Mon, 22 Jul 2019 14:42:18 +1000 Subject: [PATCH 12/24] feat(billing): fix type --- billing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billing.go b/billing.go index 2339277..719463d 100644 --- a/billing.go +++ b/billing.go @@ -107,7 +107,7 @@ type Billing struct { // Type returns the billing info type. Returns either "", "bank", or an empty string. func (b Billing) Type() string { - if b.FirstSix != "" && b.LastFour != "" && b.Month > 0 && b.Year > 0 { + if b.FirstSix != "" && b.LastFour != "" && b.Month != "" && b.Year != "" { return "card" } else if b.NameOnAccount != "" && b.RoutingNumber != "" && b.AccountNumber != "" { return "bank" From 4a604f6834eced0e75592874cab76071e3276e62 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Mon, 22 Jul 2019 15:09:38 +1000 Subject: [PATCH 13/24] feat(billing): types --- billing.go | 6 +++--- billing_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/billing.go b/billing.go index 719463d..99f6013 100644 --- a/billing.go +++ b/billing.go @@ -83,8 +83,8 @@ type Billing struct { LastFour string `xml:"last_four,omitempty"` CardType string `xml:"card_type,omitempty"` Number string `xml:"number,omitempty"` - Month string `xml:"month,omitempty"` - Year string `xml:"year,omitempty"` + Month int `xml:"month,omitempty"` + Year int `xml:"year,omitempty"` VerificationValue string `xml:"verification_value,omitempty"` // Create/update only // Paypal @@ -107,7 +107,7 @@ type Billing struct { // Type returns the billing info type. Returns either "", "bank", or an empty string. func (b Billing) Type() string { - if b.FirstSix != "" && b.LastFour != "" && b.Month != "" && b.Year != "" { + if b.FirstSix != "" && b.LastFour != "" && b.Month > 0 && b.Year > 0 { return "card" } else if b.NameOnAccount != "" && b.RoutingNumber != "" && b.AccountNumber != "" { return "bank" diff --git a/billing_test.go b/billing_test.go index e730a9f..f08a6f8 100644 --- a/billing_test.go +++ b/billing_test.go @@ -318,8 +318,8 @@ func TestBilling_Create(t *testing.T) { Zip: "94105", Country: "US", Number: "4111111111111111", - Month: "10", - Year: "2020", + Month: 10, + Year: 2020, }); !s.Invoked { t.Fatal("expected fn invocation") } else if err != nil { @@ -420,8 +420,8 @@ func TestBilling_Update(t *testing.T) { Zip: "94105", Country: "US", Number: "4111111111111111", - Month: "10", - Year: "2020", + Month: 10, + Year: 2020, }); !s.Invoked { t.Fatal("expected fn invocation") } else if err != nil { From 726b070061aa837c6434fc4aced0979d99c44add Mon Sep 17 00:00:00 2001 From: Denys Misko Date: Tue, 23 Jul 2019 08:41:14 +1000 Subject: [PATCH 14/24] Add closed_invoice_notification notification type --- webhooks/charge_invoices.go | 1 + webhooks/webhooks.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/webhooks/charge_invoices.go b/webhooks/charge_invoices.go index fbb971d..411ad38 100644 --- a/webhooks/charge_invoices.go +++ b/webhooks/charge_invoices.go @@ -16,6 +16,7 @@ const ( PaidChargeInvoice = "paid_charge_invoice_notification" FailedChargeInvoice = "failed_charge_invoice_notification" ReopenedChargeInvoice = "reopened_charge_invoice_notification" + ClosedInvoiceNotification = "closed_invoice_notification" ) // ChargeInvoiceNotification is returned for all charge invoice notifications. diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index fce5c1e..e15bc4c 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -55,7 +55,7 @@ func nameToNotification(name string) (interface{}, error) { case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, ResumedSubscription, ScheduledPauseSubscription, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil - case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice: + case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification: return &ChargeInvoiceNotification{Type: name}, nil case NewCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: return &CreditInvoiceNotification{Type: name}, nil From 4febd76ead6e387f11a286af980b3f276c876934 Mon Sep 17 00:00:00 2001 From: Denys Misko Date: Wed, 24 Jul 2019 10:50:18 +1000 Subject: [PATCH 15/24] Add updated invoice notification --- webhooks/charge_invoices.go | 17 +++++++++-------- webhooks/webhooks.go | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/webhooks/charge_invoices.go b/webhooks/charge_invoices.go index 411ad38..ddd324b 100644 --- a/webhooks/charge_invoices.go +++ b/webhooks/charge_invoices.go @@ -9,14 +9,15 @@ import ( // Charge invoice notifications. // https://dev.recurly.com/page/webhooks#charge-invoice-notifications const ( - NewChargeInvoice = "new_charge_invoice_notification" - ProcessingChargeInvoice = "processing_charge_invoice_notification" - PastDueInvoice = "past_due_invoice_notification" - PastDueChargeInvoice = "past_due_charge_invoice_notification" - PaidChargeInvoice = "paid_charge_invoice_notification" - FailedChargeInvoice = "failed_charge_invoice_notification" - ReopenedChargeInvoice = "reopened_charge_invoice_notification" - ClosedInvoiceNotification = "closed_invoice_notification" + NewChargeInvoice = "new_charge_invoice_notification" + ProcessingChargeInvoice = "processing_charge_invoice_notification" + PastDueInvoice = "past_due_invoice_notification" + PastDueChargeInvoice = "past_due_charge_invoice_notification" + PaidChargeInvoice = "paid_charge_invoice_notification" + FailedChargeInvoice = "failed_charge_invoice_notification" + ReopenedChargeInvoice = "reopened_charge_invoice_notification" + ClosedInvoiceNotification = "closed_invoice_notification" + UpdatedInvoiceNotification = "updated_invoice_notification" ) // ChargeInvoiceNotification is returned for all charge invoice notifications. diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index e15bc4c..912c70a 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -55,7 +55,7 @@ func nameToNotification(name string) (interface{}, error) { case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, ResumedSubscription, ScheduledPauseSubscription, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil - case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification: + case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification, UpdatedInvoiceNotification: return &ChargeInvoiceNotification{Type: name}, nil case NewCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: return &CreditInvoiceNotification{Type: name}, nil From 76e23cd9f954ce362cc18d9298563275f286771b Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Wed, 24 Jul 2019 11:52:26 +1000 Subject: [PATCH 16/24] feat(webhooks): add UpdatedChargeInvoiceNotification && PendingInvoiceNotification --- webhooks/charge_invoices.go | 20 +++++++++++--------- webhooks/webhooks.go | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/webhooks/charge_invoices.go b/webhooks/charge_invoices.go index ddd324b..0de389b 100644 --- a/webhooks/charge_invoices.go +++ b/webhooks/charge_invoices.go @@ -9,15 +9,17 @@ import ( // Charge invoice notifications. // https://dev.recurly.com/page/webhooks#charge-invoice-notifications const ( - NewChargeInvoice = "new_charge_invoice_notification" - ProcessingChargeInvoice = "processing_charge_invoice_notification" - PastDueInvoice = "past_due_invoice_notification" - PastDueChargeInvoice = "past_due_charge_invoice_notification" - PaidChargeInvoice = "paid_charge_invoice_notification" - FailedChargeInvoice = "failed_charge_invoice_notification" - ReopenedChargeInvoice = "reopened_charge_invoice_notification" - ClosedInvoiceNotification = "closed_invoice_notification" - UpdatedInvoiceNotification = "updated_invoice_notification" + NewChargeInvoice = "new_charge_invoice_notification" + ProcessingChargeInvoice = "processing_charge_invoice_notification" + PastDueInvoice = "past_due_invoice_notification" + PastDueChargeInvoice = "past_due_charge_invoice_notification" + PaidChargeInvoice = "paid_charge_invoice_notification" + FailedChargeInvoice = "failed_charge_invoice_notification" + ReopenedChargeInvoice = "reopened_charge_invoice_notification" + ClosedInvoiceNotification = "closed_invoice_notification" + UpdatedInvoiceNotification = "updated_invoice_notification" + UpdatedChargeInvoiceNotification = "updated_charge_invoice_notification" + PendingInvoiceNotification = "pending_invoice_notification" ) // ChargeInvoiceNotification is returned for all charge invoice notifications. diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 912c70a..6a5dafb 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -55,7 +55,7 @@ func nameToNotification(name string) (interface{}, error) { case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, ResumedSubscription, ScheduledPauseSubscription, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil - case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification, UpdatedInvoiceNotification: + case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification, UpdatedInvoiceNotification, UpdatedChargeInvoiceNotification, PendingInvoiceNotification: return &ChargeInvoiceNotification{Type: name}, nil case NewCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: return &CreditInvoiceNotification{Type: name}, nil From 9d9eafb44c4960fbcd1488403d6081a00e476936 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Fri, 26 Jul 2019 16:55:43 +1000 Subject: [PATCH 17/24] feat(recurly): correct use of error pointer && add 3d secure token --- recurly.go | 4 ++-- transactions.go | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/recurly.go b/recurly.go index 2b27c7f..c19159f 100644 --- a/recurly.go +++ b/recurly.go @@ -325,7 +325,7 @@ func (r *response) parseClientError(v interface{}) error { // Any transaction errors return TransactionFailedError. if e.Transaction != nil || e.TransactionError != nil { - transFailedErr := &TransactionFailedError{ + transFailedErr := TransactionFailedError{ Response: r.Response, Transaction: e.Transaction, } @@ -433,7 +433,7 @@ type TransactionFailedError struct { TransactionError TransactionError } -func (e *TransactionFailedError) Error() string { +func (e TransactionFailedError) Error() string { return fmt.Sprintf("transaction failed: %s %s: %d [%s/%s/%s]", e.Response.Request.Method, e.Response.Request.URL.Path, diff --git a/transactions.go b/transactions.go index 458c02c..1f189f7 100644 --- a/transactions.go +++ b/transactions.go @@ -77,12 +77,13 @@ type Transaction struct { // // https://dev.recurly.com/page/transaction-errors type TransactionError struct { - XMLName xml.Name `xml:"transaction_error"` - ErrorCode string `xml:"error_code,omitempty"` - ErrorCategory string `xml:"error_category,omitempty"` - MerchantMessage string `xml:"merchant_message,omitempty"` - CustomerMessage string `xml:"customer_message,omitempty"` - GatewayErrorCode string `xml:"gateway_error_code,omitempty"` + XMLName xml.Name `xml:"transaction_error"` + ErrorCode string `xml:"error_code,omitempty"` + ErrorCategory string `xml:"error_category,omitempty"` + MerchantMessage string `xml:"merchant_message,omitempty"` + CustomerMessage string `xml:"customer_message,omitempty"` + GatewayErrorCode string `xml:"gateway_error_code,omitempty"` + ThreeDSecureActionTokenId string `xml:"three_d_secure_action_token_id,omitempty"` } // UnmarshalXML unmarshals transactions and handles intermediary state during unmarshaling From e622add29e78965e19bdb074e7233e523115711d Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Tue, 30 Jul 2019 11:22:43 +1000 Subject: [PATCH 18/24] feat(billing): bump version && add 3d token --- billing.go | 2 ++ recurly.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/billing.go b/billing.go index 99f6013..b5125b8 100644 --- a/billing.go +++ b/billing.go @@ -103,6 +103,8 @@ type Billing struct { ExternalHPPType string `xml:"external_hpp_type,omitempty"` // only usable with purchases API Currency string `xml:"currency,omitempty"` // Create/update only Token string `xml:"token_id,omitempty"` // Create/update only + + ThreeDSecureActionResultTokenId string `xml:"three_d_secure_action_result_token_id,omitempty"` // Create/update only } // Type returns the billing info type. Returns either "", "bank", or an empty string. diff --git a/recurly.go b/recurly.go index c19159f..20f526b 100644 --- a/recurly.go +++ b/recurly.go @@ -19,7 +19,7 @@ import ( // apiVersion is the API version in use by this client. // NOTE: v2.19: // - Parent/child accounts not yet implemented. -const apiVersion = "2.20" +const apiVersion = "2.21" // uaVersion is the userAgent version sent to Recurly so they can track usage // of this library. From caddb20601c9b8d6e9f80990bd2c51338049b9bb Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Mon, 1 Mar 2021 09:06:25 +1100 Subject: [PATCH 19/24] add new notif --- webhooks/pre_renewal_notification.go | 14 ++++++++++++++ webhooks/webhooks.go | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 webhooks/pre_renewal_notification.go diff --git a/webhooks/pre_renewal_notification.go b/webhooks/pre_renewal_notification.go new file mode 100644 index 0000000..b1e0109 --- /dev/null +++ b/webhooks/pre_renewal_notification.go @@ -0,0 +1,14 @@ +package webhooks + +import "github.com/autopilot3/recurly" + +const ( + PreRenewal = "prerenewal_notification" +) + +// NewDunningEventNotification is returned for new dunning events. +type PreRenewalNotification struct { + Type string `xml:"-"` + Account Account + Subscription recurly.Subscription +} diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 8a27b91..e2ed89f 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -65,6 +65,8 @@ func nameToNotification(name string) (interface{}, error) { return &PaymentNotification{Type: name}, nil case NewDunningEvent: return &NewDunningEventNotification{Type: name}, nil + case PreRenewal: + return &PreRenewalNotification{Type: name}, nil } return nil, ErrUnknownNotification{name: name} } From 54b69388d7fd1b30947f87da8897218910b74710 Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Tue, 27 Apr 2021 08:22:45 +1000 Subject: [PATCH 20/24] New dummy event --- webhooks/new_shipping_address.go | 14 ++++++++++++++ webhooks/webhooks.go | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 webhooks/new_shipping_address.go diff --git a/webhooks/new_shipping_address.go b/webhooks/new_shipping_address.go new file mode 100644 index 0000000..2530aaf --- /dev/null +++ b/webhooks/new_shipping_address.go @@ -0,0 +1,14 @@ +package webhooks + +import "github.com/autopilot3/recurly" + +const ( + NewShippingAddress = "new_shipping_address_notification" +) + +// NewDunningEventNotification is returned for new dunning events. +type NewShippingAddressNotification struct { + Type string `xml:"-"` + Account Account + Subscription recurly.Subscription +} diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index e2ed89f..41a0078 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -67,6 +67,8 @@ func nameToNotification(name string) (interface{}, error) { return &NewDunningEventNotification{Type: name}, nil case PreRenewal: return &PreRenewalNotification{Type: name}, nil + case NewShippingAddress: + return &NewShippingAddress{Type: name}, nil } return nil, ErrUnknownNotification{name: name} } From 9e1908ca21c937283e7b45e343b9705c15088ddd Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Tue, 27 Apr 2021 09:10:38 +1000 Subject: [PATCH 21/24] add 2nd missing notif --- webhooks/subscriptions.go | 25 +++++++++++++------------ webhooks/webhooks.go | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/webhooks/subscriptions.go b/webhooks/subscriptions.go index 6ffea38..3454370 100644 --- a/webhooks/subscriptions.go +++ b/webhooks/subscriptions.go @@ -5,18 +5,19 @@ import "github.com/autopilot3/recurly" // Subscription notifications. // https://dev.recurly.com/page/webhooks#subscription-notifications const ( - NewSubscription = "new_subscription_notification" - UpdatedSubscription = "updated_subscription_notification" - RenewedSubscription = "renewed_subscription_notification" - ExpiredSubscription = "expired_subscription_notification" - CanceledSubscription = "canceled_subscription_notification" - PausedSubscription = "subscription_paused_notification" - ResumedSubscription = "subscription_resumed_notification" - ScheduledPauseSubscription = "scheduled_subscription_pause_notification" - ModifiedPauseSubscription = "subscription_pause_modified_notification" - PausedRenewalSubscription = "paused_subscription_renewal_notification" - PauseCanceledSubscription = "subscription_pause_canceled_notification" - ReactivatedAccount = "reactivated_account_notification" + NewSubscription = "new_subscription_notification" + UpdatedSubscription = "updated_subscription_notification" + RenewedSubscription = "renewed_subscription_notification" + ExpiredSubscription = "expired_subscription_notification" + CanceledSubscription = "canceled_subscription_notification" + PausedSubscription = "subscription_paused_notification" + ResumedSubscription = "subscription_resumed_notification" + ScheduledPauseSubscription = "scheduled_subscription_pause_notification" + ScheduledSubscriptionUpdate = "scheduled_subscription_update_notification" + ModifiedPauseSubscription = "subscription_pause_modified_notification" + PausedRenewalSubscription = "paused_subscription_renewal_notification" + PauseCanceledSubscription = "subscription_pause_canceled_notification" + ReactivatedAccount = "reactivated_account_notification" ) // SubscriptionNotification is returned for all subscription notifications. diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 41a0078..748de6e 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -53,7 +53,7 @@ func nameToNotification(name string) (interface{}, error) { case BillingInfoUpdated, NewAccount, UpdatedAccount, CanceledAccount, BillingInfoUpdateFailed: return &AccountNotification{Type: name}, nil case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, - ResumedSubscription, ScheduledPauseSubscription, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: + ResumedSubscription, ScheduledPauseSubscription, ScheduledSubscriptionUpdate,ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification, UpdatedInvoiceNotification, UpdatedChargeInvoiceNotification, PendingInvoiceNotification: return &ChargeInvoiceNotification{Type: name}, nil From 55c5146dde2d132dac00ba3f06f4dfcaa2fdfeca Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Tue, 27 Apr 2021 09:11:46 +1000 Subject: [PATCH 22/24] fix notification --- webhooks/webhooks.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 748de6e..66a01e4 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -50,7 +50,7 @@ func Parse(r io.Reader) (interface{}, error) { // nameToNotification returns the notification interface. func nameToNotification(name string) (interface{}, error) { switch name { - case BillingInfoUpdated, NewAccount, UpdatedAccount, CanceledAccount, BillingInfoUpdateFailed: + case BillingInfoUpdated, NewAccount, UpdatedAccount, CanceledAccount, BillingInfoUpdateFailed, NewShippingAddress: return &AccountNotification{Type: name}, nil case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, ResumedSubscription, ScheduledPauseSubscription, ScheduledSubscriptionUpdate,ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: @@ -67,8 +67,6 @@ func nameToNotification(name string) (interface{}, error) { return &NewDunningEventNotification{Type: name}, nil case PreRenewal: return &PreRenewalNotification{Type: name}, nil - case NewShippingAddress: - return &NewShippingAddress{Type: name}, nil } return nil, ErrUnknownNotification{name: name} } From 41c33da99e053345467b79cb44b15617183553db Mon Sep 17 00:00:00 2001 From: Melvin Moustaid Date: Tue, 27 Apr 2021 09:22:09 +1000 Subject: [PATCH 23/24] remove file && move type --- webhooks/accounts.go | 1 + webhooks/new_shipping_address.go | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 webhooks/new_shipping_address.go diff --git a/webhooks/accounts.go b/webhooks/accounts.go index 2facca9..6e34a27 100644 --- a/webhooks/accounts.go +++ b/webhooks/accounts.go @@ -10,6 +10,7 @@ const ( CanceledAccount = "canceled_account_notification" BillingInfoUpdated = "billing_info_updated_notification" BillingInfoUpdateFailed = "billing_info_update_failed_notification" + NewShippingAddress = "new_shipping_address_notification" ) // AccountNotification is returned for all account notifications. diff --git a/webhooks/new_shipping_address.go b/webhooks/new_shipping_address.go deleted file mode 100644 index 2530aaf..0000000 --- a/webhooks/new_shipping_address.go +++ /dev/null @@ -1,14 +0,0 @@ -package webhooks - -import "github.com/autopilot3/recurly" - -const ( - NewShippingAddress = "new_shipping_address_notification" -) - -// NewDunningEventNotification is returned for new dunning events. -type NewShippingAddressNotification struct { - Type string `xml:"-"` - Account Account - Subscription recurly.Subscription -} From f4214a428d0590ea5b18945ceeeb547edafb816f Mon Sep 17 00:00:00 2001 From: Denys Misko Date: Fri, 12 Aug 2022 09:18:50 +1000 Subject: [PATCH 24/24] Add updated_credit_invoice_notification notification --- webhooks/credit_invoices.go | 1 + webhooks/webhooks.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/webhooks/credit_invoices.go b/webhooks/credit_invoices.go index e057ad1..1ffcf64 100644 --- a/webhooks/credit_invoices.go +++ b/webhooks/credit_invoices.go @@ -10,6 +10,7 @@ import ( // https://dev.recurly.com/page/webhooks#charge-invoice-notifications const ( NewCreditInvoice = "new_credit_invoice_notification" + UpdatedCreditInvoice = "updated_credit_invoice_notification" ProcessingCreditInvoice = "processing_credit_invoice_notification" ClosedCreditInvoice = "closed_credit_invoice_notification" VoidedCreditInvoice = "voided_credit_invoice_notification" diff --git a/webhooks/webhooks.go b/webhooks/webhooks.go index 66a01e4..6c0158c 100644 --- a/webhooks/webhooks.go +++ b/webhooks/webhooks.go @@ -53,11 +53,11 @@ func nameToNotification(name string) (interface{}, error) { case BillingInfoUpdated, NewAccount, UpdatedAccount, CanceledAccount, BillingInfoUpdateFailed, NewShippingAddress: return &AccountNotification{Type: name}, nil case NewSubscription, UpdatedSubscription, RenewedSubscription, ExpiredSubscription, CanceledSubscription, ReactivatedAccount, PausedSubscription, - ResumedSubscription, ScheduledPauseSubscription, ScheduledSubscriptionUpdate,ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: + ResumedSubscription, ScheduledPauseSubscription, ScheduledSubscriptionUpdate, ModifiedPauseSubscription, PausedRenewalSubscription, PauseCanceledSubscription: return &SubscriptionNotification{Type: name}, nil case NewChargeInvoice, ProcessingChargeInvoice, PastDueChargeInvoice, PastDueInvoice, PaidChargeInvoice, FailedChargeInvoice, ReopenedChargeInvoice, ClosedInvoiceNotification, UpdatedInvoiceNotification, UpdatedChargeInvoiceNotification, PendingInvoiceNotification: return &ChargeInvoiceNotification{Type: name}, nil - case NewCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: + case NewCreditInvoice, UpdatedCreditInvoice, ProcessingCreditInvoice, ClosedCreditInvoice, VoidedCreditInvoice, ReopenedCreditInvoice, OpenCreditInvoice: return &CreditInvoiceNotification{Type: name}, nil case NewCreditPayment, VoidedCreditPayment: return &CreditPaymentNotification{Type: name}, nil