From 4d38e829be198eca7908903d78e64906746fce37 Mon Sep 17 00:00:00 2001 From: Brandur Date: Fri, 30 Nov 2018 10:44:20 -0800 Subject: [PATCH] Put `/v1/` prefix as part of all paths instead of URL Traditionally, stripe-go has done something a little weird in that it considered the `/v1/` in API URLs as part of the URL (e.g., `APIURL` or `UploadURL`) instead of part of the paths of individual API calls. So when calling `POST /v1/charges` we'd call `POST /charges` and rely on the fact that `/v1/` was expected to be present in the URL. This has always rubbed me the wrong way a little bit, and caused a little bit of trouble in #733 as we'd been doing something a little hacky when initializing new configs for backends. This has some potential backwards compatibility problems in that people may have been injecting custom URLs (e.g., if they had a testing setup a little like we do for stripe-mock) that included the `/v1/` suffix. I've tried to address this by trimming a `/v1/` suffix when creating a backend with a configured URL. For example: ``` go switch backendType { case APIBackend: if config.URL == "" { config.URL = apiURL } // For a long time we had the `/v1` suffix as part of a configured URL // rather than in the per-package URLs throughout the library. Continue // to support this for the time being by stripping one that's been // passed for better backwards compatibility. config.URL = strings.TrimSuffix(config.URL, "/v1") config.URL = strings.TrimSuffix(config.URL, "/v1/") ``` I believe that will address the problem. There's some risk that I missed a URL string in the project because there are a lot of them. I tried to minimize the risk there by using a tool-assisted project-wide find + replace, then manually examining every string in the project that looks like a URL path (e.g., starts with `"/`). --- account/client.go | 14 ++++----- applepaydomain/client.go | 8 ++--- balance/client.go | 6 ++-- bankaccount/client.go | 20 ++++++------- bitcoinreceiver/client.go | 4 +-- bitcointransaction/client.go | 2 +- card/client.go | 30 +++++++++---------- charge/client.go | 10 +++---- countryspec/client.go | 4 +-- coupon/client.go | 10 +++---- customer/client.go | 10 +++---- discount/client.go | 4 +-- dispute/client.go | 8 ++--- ephemeralkey/client.go | 4 +-- event/client.go | 4 +-- exchangerate/client.go | 4 +-- fee/client.go | 4 +-- feerefund/client.go | 8 ++--- file/client.go | 6 ++-- filelink/client.go | 8 ++--- invoice/client.go | 24 +++++++-------- invoiceitem/client.go | 10 +++---- issuerfraudrecord/client.go | 4 +-- issuing/authorization/client.go | 10 +++---- issuing/card/client.go | 10 +++---- issuing/cardholder/client.go | 8 ++--- issuing/dispute/client.go | 8 ++--- issuing/transaction/client.go | 6 ++-- loginlink/client.go | 2 +- order/client.go | 12 ++++---- orderreturn/client.go | 2 +- paymentintent/client.go | 14 ++++----- paymentsource/client.go | 14 ++++----- payout/client.go | 10 +++---- person/client.go | 10 +++---- plan/client.go | 10 +++---- product/client.go | 10 +++---- radar/valuelist/client.go | 10 +++---- radar/valuelistitem/client.go | 8 ++--- recipient/client.go | 8 ++--- refund/client.go | 8 ++--- reporting/reportrun/client.go | 6 ++-- reporting/reporttype/client.go | 4 +-- reversal/client.go | 8 ++--- review/client.go | 6 ++-- sigma/scheduledqueryrun/client.go | 4 +-- sku/client.go | 10 +++---- source/client.go | 8 ++--- sourcetransaction/client.go | 2 +- stripe.go | 28 +++++++++++------- stripe_test.go | 47 +++++++++++++++++++++++++++--- sub/client.go | 10 +++---- subitem/client.go | 10 +++---- terminal/connectiontoken/client.go | 2 +- terminal/location/client.go | 8 ++--- terminal/reader/client.go | 8 ++--- threedsecure/client.go | 4 +-- token/client.go | 4 +-- topup/client.go | 10 +++---- transfer/client.go | 8 ++--- usagerecord/client.go | 2 +- usagerecordsummary/client.go | 2 +- webhookendpoint/client.go | 10 +++---- 63 files changed, 307 insertions(+), 260 deletions(-) diff --git a/account/client.go b/account/client.go index aa4cbdaedb..1d23cbbc71 100644 --- a/account/client.go +++ b/account/client.go @@ -24,7 +24,7 @@ func New(params *stripe.AccountParams) (*stripe.Account, error) { // New creates a new account. func (c Client) New(params *stripe.AccountParams) (*stripe.Account, error) { acct := &stripe.Account{} - err := c.B.Call(http.MethodPost, "/accounts", c.Key, params, acct) + err := c.B.Call(http.MethodPost, "/v1/accounts", c.Key, params, acct) return acct, err } @@ -36,7 +36,7 @@ func Get() (*stripe.Account, error) { // Get retrieves the authenticating account. func (c Client) Get() (*stripe.Account, error) { account := &stripe.Account{} - err := c.B.Call(http.MethodGet, "/account", c.Key, nil, account) + err := c.B.Call(http.MethodGet, "/v1/account", c.Key, nil, account) return account, err } @@ -47,7 +47,7 @@ func GetByID(id string, params *stripe.AccountParams) (*stripe.Account, error) { // GetByID retrieves an account. func (c Client) GetByID(id string, params *stripe.AccountParams) (*stripe.Account, error) { - path := stripe.FormatURLPath("/accounts/%s", id) + path := stripe.FormatURLPath("/v1/accounts/%s", id) account := &stripe.Account{} err := c.B.Call(http.MethodGet, path, c.Key, params, account) return account, err @@ -60,7 +60,7 @@ func Update(id string, params *stripe.AccountParams) (*stripe.Account, error) { // Update updates an account. func (c Client) Update(id string, params *stripe.AccountParams) (*stripe.Account, error) { - path := stripe.FormatURLPath("/accounts/%s", id) + path := stripe.FormatURLPath("/v1/accounts/%s", id) acct := &stripe.Account{} err := c.B.Call(http.MethodPost, path, c.Key, params, acct) return acct, err @@ -73,7 +73,7 @@ func Del(id string, params *stripe.AccountParams) (*stripe.Account, error) { // Del deletes an account. func (c Client) Del(id string, params *stripe.AccountParams) (*stripe.Account, error) { - path := stripe.FormatURLPath("/accounts/%s", id) + path := stripe.FormatURLPath("/v1/accounts/%s", id) acct := &stripe.Account{} err := c.B.Call(http.MethodDelete, path, c.Key, params, acct) return acct, err @@ -86,7 +86,7 @@ func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, err // Reject rejects an account. func (c Client) Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) { - path := stripe.FormatURLPath("/accounts/%s/reject", id) + path := stripe.FormatURLPath("/v1/accounts/%s/reject", id) acct := &stripe.Account{} err := c.B.Call(http.MethodPost, path, c.Key, params, acct) return acct, err @@ -101,7 +101,7 @@ func List(params *stripe.AccountListParams) *Iter { func (c Client) List(listParams *stripe.AccountListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.AccountList{} - err := c.B.CallRaw(http.MethodGet, "/accounts", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/accounts", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/applepaydomain/client.go b/applepaydomain/client.go index bc91c41ee1..48c7bb6fec 100644 --- a/applepaydomain/client.go +++ b/applepaydomain/client.go @@ -22,7 +22,7 @@ func New(params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) { // New creates a new Apple Pay domain. func (c Client) New(params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) { domain := &stripe.ApplePayDomain{} - err := c.B.Call(http.MethodPost, "/apple_pay/domains", c.Key, params, domain) + err := c.B.Call(http.MethodPost, "/v1/apple_pay/domains", c.Key, params, domain) return domain, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain // Get retrieves an Apple Pay domain. func (c Client) Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) { - path := stripe.FormatURLPath("/apple_pay/domains/%s", id) + path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id) domain := &stripe.ApplePayDomain{} err := c.B.Call(http.MethodGet, path, c.Key, params, domain) return domain, err @@ -46,7 +46,7 @@ func Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain // Del removes an Apple Pay domain. func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) { - path := stripe.FormatURLPath("/apple_pay/domains/%s", id) + path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id) domain := &stripe.ApplePayDomain{} err := c.B.Call(http.MethodDelete, path, c.Key, params, domain) return domain, err @@ -61,7 +61,7 @@ func List(params *stripe.ApplePayDomainListParams) *Iter { func (c Client) List(listParams *stripe.ApplePayDomainListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ApplePayDomainList{} - err := c.B.CallRaw(http.MethodGet, "/apple_pay/domains", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/apple_pay/domains", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/balance/client.go b/balance/client.go index 026c4cb66f..4d67314e3c 100644 --- a/balance/client.go +++ b/balance/client.go @@ -22,7 +22,7 @@ func Get(params *stripe.BalanceParams) (*stripe.Balance, error) { // Get retrieves an account's balance func (c Client) Get(params *stripe.BalanceParams) (*stripe.Balance, error) { balance := &stripe.Balance{} - err := c.B.Call(http.MethodGet, "/balance", c.Key, params, balance) + err := c.B.Call(http.MethodGet, "/v1/balance", c.Key, params, balance) return balance, err } @@ -33,7 +33,7 @@ func GetBalanceTransaction(id string, params *stripe.BalanceTransactionParams) ( // GetBalanceTransaction retrieves a balance transaction func (c Client) GetBalanceTransaction(id string, params *stripe.BalanceTransactionParams) (*stripe.BalanceTransaction, error) { - path := stripe.FormatURLPath("/balance/history/%s", id) + path := stripe.FormatURLPath("/v1/balance/history/%s", id) balance := &stripe.BalanceTransaction{} err := c.B.Call(http.MethodGet, path, c.Key, params, balance) return balance, err @@ -48,7 +48,7 @@ func List(params *stripe.BalanceTransactionListParams) *Iter { func (c Client) List(listParams *stripe.BalanceTransactionListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.BalanceTransactionList{} - err := c.B.CallRaw(http.MethodGet, "/balance/history", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/balance/history", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/bankaccount/client.go b/bankaccount/client.go index 66c1057ce1..cbbff09301 100644 --- a/bankaccount/client.go +++ b/bankaccount/client.go @@ -28,9 +28,9 @@ func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, erro var path string if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources", stripe.StringValue(params.Customer)) + path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(params.Customer)) } else if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts", stripe.StringValue(params.Account)) + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts", stripe.StringValue(params.Account)) } else { return nil, errors.New("Invalid bank account params: either Customer or Account need to be set") } @@ -63,9 +63,9 @@ func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAc var path string if params != nil && params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params != nil && params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else { return nil, errors.New("Invalid bank account params: either Customer or Account need to be set") } @@ -88,9 +88,9 @@ func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.Ban var path string if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else { return nil, errors.New("Invalid bank account params: either Customer or Account need to be set") } @@ -113,9 +113,9 @@ func (c Client) Del(id string, params *stripe.BankAccountParams) (*stripe.BankAc var path string if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else { return nil, errors.New("Invalid bank account params: either Customer or Account need to be set") } @@ -142,10 +142,10 @@ func (c Client) List(listParams *stripe.BankAccountListParams) *Iter { if listParams == nil { outerErr = errors.New("params should not be nil") } else if listParams.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources", + path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(listParams.Customer)) } else if listParams.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts", + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts", stripe.StringValue(listParams.Account)) } else { outerErr = errors.New("Invalid bank account params: either Customer or Account need to be set") diff --git a/bitcoinreceiver/client.go b/bitcoinreceiver/client.go index 4154908b52..1dbf274a3b 100644 --- a/bitcoinreceiver/client.go +++ b/bitcoinreceiver/client.go @@ -24,7 +24,7 @@ func Get(id string) (*stripe.BitcoinReceiver, error) { // Get returns the details of a bitcoin receiver. func (c Client) Get(id string) (*stripe.BitcoinReceiver, error) { - path := stripe.FormatURLPath("/bitcoin/receivers/%s", id) + path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s", id) bitcoinReceiver := &stripe.BitcoinReceiver{} err := c.B.Call(http.MethodGet, path, c.Key, nil, bitcoinReceiver) return bitcoinReceiver, err @@ -39,7 +39,7 @@ func List(params *stripe.BitcoinReceiverListParams) *Iter { func (c Client) List(listParams *stripe.BitcoinReceiverListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.BitcoinReceiverList{} - err := c.B.CallRaw(http.MethodGet, "/bitcoin/receivers", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/bitcoin/receivers", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/bitcointransaction/client.go b/bitcointransaction/client.go index b2c7f56724..7950dbb7e2 100644 --- a/bitcointransaction/client.go +++ b/bitcointransaction/client.go @@ -22,7 +22,7 @@ func List(params *stripe.BitcoinTransactionListParams) *Iter { // List returns a list of bitcoin transactions. func (c Client) List(listParams *stripe.BitcoinTransactionListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { - path := stripe.FormatURLPath("/bitcoin/receivers/%s/transactions", + path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s/transactions", stripe.StringValue(listParams.Receiver)) list := &stripe.BitcoinTransactionList{} err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) diff --git a/card/client.go b/card/client.go index ff4fca8faa..2fe4cb12c7 100644 --- a/card/client.go +++ b/card/client.go @@ -28,13 +28,13 @@ func (c Client) New(params *stripe.CardParams) (*stripe.Card, error) { var path string if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts", + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts", stripe.StringValue(params.Account)) } else if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources", + path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(params.Customer)) } else if params.Recipient != nil { - path = stripe.FormatURLPath("/recipients/%s/cards", + path = stripe.FormatURLPath("/v1/recipients/%s/cards", stripe.StringValue(params.Recipient)) } else { return nil, errors.New("Invalid card params: either account, customer or recipient need to be set") @@ -68,13 +68,13 @@ func (c Client) Get(id string, params *stripe.CardParams) (*stripe.Card, error) var path string if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params.Recipient != nil { - path = stripe.FormatURLPath("/recipients/%s/cards/%s", + path = stripe.FormatURLPath("/v1/recipients/%s/cards/%s", stripe.StringValue(params.Recipient), id) } else { return nil, errors.New("Invalid card params: either account, customer or recipient need to be set") @@ -98,13 +98,13 @@ func (c Client) Update(id string, params *stripe.CardParams) (*stripe.Card, erro var path string if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params.Recipient != nil { - path = stripe.FormatURLPath("/recipients/%s/cards/%s", + path = stripe.FormatURLPath("/v1/recipients/%s/cards/%s", stripe.StringValue(params.Recipient), id) } else { return nil, errors.New("Invalid card params: either account, customer or recipient need to be set") @@ -128,11 +128,11 @@ func (c Client) Del(id string, params *stripe.CardParams) (*stripe.Card, error) var path string if params.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts/%s", stripe.StringValue(params.Account), id) } else if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) } else if params.Recipient != nil { - path = stripe.FormatURLPath("/recipients/%s/cards/%s", stripe.StringValue(params.Recipient), id) + path = stripe.FormatURLPath("/v1/recipients/%s/cards/%s", stripe.StringValue(params.Recipient), id) } else { return nil, errors.New("Invalid card params: either account, customer or recipient need to be set") } @@ -158,13 +158,13 @@ func (c Client) List(listParams *stripe.CardListParams) *Iter { if listParams == nil { outerErr = errors.New("params should not be nil") } else if listParams.Account != nil { - path = stripe.FormatURLPath("/accounts/%s/external_accounts", + path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts", stripe.StringValue(listParams.Account)) } else if listParams.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources", + path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(listParams.Customer)) } else if listParams.Recipient != nil { - path = stripe.FormatURLPath("/recipients/%s/cards", stripe.StringValue(listParams.Recipient)) + path = stripe.FormatURLPath("/v1/recipients/%s/cards", stripe.StringValue(listParams.Recipient)) } else { outerErr = errors.New("Invalid card params: either account, customer or recipient need to be set") } diff --git a/charge/client.go b/charge/client.go index f64d983e65..a5f17ae979 100644 --- a/charge/client.go +++ b/charge/client.go @@ -24,7 +24,7 @@ func New(params *stripe.ChargeParams) (*stripe.Charge, error) { // New creates a new charge. func (c Client) New(params *stripe.ChargeParams) (*stripe.Charge, error) { charge := &stripe.Charge{} - err := c.B.Call(http.MethodPost, "/charges", c.Key, params, charge) + err := c.B.Call(http.MethodPost, "/v1/charges", c.Key, params, charge) return charge, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.ChargeParams) (*stripe.Charge, error) { // Get retrieves a charge. func (c Client) Get(id string, params *stripe.ChargeParams) (*stripe.Charge, error) { - path := stripe.FormatURLPath("/charges/%s", id) + path := stripe.FormatURLPath("/v1/charges/%s", id) charge := &stripe.Charge{} err := c.B.Call(http.MethodGet, path, c.Key, params, charge) return charge, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.ChargeParams) (*stripe.Charge, error) { // Update updates a charge. func (c Client) Update(id string, params *stripe.ChargeParams) (*stripe.Charge, error) { - path := stripe.FormatURLPath("/charges/%s", id) + path := stripe.FormatURLPath("/v1/charges/%s", id) charge := &stripe.Charge{} err := c.B.Call(http.MethodPost, path, c.Key, params, charge) return charge, err @@ -61,7 +61,7 @@ func Capture(id string, params *stripe.CaptureParams) (*stripe.Charge, error) { // Capture captures a charge that's not yet captured. func (c Client) Capture(id string, params *stripe.CaptureParams) (*stripe.Charge, error) { - path := stripe.FormatURLPath("/charges/%s/capture", id) + path := stripe.FormatURLPath("/v1/charges/%s/capture", id) charge := &stripe.Charge{} err := c.B.Call(http.MethodPost, path, c.Key, params, charge) return charge, err @@ -76,7 +76,7 @@ func List(params *stripe.ChargeListParams) *Iter { func (c Client) List(listParams *stripe.ChargeListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ChargeList{} - err := c.B.CallRaw(http.MethodGet, "/charges", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/charges", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/countryspec/client.go b/countryspec/client.go index 85b3a7a4a9..3c80fe8407 100644 --- a/countryspec/client.go +++ b/countryspec/client.go @@ -21,7 +21,7 @@ func Get(country string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, // Get returns a Country Spec for a given country code. func (c Client) Get(country string, params *stripe.CountrySpecParams) (*stripe.CountrySpec, error) { - path := stripe.FormatURLPath("/country_specs/%s", country) + path := stripe.FormatURLPath("/v1/country_specs/%s", country) countrySpec := &stripe.CountrySpec{} err := c.B.Call(http.MethodGet, path, c.Key, params, countrySpec) return countrySpec, err @@ -36,7 +36,7 @@ func List(params *stripe.CountrySpecListParams) *Iter { func (c Client) List(listParams *stripe.CountrySpecListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.CountrySpecList{} - err := c.B.CallRaw(http.MethodGet, "/country_specs", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/country_specs", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/coupon/client.go b/coupon/client.go index 299a6b41eb..da17e9eeb1 100644 --- a/coupon/client.go +++ b/coupon/client.go @@ -22,7 +22,7 @@ func New(params *stripe.CouponParams) (*stripe.Coupon, error) { // New creates a new coupon. func (c Client) New(params *stripe.CouponParams) (*stripe.Coupon, error) { coupon := &stripe.Coupon{} - err := c.B.Call(http.MethodPost, "/coupons", c.Key, params, coupon) + err := c.B.Call(http.MethodPost, "/v1/coupons", c.Key, params, coupon) return coupon, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { // Get returns the details of a coupon. func (c Client) Get(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { - path := stripe.FormatURLPath("/coupons/%s", id) + path := stripe.FormatURLPath("/v1/coupons/%s", id) coupon := &stripe.Coupon{} err := c.B.Call(http.MethodGet, path, c.Key, params, coupon) return coupon, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { // Update updates a coupon's properties. func (c Client) Update(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { - path := stripe.FormatURLPath("/coupons/%s", id) + path := stripe.FormatURLPath("/v1/coupons/%s", id) coupon := &stripe.Coupon{} err := c.B.Call(http.MethodPost, path, c.Key, params, coupon) return coupon, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { // Del removes a coupon. func (c Client) Del(id string, params *stripe.CouponParams) (*stripe.Coupon, error) { - path := stripe.FormatURLPath("/coupons/%s", id) + path := stripe.FormatURLPath("/v1/coupons/%s", id) coupon := &stripe.Coupon{} err := c.B.Call(http.MethodDelete, path, c.Key, params, coupon) return coupon, err @@ -74,7 +74,7 @@ func List(params *stripe.CouponListParams) *Iter { func (c Client) List(listParams *stripe.CouponListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.CouponList{} - err := c.B.CallRaw(http.MethodGet, "/coupons", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/coupons", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/customer/client.go b/customer/client.go index 55c7a08705..d7cacd5107 100644 --- a/customer/client.go +++ b/customer/client.go @@ -22,7 +22,7 @@ func New(params *stripe.CustomerParams) (*stripe.Customer, error) { // New creates a new customer. func (c Client) New(params *stripe.CustomerParams) (*stripe.Customer, error) { cust := &stripe.Customer{} - err := c.B.Call(http.MethodPost, "/customers", c.Key, params, cust) + err := c.B.Call(http.MethodPost, "/v1/customers", c.Key, params, cust) return cust, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { // Get returns the details of a customer. func (c Client) Get(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { - path := stripe.FormatURLPath("/customers/%s", id) + path := stripe.FormatURLPath("/v1/customers/%s", id) cust := &stripe.Customer{} err := c.B.Call(http.MethodGet, path, c.Key, params, cust) return cust, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) // Update updates a customer's properties. func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { - path := stripe.FormatURLPath("/customers/%s", id) + path := stripe.FormatURLPath("/v1/customers/%s", id) cust := &stripe.Customer{} err := c.B.Call(http.MethodPost, path, c.Key, params, cust) return cust, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { // Del removes a customer. func (c Client) Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { - path := stripe.FormatURLPath("/customers/%s", id) + path := stripe.FormatURLPath("/v1/customers/%s", id) cust := &stripe.Customer{} err := c.B.Call(http.MethodDelete, path, c.Key, params, cust) return cust, err @@ -74,7 +74,7 @@ func List(params *stripe.CustomerListParams) *Iter { func (c Client) List(listParams *stripe.CustomerListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.CustomerList{} - err := c.B.CallRaw(http.MethodGet, "/customers", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/customers", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/discount/client.go b/discount/client.go index 7242ca429f..c001277cd8 100644 --- a/discount/client.go +++ b/discount/client.go @@ -20,7 +20,7 @@ func Del(customerID string, params *stripe.DiscountParams) (*stripe.Discount, er // Del removes a discount from a customer. func (c Client) Del(customerID string, params *stripe.DiscountParams) (*stripe.Discount, error) { - path := stripe.FormatURLPath("/customers/%s/discount", customerID) + path := stripe.FormatURLPath("/v1/customers/%s/discount", customerID) discount := &stripe.Discount{} err := c.B.Call(http.MethodDelete, path, c.Key, params, discount) return discount, err @@ -33,7 +33,7 @@ func DelSubscription(subscriptionID string, params *stripe.DiscountParams) (*str // DelSub removes a discount from a customer's subscription. func (c Client) DelSub(subscriptionID string, params *stripe.DiscountParams) (*stripe.Discount, error) { - path := stripe.FormatURLPath("/subscriptions/%s/discount", subscriptionID) + path := stripe.FormatURLPath("/v1/subscriptions/%s/discount", subscriptionID) discount := &stripe.Discount{} err := c.B.Call(http.MethodDelete, path, c.Key, params, discount) diff --git a/dispute/client.go b/dispute/client.go index 36699756c8..d577b7e5c1 100644 --- a/dispute/client.go +++ b/dispute/client.go @@ -20,7 +20,7 @@ func Get(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { // Get returns the details of a dispute. func (c Client) Get(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { - path := stripe.FormatURLPath("/disputes/%s", id) + path := stripe.FormatURLPath("/v1/disputes/%s", id) dispute := &stripe.Dispute{} err := c.B.Call(http.MethodGet, path, c.Key, params, dispute) return dispute, err @@ -35,7 +35,7 @@ func List(params *stripe.DisputeListParams) *Iter { func (c Client) List(listParams *stripe.DisputeListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.DisputeList{} - err := c.B.CallRaw(http.MethodGet, "/disputes", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/disputes", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -53,7 +53,7 @@ func Update(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { // Update updates a dispute. func (c Client) Update(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { - path := stripe.FormatURLPath("/disputes/%s", id) + path := stripe.FormatURLPath("/v1/disputes/%s", id) dispute := &stripe.Dispute{} err := c.B.Call(http.MethodPost, path, c.Key, params, dispute) return dispute, err @@ -66,7 +66,7 @@ func Close(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { // Close dismisses a dispute in the customer's favor. func (c Client) Close(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) { - path := stripe.FormatURLPath("/disputes/%s/close", id) + path := stripe.FormatURLPath("/v1/disputes/%s/close", id) dispute := &stripe.Dispute{} err := c.B.Call(http.MethodPost, path, c.Key, params, dispute) return dispute, err diff --git a/ephemeralkey/client.go b/ephemeralkey/client.go index daf39771fa..c727c7c957 100644 --- a/ephemeralkey/client.go +++ b/ephemeralkey/client.go @@ -31,7 +31,7 @@ func (c Client) New(params *stripe.EphemeralKeyParams) (*stripe.EphemeralKey, er params.Headers.Add("Stripe-Version", stripe.StringValue(params.StripeVersion)) ephemeralKey := &stripe.EphemeralKey{} - err := c.B.Call(http.MethodPost, "/ephemeral_keys", c.Key, params, ephemeralKey) + err := c.B.Call(http.MethodPost, "/v1/ephemeral_keys", c.Key, params, ephemeralKey) return ephemeralKey, err } @@ -42,7 +42,7 @@ func Del(id string, params *stripe.EphemeralKeyParams) (*stripe.EphemeralKey, er // Del removes an ephemeral key. func (c Client) Del(id string, params *stripe.EphemeralKeyParams) (*stripe.EphemeralKey, error) { - path := stripe.FormatURLPath("/ephemeral_keys/%s", id) + path := stripe.FormatURLPath("/v1/ephemeral_keys/%s", id) ephemeralKey := &stripe.EphemeralKey{} err := c.B.Call(http.MethodDelete, path, c.Key, params, ephemeralKey) return ephemeralKey, err diff --git a/event/client.go b/event/client.go index 3e334d8cca..69209bcde8 100644 --- a/event/client.go +++ b/event/client.go @@ -21,7 +21,7 @@ func Get(id string, params *stripe.EventParams) (*stripe.Event, error) { // Get returns the details of an event. func (c Client) Get(id string, params *stripe.EventParams) (*stripe.Event, error) { - path := stripe.FormatURLPath("/events/%s", id) + path := stripe.FormatURLPath("/v1/events/%s", id) event := &stripe.Event{} err := c.B.Call(http.MethodGet, path, c.Key, params, event) return event, err @@ -36,7 +36,7 @@ func List(params *stripe.EventListParams) *Iter { func (c Client) List(listParams *stripe.EventListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.EventList{} - err := c.B.CallRaw(http.MethodGet, "/events", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/events", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/exchangerate/client.go b/exchangerate/client.go index 7084883e56..8930c12505 100644 --- a/exchangerate/client.go +++ b/exchangerate/client.go @@ -21,7 +21,7 @@ func Get(currency string, params *stripe.ExchangeRateParams) (*stripe.ExchangeRa // Get returns the exchante rate for a given currency. func (c Client) Get(currency string, params *stripe.ExchangeRateParams) (*stripe.ExchangeRate, error) { - path := stripe.FormatURLPath("/exchange_rates/%s", currency) + path := stripe.FormatURLPath("/v1/exchange_rates/%s", currency) exchangeRate := &stripe.ExchangeRate{} err := c.B.Call(http.MethodGet, path, c.Key, params, exchangeRate) @@ -37,7 +37,7 @@ func List(params *stripe.ExchangeRateListParams) *Iter { func (c Client) List(listParams *stripe.ExchangeRateListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ExchangeRateList{} - err := c.B.CallRaw(http.MethodGet, "/exchange_rates", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/exchange_rates", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/fee/client.go b/fee/client.go index 1cafcb566c..0d47d5d188 100644 --- a/fee/client.go +++ b/fee/client.go @@ -21,7 +21,7 @@ func Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee // Get returns the details of an application fee. func (c Client) Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee, error) { - path := stripe.FormatURLPath("/application_fees/%s", id) + path := stripe.FormatURLPath("/v1/application_fees/%s", id) fee := &stripe.ApplicationFee{} err := c.B.Call(http.MethodGet, path, c.Key, params, fee) return fee, err @@ -36,7 +36,7 @@ func List(params *stripe.ApplicationFeeListParams) *Iter { func (c Client) List(listParams *stripe.ApplicationFeeListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ApplicationFeeList{} - err := c.B.CallRaw(http.MethodGet, "/application_fees", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/application_fees", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/feerefund/client.go b/feerefund/client.go index 469c3c6629..f9a422768c 100644 --- a/feerefund/client.go +++ b/feerefund/client.go @@ -29,7 +29,7 @@ func (c Client) New(params *stripe.FeeRefundParams) (*stripe.FeeRefund, error) { return nil, fmt.Errorf("params.ApplicationFee must be set") } - path := stripe.FormatURLPath("/application_fees/%s/refunds", + path := stripe.FormatURLPath("/v1/application_fees/%s/refunds", stripe.StringValue(params.ApplicationFee)) refund := &stripe.FeeRefund{} err := c.B.Call(http.MethodPost, path, c.Key, params, refund) @@ -50,7 +50,7 @@ func (c Client) Get(id string, params *stripe.FeeRefundParams) (*stripe.FeeRefun return nil, fmt.Errorf("params.ApplicationFee must be set") } - path := stripe.FormatURLPath("/application_fees/%s/refunds/%s", + path := stripe.FormatURLPath("/v1/application_fees/%s/refunds/%s", stripe.StringValue(params.ApplicationFee), id) refund := &stripe.FeeRefund{} err := c.B.Call(http.MethodGet, path, c.Key, params, refund) @@ -71,7 +71,7 @@ func (c Client) Update(id string, params *stripe.FeeRefundParams) (*stripe.FeeRe return nil, fmt.Errorf("params.ApplicationFee must be set") } - path := stripe.FormatURLPath("/application_fees/%s/refunds/%s", + path := stripe.FormatURLPath("/v1/application_fees/%s/refunds/%s", stripe.StringValue(params.ApplicationFee), id) refund := &stripe.FeeRefund{} err := c.B.Call(http.MethodPost, path, c.Key, params, refund) @@ -86,7 +86,7 @@ func List(params *stripe.FeeRefundListParams) *Iter { // List returns a list of application fee refunds. func (c Client) List(listParams *stripe.FeeRefundListParams) *Iter { - path := stripe.FormatURLPath("/application_fees/%s/refunds", + path := stripe.FormatURLPath("/v1/application_fees/%s/refunds", stripe.StringValue(listParams.ApplicationFee)) return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { diff --git a/file/client.go b/file/client.go index ca58edf87c..11f23d7417 100644 --- a/file/client.go +++ b/file/client.go @@ -32,7 +32,7 @@ func (c Client) New(params *stripe.FileParams) (*stripe.File, error) { } file := &stripe.File{} - err = c.B.CallMultipart(http.MethodPost, "/files", c.Key, boundary, bodyBuffer, ¶ms.Params, file) + err = c.B.CallMultipart(http.MethodPost, "/v1/files", c.Key, boundary, bodyBuffer, ¶ms.Params, file) return file, err } @@ -45,7 +45,7 @@ func Get(id string, params *stripe.FileParams) (*stripe.File, error) { // Get returns the details of a file. func (c Client) Get(id string, params *stripe.FileParams) (*stripe.File, error) { - path := stripe.FormatURLPath("/files/%s", id) + path := stripe.FormatURLPath("/v1/files/%s", id) file := &stripe.File{} err := c.B.Call(http.MethodGet, path, c.Key, params, file) return file, err @@ -60,7 +60,7 @@ func List(params *stripe.FileListParams) *Iter { func (c Client) List(listParams *stripe.FileListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.FileList{} - err := c.B.CallRaw(http.MethodGet, "/files", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/files", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/filelink/client.go b/filelink/client.go index 0c182f1cc4..d130a681b2 100644 --- a/filelink/client.go +++ b/filelink/client.go @@ -24,7 +24,7 @@ func New(params *stripe.FileLinkParams) (*stripe.FileLink, error) { // New creates a new file link. func (c Client) New(params *stripe.FileLinkParams) (*stripe.FileLink, error) { fileLink := &stripe.FileLink{} - err := c.B.Call(http.MethodPost, "/file_links", c.Key, params, fileLink) + err := c.B.Call(http.MethodPost, "/v1/file_links", c.Key, params, fileLink) return fileLink, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) { // Get retrieves a file link. func (c Client) Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) { - path := stripe.FormatURLPath("/file_links/%s", id) + path := stripe.FormatURLPath("/v1/file_links/%s", id) fileLink := &stripe.FileLink{} err := c.B.Call(http.MethodGet, path, c.Key, params, fileLink) return fileLink, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) // Update updates a file link. func (c Client) Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) { - path := stripe.FormatURLPath("/file_links/%s", id) + path := stripe.FormatURLPath("/v1/file_links/%s", id) fileLink := &stripe.FileLink{} err := c.B.Call(http.MethodPost, path, c.Key, params, fileLink) return fileLink, err @@ -63,7 +63,7 @@ func List(params *stripe.FileLinkListParams) *Iter { func (c Client) List(listParams *stripe.FileLinkListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.FileLinkList{} - err := c.B.CallRaw(http.MethodGet, "/file_links", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/invoice/client.go b/invoice/client.go index af9eec0d35..a8d30e322e 100644 --- a/invoice/client.go +++ b/invoice/client.go @@ -22,7 +22,7 @@ func New(params *stripe.InvoiceParams) (*stripe.Invoice, error) { // New creates a new invoice. func (c Client) New(params *stripe.InvoiceParams) (*stripe.Invoice, error) { invoice := &stripe.Invoice{} - err := c.B.Call(http.MethodPost, "/invoices", c.Key, params, invoice) + err := c.B.Call(http.MethodPost, "/v1/invoices", c.Key, params, invoice) return invoice, err } @@ -33,7 +33,7 @@ func Del(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { // Del deletes an invoice. func (c Client) Del(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s", id) + path := stripe.FormatURLPath("/v1/invoices/%s", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodDelete, path, c.Key, params, invoice) return invoice, err @@ -46,7 +46,7 @@ func Get(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { // Get returns the details of an invoice. func (c Client) Get(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s", id) + path := stripe.FormatURLPath("/v1/invoices/%s", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodGet, path, c.Key, params, invoice) return invoice, err @@ -59,7 +59,7 @@ func Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error) { // Pay pays an invoice. func (c Client) Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s/pay", id) + path := stripe.FormatURLPath("/v1/invoices/%s/pay", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err @@ -72,7 +72,7 @@ func Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { // Update updates an invoice. func (c Client) Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s", id) + path := stripe.FormatURLPath("/v1/invoices/%s", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err @@ -86,7 +86,7 @@ func GetNext(params *stripe.InvoiceParams) (*stripe.Invoice, error) { // GetNext returns an upcoming invoice. func (c Client) GetNext(params *stripe.InvoiceParams) (*stripe.Invoice, error) { invoice := &stripe.Invoice{} - err := c.B.Call(http.MethodGet, "/invoices/upcoming", c.Key, params, invoice) + err := c.B.Call(http.MethodGet, "/v1/invoices/upcoming", c.Key, params, invoice) return invoice, err } @@ -99,7 +99,7 @@ func List(params *stripe.InvoiceListParams) *Iter { func (c Client) List(listParams *stripe.InvoiceListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.InvoiceList{} - err := c.B.CallRaw(http.MethodGet, "/invoices", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/invoices", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -117,7 +117,7 @@ func ListLines(params *stripe.InvoiceLineListParams) *LineIter { // ListLines returns a list of line items on an invoice. func (c Client) ListLines(listParams *stripe.InvoiceLineListParams) *LineIter { - path := stripe.FormatURLPath("/invoices/%s/lines", stripe.StringValue(listParams.ID)) + path := stripe.FormatURLPath("/v1/invoices/%s/lines", stripe.StringValue(listParams.ID)) return &LineIter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.InvoiceLineList{} err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) @@ -138,7 +138,7 @@ func FinalizeInvoice(id string, params *stripe.InvoiceFinalizeParams) (*stripe.I // FinalizeInvoice finalizes an invoice. func (c Client) FinalizeInvoice(id string, params *stripe.InvoiceFinalizeParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s/finalize", id) + path := stripe.FormatURLPath("/v1/invoices/%s/finalize", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err @@ -151,7 +151,7 @@ func MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) // MarkUncollectible marks an invoice as uncollectible. func (c Client) MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s/mark_uncollectible", id) + path := stripe.FormatURLPath("/v1/invoices/%s/mark_uncollectible", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err @@ -164,7 +164,7 @@ func SendInvoice(id string, params *stripe.InvoiceSendParams) (*stripe.Invoice, // SendInvoice sends an invoice. func (c Client) SendInvoice(id string, params *stripe.InvoiceSendParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s/send", id) + path := stripe.FormatURLPath("/v1/invoices/%s/send", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err @@ -177,7 +177,7 @@ func VoidInvoice(id string, params *stripe.InvoiceVoidParams) (*stripe.Invoice, // VoidInvoice voids an invoice. func (c Client) VoidInvoice(id string, params *stripe.InvoiceVoidParams) (*stripe.Invoice, error) { - path := stripe.FormatURLPath("/invoices/%s/void", id) + path := stripe.FormatURLPath("/v1/invoices/%s/void", id) invoice := &stripe.Invoice{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoice) return invoice, err diff --git a/invoiceitem/client.go b/invoiceitem/client.go index 3dfda8ff21..410fe3c31c 100644 --- a/invoiceitem/client.go +++ b/invoiceitem/client.go @@ -22,7 +22,7 @@ func New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { // New creates a new invoice item. func (c Client) New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { invoiceItem := &stripe.InvoiceItem{} - err := c.B.Call(http.MethodPost, "/invoiceitems", c.Key, params, invoiceItem) + err := c.B.Call(http.MethodPost, "/v1/invoiceitems", c.Key, params, invoiceItem) return invoiceItem, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, erro // Get returns the details of an invoice item. func (c Client) Get(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { - path := stripe.FormatURLPath("/invoiceitems/%s", id) + path := stripe.FormatURLPath("/v1/invoiceitems/%s", id) invoiceItem := &stripe.InvoiceItem{} err := c.B.Call(http.MethodGet, path, c.Key, params, invoiceItem) return invoiceItem, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, e // Update updates an invoice item. func (c Client) Update(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { - path := stripe.FormatURLPath("/invoiceitems/%s", id) + path := stripe.FormatURLPath("/v1/invoiceitems/%s", id) invoiceItem := &stripe.InvoiceItem{} err := c.B.Call(http.MethodPost, path, c.Key, params, invoiceItem) return invoiceItem, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, erro // Del removes an invoice item. func (c Client) Del(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { - path := stripe.FormatURLPath("/invoiceitems/%s", id) + path := stripe.FormatURLPath("/v1/invoiceitems/%s", id) ii := &stripe.InvoiceItem{} err := c.B.Call(http.MethodDelete, path, c.Key, params, ii) return ii, err @@ -74,7 +74,7 @@ func List(params *stripe.InvoiceItemListParams) *Iter { func (c Client) List(listParams *stripe.InvoiceItemListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.InvoiceItemList{} - err := c.B.CallRaw(http.MethodGet, "/invoiceitems", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/invoiceitems", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/issuerfraudrecord/client.go b/issuerfraudrecord/client.go index c29f0addf4..fef537ea4c 100644 --- a/issuerfraudrecord/client.go +++ b/issuerfraudrecord/client.go @@ -20,7 +20,7 @@ func Get(id string, params *stripe.IssuerFraudRecordParams) (*stripe.IssuerFraud // Get returns the details of an issuer fraud record. func (c Client) Get(id string, params *stripe.IssuerFraudRecordParams) (*stripe.IssuerFraudRecord, error) { - path := stripe.FormatURLPath("/issuer_fraud_records/%s", id) + path := stripe.FormatURLPath("/v1/issuer_fraud_records/%s", id) ifr := &stripe.IssuerFraudRecord{} err := c.B.Call(http.MethodGet, path, c.Key, params, ifr) return ifr, err @@ -35,7 +35,7 @@ func List(params *stripe.IssuerFraudRecordListParams) *Iter { func (c Client) List(listParams *stripe.IssuerFraudRecordListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuerFraudRecordList{} - err := c.B.CallRaw(http.MethodGet, "/issuer_fraud_records", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuer_fraud_records", c.Key, b, p, list) ret := make([]interface{}, len(list.Values)) for i, v := range list.Values { diff --git a/issuing/authorization/client.go b/issuing/authorization/client.go index 3ccaf73456..d25d39d996 100644 --- a/issuing/authorization/client.go +++ b/issuing/authorization/client.go @@ -23,7 +23,7 @@ func Approve(id string, params *stripe.IssuingAuthorizationParams) (*stripe.Issu // Approve updates an issuing authorization. func (c Client) Approve(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) { - path := stripe.FormatURLPath("/issuing/authorizations/%s/approve", id) + path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/approve", id) authorization := &stripe.IssuingAuthorization{} err := c.B.Call(http.MethodPost, path, c.Key, params, authorization) return authorization, err @@ -36,7 +36,7 @@ func Decline(id string, params *stripe.IssuingAuthorizationParams) (*stripe.Issu // Decline updates an issuing authorization. func (c Client) Decline(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) { - path := stripe.FormatURLPath("/issuing/authorizations/%s/decline", id) + path := stripe.FormatURLPath("/v1/issuing/authorizations/%s/decline", id) authorization := &stripe.IssuingAuthorization{} err := c.B.Call(http.MethodPost, path, c.Key, params, authorization) return authorization, err @@ -49,7 +49,7 @@ func Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingA // Get returns the details of an issuing authorization. func (c Client) Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) { - path := stripe.FormatURLPath("/issuing/authorizations/%s", id) + path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id) authorization := &stripe.IssuingAuthorization{} err := c.B.Call(http.MethodGet, path, c.Key, params, authorization) return authorization, err @@ -62,7 +62,7 @@ func Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.Issui // Update updates an issuing authorization. func (c Client) Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) { - path := stripe.FormatURLPath("/issuing/authorizations/%s", id) + path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id) authorization := &stripe.IssuingAuthorization{} err := c.B.Call(http.MethodPost, path, c.Key, params, authorization) return authorization, err @@ -77,7 +77,7 @@ func List(params *stripe.IssuingAuthorizationListParams) *Iter { func (c Client) List(listParams *stripe.IssuingAuthorizationListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuingAuthorizationList{} - err := c.B.CallRaw(http.MethodGet, "/issuing/authorizations", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuing/authorizations", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/issuing/card/client.go b/issuing/card/client.go index 0f32ae4567..443ae05327 100644 --- a/issuing/card/client.go +++ b/issuing/card/client.go @@ -24,7 +24,7 @@ func New(params *stripe.IssuingCardParams) (*stripe.IssuingCard, error) { // New creates a new issuing card. func (c Client) New(params *stripe.IssuingCardParams) (*stripe.IssuingCard, error) { card := &stripe.IssuingCard{} - err := c.B.Call(http.MethodPost, "/issuing/cards", c.Key, params, card) + err := c.B.Call(http.MethodPost, "/v1/issuing/cards", c.Key, params, card) return card, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCard, erro // Get returns the details of an issuing card. func (c Client) Get(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCard, error) { - path := stripe.FormatURLPath("/issuing/cards/%s", id) + path := stripe.FormatURLPath("/v1/issuing/cards/%s", id) card := &stripe.IssuingCard{} err := c.B.Call(http.MethodGet, path, c.Key, params, card) return card, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCard, e // Update updates an issuing card. func (c Client) Update(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCard, error) { - path := stripe.FormatURLPath("/issuing/cards/%s", id) + path := stripe.FormatURLPath("/v1/issuing/cards/%s", id) card := &stripe.IssuingCard{} err := c.B.Call(http.MethodPost, path, c.Key, params, card) return card, err @@ -63,7 +63,7 @@ func List(params *stripe.IssuingCardListParams) *Iter { func (c Client) List(listParams *stripe.IssuingCardListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuingCardList{} - err := c.B.CallRaw(http.MethodGet, "/issuing/cards", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuing/cards", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -81,7 +81,7 @@ func Details(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCardDe // Details retrieves an issuing card details. func (c Client) Details(id string, params *stripe.IssuingCardParams) (*stripe.IssuingCardDetails, error) { - path := stripe.FormatURLPath("/issuing/cards/%s/details", id) + path := stripe.FormatURLPath("/v1/issuing/cards/%s/details", id) cardDetails := &stripe.IssuingCardDetails{} err := c.B.Call(http.MethodGet, path, c.Key, params, cardDetails) return cardDetails, err diff --git a/issuing/cardholder/client.go b/issuing/cardholder/client.go index 6c64ece18f..f0eb849209 100644 --- a/issuing/cardholder/client.go +++ b/issuing/cardholder/client.go @@ -24,7 +24,7 @@ func New(params *stripe.IssuingCardholderParams) (*stripe.IssuingCardholder, err // New creates a new issuing cardholder. func (c Client) New(params *stripe.IssuingCardholderParams) (*stripe.IssuingCardholder, error) { cardholder := &stripe.IssuingCardholder{} - err := c.B.Call(http.MethodPost, "/issuing/cardholders", c.Key, params, cardholder) + err := c.B.Call(http.MethodPost, "/v1/issuing/cardholders", c.Key, params, cardholder) return cardholder, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.IssuingCardholderParams) (*stripe.IssuingCard // Get returns the details of an issuing cardholder. func (c Client) Get(id string, params *stripe.IssuingCardholderParams) (*stripe.IssuingCardholder, error) { - path := stripe.FormatURLPath("/issuing/cardholders/%s", id) + path := stripe.FormatURLPath("/v1/issuing/cardholders/%s", id) cardholder := &stripe.IssuingCardholder{} err := c.B.Call(http.MethodGet, path, c.Key, params, cardholder) return cardholder, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.IssuingCardholderParams) (*stripe.IssuingC // Update updates an issuing cardholder. func (c Client) Update(id string, params *stripe.IssuingCardholderParams) (*stripe.IssuingCardholder, error) { - path := stripe.FormatURLPath("/issuing/cardholders/%s", id) + path := stripe.FormatURLPath("/v1/issuing/cardholders/%s", id) cardholder := &stripe.IssuingCardholder{} err := c.B.Call(http.MethodPost, path, c.Key, params, cardholder) return cardholder, err @@ -63,7 +63,7 @@ func List(params *stripe.IssuingCardholderListParams) *Iter { func (c Client) List(listParams *stripe.IssuingCardholderListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuingCardholderList{} - err := c.B.CallRaw(http.MethodGet, "/issuing/cardholders", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuing/cardholders", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/issuing/dispute/client.go b/issuing/dispute/client.go index 55a4705747..14d24bbee0 100644 --- a/issuing/dispute/client.go +++ b/issuing/dispute/client.go @@ -24,7 +24,7 @@ func New(params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) { // New creates a new issuing dispute. func (c Client) New(params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) { dispute := &stripe.IssuingDispute{} - err := c.B.Call(http.MethodPost, "/issuing/disputes", c.Key, params, dispute) + err := c.B.Call(http.MethodPost, "/v1/issuing/disputes", c.Key, params, dispute) return dispute, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute // Get returns the details of an issuing dispute. func (c Client) Get(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) { - path := stripe.FormatURLPath("/issuing/disputes/%s", id) + path := stripe.FormatURLPath("/v1/issuing/disputes/%s", id) dispute := &stripe.IssuingDispute{} err := c.B.Call(http.MethodGet, path, c.Key, params, dispute) return dispute, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDisp // Update updates an issuing dispute. func (c Client) Update(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) { - path := stripe.FormatURLPath("/issuing/disputes/%s", id) + path := stripe.FormatURLPath("/v1/issuing/disputes/%s", id) dispute := &stripe.IssuingDispute{} err := c.B.Call(http.MethodPost, path, c.Key, params, dispute) return dispute, err @@ -63,7 +63,7 @@ func List(params *stripe.IssuingDisputeListParams) *Iter { func (c Client) List(listParams *stripe.IssuingDisputeListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuingDisputeList{} - err := c.B.CallRaw(http.MethodGet, "/issuing/disputes", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuing/disputes", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/issuing/transaction/client.go b/issuing/transaction/client.go index 17b88cf2c4..85590a9f88 100644 --- a/issuing/transaction/client.go +++ b/issuing/transaction/client.go @@ -23,7 +23,7 @@ func Get(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTra // Get returns the details of an issuing transaction. func (c Client) Get(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) { - path := stripe.FormatURLPath("/issuing/transactions/%s", id) + path := stripe.FormatURLPath("/v1/issuing/transactions/%s", id) transaction := &stripe.IssuingTransaction{} err := c.B.Call(http.MethodGet, path, c.Key, params, transaction) return transaction, err @@ -36,7 +36,7 @@ func Update(id string, params *stripe.IssuingTransactionParams) (*stripe.Issuing // Update updates an issuing transaction. func (c Client) Update(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) { - path := stripe.FormatURLPath("/issuing/transactions/%s", id) + path := stripe.FormatURLPath("/v1/issuing/transactions/%s", id) transaction := &stripe.IssuingTransaction{} err := c.B.Call(http.MethodPost, path, c.Key, params, transaction) return transaction, err @@ -51,7 +51,7 @@ func List(params *stripe.IssuingTransactionListParams) *Iter { func (c Client) List(listParams *stripe.IssuingTransactionListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.IssuingTransactionList{} - err := c.B.CallRaw(http.MethodGet, "/issuing/transactions", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/issuing/transactions", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/loginlink/client.go b/loginlink/client.go index f0a960832c..fa602a1357 100644 --- a/loginlink/client.go +++ b/loginlink/client.go @@ -25,7 +25,7 @@ func (c Client) New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) { return nil, errors.New("Invalid login link params: Account must be set") } - path := stripe.FormatURLPath("/accounts/%s/login_links", stripe.StringValue(params.Account)) + path := stripe.FormatURLPath("/v1/accounts/%s/login_links", stripe.StringValue(params.Account)) loginLink := &stripe.LoginLink{} err := c.B.Call(http.MethodPost, path, c.Key, params, loginLink) return loginLink, err diff --git a/order/client.go b/order/client.go index 9c83eddf7f..12d8224173 100644 --- a/order/client.go +++ b/order/client.go @@ -21,7 +21,7 @@ func New(params *stripe.OrderParams) (*stripe.Order, error) { // New creates a new order. func (c Client) New(params *stripe.OrderParams) (*stripe.Order, error) { p := &stripe.Order{} - err := c.B.Call(http.MethodPost, "/orders", c.Key, params, p) + err := c.B.Call(http.MethodPost, "/v1/orders", c.Key, params, p) return p, err } @@ -32,7 +32,7 @@ func Update(id string, params *stripe.OrderUpdateParams) (*stripe.Order, error) // Update updates an order's properties. func (c Client) Update(id string, params *stripe.OrderUpdateParams) (*stripe.Order, error) { - path := stripe.FormatURLPath("/orders/%s", id) + path := stripe.FormatURLPath("/v1/orders/%s", id) o := &stripe.Order{} err := c.B.Call(http.MethodPost, path, c.Key, params, o) return o, err @@ -45,7 +45,7 @@ func Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) { // Pay pays an order. func (c Client) Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) { - path := stripe.FormatURLPath("/orders/%s/pay", id) + path := stripe.FormatURLPath("/v1/orders/%s/pay", id) o := &stripe.Order{} err := c.B.Call(http.MethodPost, path, c.Key, params, o) return o, err @@ -58,7 +58,7 @@ func Get(id string, params *stripe.OrderParams) (*stripe.Order, error) { // Get returns the details of an order. func (c Client) Get(id string, params *stripe.OrderParams) (*stripe.Order, error) { - path := stripe.FormatURLPath("/orders/%s", id) + path := stripe.FormatURLPath("/v1/orders/%s", id) order := &stripe.Order{} err := c.B.Call(http.MethodGet, path, c.Key, params, order) return order, err @@ -73,7 +73,7 @@ func List(params *stripe.OrderListParams) *Iter { func (c Client) List(listParams *stripe.OrderListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.OrderList{} - err := c.B.CallRaw(http.MethodGet, "/orders", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/orders", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -91,7 +91,7 @@ func Return(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, e // Return returns all or part of an order. func (c Client) Return(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) { - path := stripe.FormatURLPath("/orders/%s/returns", id) + path := stripe.FormatURLPath("/v1/orders/%s/returns", id) ret := &stripe.OrderReturn{} err := c.B.Call(http.MethodPost, path, c.Key, params, ret) return ret, err diff --git a/orderreturn/client.go b/orderreturn/client.go index 86414aa8f7..b6c13f852a 100644 --- a/orderreturn/client.go +++ b/orderreturn/client.go @@ -22,7 +22,7 @@ func List(params *stripe.OrderReturnListParams) *Iter { func (c Client) List(listParams *stripe.OrderReturnListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.OrderReturnList{} - err := c.B.CallRaw(http.MethodGet, "/order_returns", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/order_returns", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/paymentintent/client.go b/paymentintent/client.go index 7603845134..f428f2ef7f 100644 --- a/paymentintent/client.go +++ b/paymentintent/client.go @@ -24,7 +24,7 @@ func New(params *stripe.PaymentIntentParams) (*stripe.PaymentIntent, error) { // New creates a payment intent. func (c Client) New(params *stripe.PaymentIntentParams) (*stripe.PaymentIntent, error) { intent := &stripe.PaymentIntent{} - err := c.B.Call(http.MethodPost, "/payment_intents", c.Key, params, intent) + err := c.B.Call(http.MethodPost, "/v1/payment_intents", c.Key, params, intent) return intent, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.PaymentIntentParams) (*stripe.PaymentIntent, // Get retrieves a payment intent. func (c Client) Get(id string, params *stripe.PaymentIntentParams) (*stripe.PaymentIntent, error) { - path := stripe.FormatURLPath("/payment_intents/%s", id) + path := stripe.FormatURLPath("/v1/payment_intents/%s", id) intent := &stripe.PaymentIntent{} err := c.B.Call(http.MethodGet, path, c.Key, params, intent) return intent, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.PaymentIntentParams) (*stripe.PaymentInten // Update updates a payment intent. func (c Client) Update(id string, params *stripe.PaymentIntentParams) (*stripe.PaymentIntent, error) { - path := stripe.FormatURLPath("/payment_intents/%s", id) + path := stripe.FormatURLPath("/v1/payment_intents/%s", id) intent := &stripe.PaymentIntent{} err := c.B.Call(http.MethodPost, path, c.Key, params, intent) return intent, err @@ -61,7 +61,7 @@ func Cancel(id string, params *stripe.PaymentIntentCancelParams) (*stripe.Paymen // Cancel cancels a payment intent. func (c Client) Cancel(id string, params *stripe.PaymentIntentCancelParams) (*stripe.PaymentIntent, error) { - path := stripe.FormatURLPath("/payment_intents/%s/cancel", id) + path := stripe.FormatURLPath("/v1/payment_intents/%s/cancel", id) intent := &stripe.PaymentIntent{} err := c.B.Call(http.MethodPost, path, c.Key, params, intent) return intent, err @@ -74,7 +74,7 @@ func Capture(id string, params *stripe.PaymentIntentCaptureParams) (*stripe.Paym // Capture captures a payment intent. func (c Client) Capture(id string, params *stripe.PaymentIntentCaptureParams) (*stripe.PaymentIntent, error) { - path := stripe.FormatURLPath("/payment_intents/%s/capture", id) + path := stripe.FormatURLPath("/v1/payment_intents/%s/capture", id) intent := &stripe.PaymentIntent{} err := c.B.Call(http.MethodPost, path, c.Key, params, intent) return intent, err @@ -87,7 +87,7 @@ func Confirm(id string, params *stripe.PaymentIntentConfirmParams) (*stripe.Paym // Confirm confirms a payment intent. func (c Client) Confirm(id string, params *stripe.PaymentIntentConfirmParams) (*stripe.PaymentIntent, error) { - path := stripe.FormatURLPath("/payment_intents/%s/confirm", id) + path := stripe.FormatURLPath("/v1/payment_intents/%s/confirm", id) intent := &stripe.PaymentIntent{} err := c.B.Call(http.MethodPost, path, c.Key, params, intent) return intent, err @@ -102,7 +102,7 @@ func List(params *stripe.PaymentIntentListParams) *Iter { func (c Client) List(listParams *stripe.PaymentIntentListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.PaymentIntentList{} - err := c.B.CallRaw(http.MethodGet, "/payment_intents", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/payment_intents", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/paymentsource/client.go b/paymentsource/client.go index 4282ecb123..55d710045c 100644 --- a/paymentsource/client.go +++ b/paymentsource/client.go @@ -30,7 +30,7 @@ func (s Client) New(params *stripe.CustomerSourceParams) (*stripe.PaymentSource, return nil, errors.New("Invalid source params: customer needs to be set") } - path := stripe.FormatURLPath("/customers/%s/sources", stripe.StringValue(params.Customer)) + path := stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(params.Customer)) source := &stripe.PaymentSource{} err := s.B.Call(http.MethodPost, path, s.Key, params, source) return source, err @@ -51,7 +51,7 @@ func (s Client) Get(id string, params *stripe.CustomerSourceParams) (*stripe.Pay return nil, errors.New("Invalid source params: customer needs to be set") } - path := stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path := stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) source := &stripe.PaymentSource{} err := s.B.Call(http.MethodGet, path, s.Key, params, source) return source, err @@ -72,7 +72,7 @@ func (s Client) Update(id string, params *stripe.CustomerSourceParams) (*stripe. return nil, errors.New("Invalid source params: customer needs to be set") } - path := stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path := stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) source := &stripe.PaymentSource{} err := s.B.Call(http.MethodPost, path, s.Key, params, source) return source, err @@ -94,7 +94,7 @@ func (s Client) Del(id string, params *stripe.CustomerSourceParams) (*stripe.Pay } source := &stripe.PaymentSource{} - path := stripe.FormatURLPath("/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) + path := stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) err := s.B.Call(http.MethodDelete, path, s.Key, params, source) return source, err } @@ -114,7 +114,7 @@ func (s Client) List(listParams *stripe.SourceListParams) *Iter { } else if listParams.Customer == nil { outerErr = errors.New("Invalid source params: customer needs to be set") } else { - path = stripe.FormatURLPath("/customers/%s/sources", + path = stripe.FormatURLPath("/v1/customers/%s/sources", stripe.StringValue(listParams.Customer)) } @@ -149,10 +149,10 @@ func (s Client) Verify(id string, params *stripe.SourceVerifyParams) (*stripe.Pa var path string if params.Customer != nil { - path = stripe.FormatURLPath("/customers/%s/sources/%s/verify", + path = stripe.FormatURLPath("/v1/customers/%s/sources/%s/verify", stripe.StringValue(params.Customer), id) } else if len(params.Values) > 0 { - path = stripe.FormatURLPath("/sources/%s/verify", id) + path = stripe.FormatURLPath("/v1/sources/%s/verify", id) } else { return nil, errors.New("Only customer bank accounts or sources can be verified in this manner") } diff --git a/payout/client.go b/payout/client.go index c516a0d279..bebfa580eb 100644 --- a/payout/client.go +++ b/payout/client.go @@ -22,7 +22,7 @@ func New(params *stripe.PayoutParams) (*stripe.Payout, error) { // New creates a new payout. func (c Client) New(params *stripe.PayoutParams) (*stripe.Payout, error) { payout := &stripe.Payout{} - err := c.B.Call(http.MethodPost, "/payouts", c.Key, params, payout) + err := c.B.Call(http.MethodPost, "/v1/payouts", c.Key, params, payout) return payout, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { // Get returns the details of a payout. func (c Client) Get(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { - path := stripe.FormatURLPath("/payouts/%s", id) + path := stripe.FormatURLPath("/v1/payouts/%s", id) payout := &stripe.Payout{} err := c.B.Call(http.MethodGet, path, c.Key, params, payout) return payout, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { // Update updates a payout's properties. func (c Client) Update(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { - path := stripe.FormatURLPath("/payouts/%s", id) + path := stripe.FormatURLPath("/v1/payouts/%s", id) payout := &stripe.Payout{} err := c.B.Call(http.MethodPost, path, c.Key, params, payout) return payout, err @@ -59,7 +59,7 @@ func Cancel(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { // Cancel cancels a pending payout. func (c Client) Cancel(id string, params *stripe.PayoutParams) (*stripe.Payout, error) { - path := stripe.FormatURLPath("/payouts/%s/cancel", id) + path := stripe.FormatURLPath("/v1/payouts/%s/cancel", id) payout := &stripe.Payout{} err := c.B.Call(http.MethodPost, path, c.Key, params, payout) return payout, err @@ -74,7 +74,7 @@ func List(params *stripe.PayoutListParams) *Iter { func (c Client) List(listParams *stripe.PayoutListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.PayoutList{} - err := c.B.CallRaw(http.MethodGet, "/payouts", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/payouts", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/person/client.go b/person/client.go index 30ad3f0c38..49617286a5 100644 --- a/person/client.go +++ b/person/client.go @@ -22,7 +22,7 @@ func New(params *stripe.PersonParams) (*stripe.Person, error) { // New creates a new account person. func (c Client) New(params *stripe.PersonParams) (*stripe.Person, error) { - path := stripe.FormatURLPath("/accounts/%s/persons", stripe.StringValue(params.Account)) + path := stripe.FormatURLPath("/v1/accounts/%s/persons", stripe.StringValue(params.Account)) person := &stripe.Person{} err := c.B.Call(http.MethodPost, path, c.Key, params, person) return person, err @@ -39,7 +39,7 @@ func (c Client) Get(id string, params *stripe.PersonParams) (*stripe.Person, err return nil, fmt.Errorf("params cannot be nil, and params.Account must be set") } - path := stripe.FormatURLPath("/accounts/%s/persons/%s", + path := stripe.FormatURLPath("/v1/accounts/%s/persons/%s", stripe.StringValue(params.Account), id) person := &stripe.Person{} err := c.B.Call(http.MethodGet, path, c.Key, params, person) @@ -53,7 +53,7 @@ func Update(id string, params *stripe.PersonParams) (*stripe.Person, error) { // Update updates a account person's properties. func (c Client) Update(id string, params *stripe.PersonParams) (*stripe.Person, error) { - path := stripe.FormatURLPath("/accounts/%s/persons/%s", + path := stripe.FormatURLPath("/v1/accounts/%s/persons/%s", stripe.StringValue(params.Account), id) person := &stripe.Person{} err := c.B.Call(http.MethodPost, path, c.Key, params, person) @@ -67,7 +67,7 @@ func Del(id string, params *stripe.PersonParams) (*stripe.Person, error) { // Del removes a person. func (c Client) Del(id string, params *stripe.PersonParams) (*stripe.Person, error) { - path := stripe.FormatURLPath("/accounts/%s/persons/%s", + path := stripe.FormatURLPath("/v1/accounts/%s/persons/%s", stripe.StringValue(params.Account), id) person := &stripe.Person{} err := c.B.Call(http.MethodDelete, path, c.Key, params, person) @@ -81,7 +81,7 @@ func List(params *stripe.PersonListParams) *Iter { // List returns a list of account persons. func (c Client) List(listParams *stripe.PersonListParams) *Iter { - path := stripe.FormatURLPath("/accounts/%s/persons", stripe.StringValue(listParams.Account)) + path := stripe.FormatURLPath("/v1/accounts/%s/persons", stripe.StringValue(listParams.Account)) return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.PersonList{} diff --git a/plan/client.go b/plan/client.go index 5892f1a058..4df0c60104 100644 --- a/plan/client.go +++ b/plan/client.go @@ -22,7 +22,7 @@ func New(params *stripe.PlanParams) (*stripe.Plan, error) { // New creates a new plan. func (c Client) New(params *stripe.PlanParams) (*stripe.Plan, error) { plan := &stripe.Plan{} - err := c.B.Call(http.MethodPost, "/plans", c.Key, params, plan) + err := c.B.Call(http.MethodPost, "/v1/plans", c.Key, params, plan) return plan, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.PlanParams) (*stripe.Plan, error) { // Get returns the details of a plan. func (c Client) Get(id string, params *stripe.PlanParams) (*stripe.Plan, error) { - path := stripe.FormatURLPath("/plans/%s", id) + path := stripe.FormatURLPath("/v1/plans/%s", id) plan := &stripe.Plan{} err := c.B.Call(http.MethodGet, path, c.Key, params, plan) return plan, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.PlanParams) (*stripe.Plan, error) { // Update updates a plan's properties. func (c Client) Update(id string, params *stripe.PlanParams) (*stripe.Plan, error) { - path := stripe.FormatURLPath("/plans/%s", id) + path := stripe.FormatURLPath("/v1/plans/%s", id) plan := &stripe.Plan{} err := c.B.Call(http.MethodPost, path, c.Key, params, plan) return plan, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.PlanParams) (*stripe.Plan, error) { // Del removes a plan. func (c Client) Del(id string, params *stripe.PlanParams) (*stripe.Plan, error) { - path := stripe.FormatURLPath("/plans/%s", id) + path := stripe.FormatURLPath("/v1/plans/%s", id) plan := &stripe.Plan{} err := c.B.Call(http.MethodDelete, path, c.Key, params, plan) return plan, err @@ -74,7 +74,7 @@ func List(params *stripe.PlanListParams) *Iter { func (c Client) List(listParams *stripe.PlanListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.PlanList{} - err := c.B.CallRaw(http.MethodGet, "/plans", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/plans", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/product/client.go b/product/client.go index 06d3987272..9c0dfd5c67 100644 --- a/product/client.go +++ b/product/client.go @@ -21,7 +21,7 @@ func New(params *stripe.ProductParams) (*stripe.Product, error) { // New creates a new product. func (c Client) New(params *stripe.ProductParams) (*stripe.Product, error) { p := &stripe.Product{} - err := c.B.Call(http.MethodPost, "/products", c.Key, params, p) + err := c.B.Call(http.MethodPost, "/v1/products", c.Key, params, p) return p, err } @@ -32,7 +32,7 @@ func Update(id string, params *stripe.ProductParams) (*stripe.Product, error) { // Update updates a product's properties. func (c Client) Update(id string, params *stripe.ProductParams) (*stripe.Product, error) { - path := stripe.FormatURLPath("/products/%s", id) + path := stripe.FormatURLPath("/v1/products/%s", id) p := &stripe.Product{} err := c.B.Call(http.MethodPost, path, c.Key, params, p) return p, err @@ -45,7 +45,7 @@ func Get(id string, params *stripe.ProductParams) (*stripe.Product, error) { // Get returns the details of a product. func (c Client) Get(id string, params *stripe.ProductParams) (*stripe.Product, error) { - path := stripe.FormatURLPath("/products/%s", id) + path := stripe.FormatURLPath("/v1/products/%s", id) p := &stripe.Product{} err := c.B.Call(http.MethodGet, path, c.Key, params, p) return p, err @@ -60,7 +60,7 @@ func List(params *stripe.ProductListParams) *Iter { func (c Client) List(listParams *stripe.ProductListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ProductList{} - err := c.B.CallRaw(http.MethodGet, "/products", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/products", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -78,7 +78,7 @@ func Del(id string, params *stripe.ProductParams) (*stripe.Product, error) { // Del deletes a product. func (c Client) Del(id string, params *stripe.ProductParams) (*stripe.Product, error) { - path := stripe.FormatURLPath("/products/%s", id) + path := stripe.FormatURLPath("/v1/products/%s", id) p := &stripe.Product{} err := c.B.Call(http.MethodDelete, path, c.Key, params, p) diff --git a/radar/valuelist/client.go b/radar/valuelist/client.go index 1b08b5cf39..f2d3f40eb0 100644 --- a/radar/valuelist/client.go +++ b/radar/valuelist/client.go @@ -24,7 +24,7 @@ func New(params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) { // New creates a new value list. func (c Client) New(params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) { vl := &stripe.RadarValueList{} - err := c.B.Call(http.MethodPost, "/radar/value_lists", c.Key, params, vl) + err := c.B.Call(http.MethodPost, "/v1/radar/value_lists", c.Key, params, vl) return vl, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList // Get returns the details of a value list. func (c Client) Get(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) { - path := stripe.FormatURLPath("/radar/value_lists/%s", id) + path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id) vl := &stripe.RadarValueList{} err := c.B.Call(http.MethodGet, path, c.Key, params, vl) return vl, err @@ -48,7 +48,7 @@ func Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueL // Update updates a vl's properties. func (c Client) Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) { - path := stripe.FormatURLPath("/radar/value_lists/%s", id) + path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id) vl := &stripe.RadarValueList{} err := c.B.Call(http.MethodPost, path, c.Key, params, vl) return vl, err @@ -61,7 +61,7 @@ func Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList // Del removes a value list. func (c Client) Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) { - path := stripe.FormatURLPath("/radar/value_lists/%s", id) + path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id) vl := &stripe.RadarValueList{} err := c.B.Call(http.MethodDelete, path, c.Key, params, vl) return vl, err @@ -76,7 +76,7 @@ func List(params *stripe.RadarValueListListParams) *Iter { func (c Client) List(listParams *stripe.RadarValueListListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.RadarValueListList{} - err := c.B.CallRaw(http.MethodGet, "/radar/value_lists", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/radar/value_lists", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/radar/valuelistitem/client.go b/radar/valuelistitem/client.go index d8ed157d00..66408f6c7b 100644 --- a/radar/valuelistitem/client.go +++ b/radar/valuelistitem/client.go @@ -24,7 +24,7 @@ func New(params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, e // New creates a new value list item. func (c Client) New(params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { vli := &stripe.RadarValueListItem{} - err := c.B.Call(http.MethodPost, "/radar/value_list_items", c.Key, params, vli) + err := c.B.Call(http.MethodPost, "/v1/radar/value_list_items", c.Key, params, vli) return vli, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValue // Get returns the details of a value list item. func (c Client) Get(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { - path := stripe.FormatURLPath("/radar/value_list_items/%s", id) + path := stripe.FormatURLPath("/v1/radar/value_list_items/%s", id) vli := &stripe.RadarValueListItem{} err := c.B.Call(http.MethodGet, path, c.Key, params, vli) return vli, err @@ -48,7 +48,7 @@ func Del(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValue // Del removes a value list item. func (c Client) Del(id string, params *stripe.RadarValueListItemParams) (*stripe.RadarValueListItem, error) { - path := stripe.FormatURLPath("/radar/value_list_items/%s", id) + path := stripe.FormatURLPath("/v1/radar/value_list_items/%s", id) vli := &stripe.RadarValueListItem{} err := c.B.Call(http.MethodDelete, path, c.Key, params, vli) return vli, err @@ -63,7 +63,7 @@ func List(params *stripe.RadarValueListItemListParams) *Iter { func (c Client) List(listParams *stripe.RadarValueListItemListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.RadarValueListItemList{} - err := c.B.CallRaw(http.MethodGet, "/radar/value_list_items", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/radar/value_list_items", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/recipient/client.go b/recipient/client.go index 6d1b68dbcd..35ba3080fd 100644 --- a/recipient/client.go +++ b/recipient/client.go @@ -24,7 +24,7 @@ func Get(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) { // Get returns the details of a recipient. func (c Client) Get(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) { - path := stripe.FormatURLPath("/recipients/%s", id) + path := stripe.FormatURLPath("/v1/recipients/%s", id) recipient := &stripe.Recipient{} err := c.B.Call(http.MethodGet, path, c.Key, params, recipient) return recipient, err @@ -37,7 +37,7 @@ func Update(id string, params *stripe.RecipientParams) (*stripe.Recipient, error // Update updates a recipient's properties. func (c Client) Update(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) { - path := stripe.FormatURLPath("/recipients/%s", id) + path := stripe.FormatURLPath("/v1/recipients/%s", id) recipient := &stripe.Recipient{} err := c.B.Call(http.MethodPost, path, c.Key, params, recipient) return recipient, err @@ -50,7 +50,7 @@ func Del(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) { // Del removes a recipient. func (c Client) Del(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) { - path := stripe.FormatURLPath("/recipients/%s", id) + path := stripe.FormatURLPath("/v1/recipients/%s", id) recipient := &stripe.Recipient{} err := c.B.Call(http.MethodDelete, path, c.Key, params, recipient) return recipient, err @@ -65,7 +65,7 @@ func List(params *stripe.RecipientListParams) *Iter { func (c Client) List(listParams *stripe.RecipientListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.RecipientList{} - err := c.B.CallRaw(http.MethodGet, "/recipients", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/recipients", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/refund/client.go b/refund/client.go index 94f26919b6..1d0084422f 100644 --- a/refund/client.go +++ b/refund/client.go @@ -22,7 +22,7 @@ func New(params *stripe.RefundParams) (*stripe.Refund, error) { // New creates a refund. func (c Client) New(params *stripe.RefundParams) (*stripe.Refund, error) { refund := &stripe.Refund{} - err := c.B.Call(http.MethodPost, "/refunds", c.Key, params, refund) + err := c.B.Call(http.MethodPost, "/v1/refunds", c.Key, params, refund) return refund, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) { // Get returns the details of a refund. func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) { - path := stripe.FormatURLPath("/refunds/%s", id) + path := stripe.FormatURLPath("/v1/refunds/%s", id) refund := &stripe.Refund{} err := c.B.Call(http.MethodGet, path, c.Key, params, refund) return refund, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.RefundParams) (*stripe.Refund, error) { // Update updates a refund's properties. func (c Client) Update(id string, params *stripe.RefundParams) (*stripe.Refund, error) { - path := stripe.FormatURLPath("/refunds/%s", id) + path := stripe.FormatURLPath("/v1/refunds/%s", id) refund := &stripe.Refund{} err := c.B.Call(http.MethodPost, path, c.Key, params, refund) return refund, err @@ -61,7 +61,7 @@ func List(params *stripe.RefundListParams) *Iter { func (c Client) List(listParams *stripe.RefundListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.RefundList{} - err := c.B.CallRaw(http.MethodGet, "/refunds", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/refunds", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/reporting/reportrun/client.go b/reporting/reportrun/client.go index 7ae03e13dd..c4150823e5 100644 --- a/reporting/reportrun/client.go +++ b/reporting/reportrun/client.go @@ -24,7 +24,7 @@ func New(params *stripe.ReportRunParams) (*stripe.ReportRun, error) { // New creates a new report run. func (c Client) New(params *stripe.ReportRunParams) (*stripe.ReportRun, error) { reportrun := &stripe.ReportRun{} - err := c.B.Call(http.MethodPost, "/reporting/report_runs", c.Key, params, reportrun) + err := c.B.Call(http.MethodPost, "/v1/reporting/report_runs", c.Key, params, reportrun) return reportrun, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.ReportRunParams) (*stripe.ReportRun, error) { // Get returns the details of a report run. func (c Client) Get(id string, params *stripe.ReportRunParams) (*stripe.ReportRun, error) { - path := stripe.FormatURLPath("/reporting/report_runs/%s", id) + path := stripe.FormatURLPath("/v1/reporting/report_runs/%s", id) reportrun := &stripe.ReportRun{} err := c.B.Call(http.MethodGet, path, c.Key, params, reportrun) return reportrun, err @@ -50,7 +50,7 @@ func List(params *stripe.ReportRunListParams) *Iter { func (c Client) List(listParams *stripe.ReportRunListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ReportRunList{} - err := c.B.CallRaw(http.MethodGet, "/reporting/report_runs", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/reporting/report_runs", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/reporting/reporttype/client.go b/reporting/reporttype/client.go index 2cecb42fd8..05946a8d40 100644 --- a/reporting/reporttype/client.go +++ b/reporting/reporttype/client.go @@ -23,7 +23,7 @@ func Get(id string, params *stripe.ReportTypeParams) (*stripe.ReportType, error) // Get returns the details of a report type. func (c Client) Get(id string, params *stripe.ReportTypeParams) (*stripe.ReportType, error) { - path := stripe.FormatURLPath("/reporting/report_types/%s", id) + path := stripe.FormatURLPath("/v1/reporting/report_types/%s", id) reporttype := &stripe.ReportType{} err := c.B.Call(http.MethodGet, path, c.Key, params, reporttype) return reporttype, err @@ -38,7 +38,7 @@ func List(params *stripe.ReportTypeListParams) *Iter { func (c Client) List(listParams *stripe.ReportTypeListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ReportTypeList{} - err := c.B.CallRaw(http.MethodGet, "/reporting/report_types", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/reporting/report_types", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/reversal/client.go b/reversal/client.go index 1f5f4252bd..be5ab28bfd 100644 --- a/reversal/client.go +++ b/reversal/client.go @@ -22,7 +22,7 @@ func New(params *stripe.ReversalParams) (*stripe.Reversal, error) { // New creates a new transfer reversal. func (c Client) New(params *stripe.ReversalParams) (*stripe.Reversal, error) { - path := stripe.FormatURLPath("/transfers/%s/reversals", stripe.StringValue(params.Transfer)) + path := stripe.FormatURLPath("/v1/transfers/%s/reversals", stripe.StringValue(params.Transfer)) reversal := &stripe.Reversal{} err := c.B.Call(http.MethodPost, path, c.Key, params, reversal) return reversal, err @@ -39,7 +39,7 @@ func (c Client) Get(id string, params *stripe.ReversalParams) (*stripe.Reversal, return nil, fmt.Errorf("params cannot be nil, and params.Transfer must be set") } - path := stripe.FormatURLPath("/transfers/%s/reversals/%s", + path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s", stripe.StringValue(params.Transfer), id) reversal := &stripe.Reversal{} err := c.B.Call(http.MethodGet, path, c.Key, params, reversal) @@ -53,7 +53,7 @@ func Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) // Update updates a transfer reversal's properties. func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) { - path := stripe.FormatURLPath("/transfers/%s/reversals/%s", + path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s", stripe.StringValue(params.Transfer), id) reversal := &stripe.Reversal{} err := c.B.Call(http.MethodPost, path, c.Key, params, reversal) @@ -67,7 +67,7 @@ func List(params *stripe.ReversalListParams) *Iter { // List returns a list of transfer reversals. func (c Client) List(listParams *stripe.ReversalListParams) *Iter { - path := stripe.FormatURLPath("/transfers/%s/reversals", stripe.StringValue(listParams.Transfer)) + path := stripe.FormatURLPath("/v1/transfers/%s/reversals", stripe.StringValue(listParams.Transfer)) return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ReversalList{} diff --git a/review/client.go b/review/client.go index 166bf4e862..fb42feb2a5 100644 --- a/review/client.go +++ b/review/client.go @@ -21,7 +21,7 @@ func Approve(id string, params *stripe.ReviewApproveParams) (*stripe.Review, err // Approve approves a review. func (c Client) Approve(id string, params *stripe.ReviewApproveParams) (*stripe.Review, error) { - path := stripe.FormatURLPath("/reviews/%s/approve", id) + path := stripe.FormatURLPath("/v1/reviews/%s/approve", id) review := &stripe.Review{} err := c.B.Call(http.MethodPost, path, c.Key, params, review) return review, err @@ -34,7 +34,7 @@ func Get(id string, params *stripe.ReviewParams) (*stripe.Review, error) { // Get returns the details of a review. func (c Client) Get(id string, params *stripe.ReviewParams) (*stripe.Review, error) { - path := stripe.FormatURLPath("/reviews/%s", id) + path := stripe.FormatURLPath("/v1/reviews/%s", id) review := &stripe.Review{} err := c.B.Call(http.MethodGet, path, c.Key, params, review) return review, err @@ -49,7 +49,7 @@ func List(params *stripe.ReviewListParams) *Iter { func (c Client) List(listParams *stripe.ReviewListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.ReviewList{} - err := c.B.CallRaw(http.MethodGet, "/reviews", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/reviews", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/sigma/scheduledqueryrun/client.go b/sigma/scheduledqueryrun/client.go index b99aa38d8b..06e8eaac97 100644 --- a/sigma/scheduledqueryrun/client.go +++ b/sigma/scheduledqueryrun/client.go @@ -23,7 +23,7 @@ func Get(id string, params *stripe.SigmaScheduledQueryRunParams) (*stripe.SigmaS // Get returns the details of an scheduled query run. func (c Client) Get(id string, params *stripe.SigmaScheduledQueryRunParams) (*stripe.SigmaScheduledQueryRun, error) { - path := stripe.FormatURLPath("/sigma/scheduled_query_runs/%s", id) + path := stripe.FormatURLPath("/v1/sigma/scheduled_query_runs/%s", id) run := &stripe.SigmaScheduledQueryRun{} err := c.B.Call(http.MethodGet, path, c.Key, params, run) return run, err @@ -38,7 +38,7 @@ func List(params *stripe.SigmaScheduledQueryRunListParams) *Iter { func (c Client) List(listParams *stripe.SigmaScheduledQueryRunListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.SigmaScheduledQueryRunList{} - err := c.B.CallRaw(http.MethodGet, "/sigma/scheduled_query_runs", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/sigma/scheduled_query_runs", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/sku/client.go b/sku/client.go index b95412aadd..961914aa5a 100644 --- a/sku/client.go +++ b/sku/client.go @@ -21,7 +21,7 @@ func New(params *stripe.SKUParams) (*stripe.SKU, error) { // New creates a new SKU. func (c Client) New(params *stripe.SKUParams) (*stripe.SKU, error) { s := &stripe.SKU{} - err := c.B.Call(http.MethodPost, "/skus", c.Key, params, s) + err := c.B.Call(http.MethodPost, "/v1/skus", c.Key, params, s) return s, err } @@ -32,7 +32,7 @@ func Update(id string, params *stripe.SKUParams) (*stripe.SKU, error) { // Update updates a SKU's properties. func (c Client) Update(id string, params *stripe.SKUParams) (*stripe.SKU, error) { - path := stripe.FormatURLPath("/skus/%s", id) + path := stripe.FormatURLPath("/v1/skus/%s", id) s := &stripe.SKU{} err := c.B.Call(http.MethodPost, path, c.Key, params, s) return s, err @@ -45,7 +45,7 @@ func Get(id string, params *stripe.SKUParams) (*stripe.SKU, error) { // Get returns the details of a SKU. func (c Client) Get(id string, params *stripe.SKUParams) (*stripe.SKU, error) { - path := stripe.FormatURLPath("/skus/%s", id) + path := stripe.FormatURLPath("/v1/skus/%s", id) s := &stripe.SKU{} err := c.B.Call(http.MethodGet, path, c.Key, params, s) return s, err @@ -60,7 +60,7 @@ func List(params *stripe.SKUListParams) *Iter { func (c Client) List(listParams *stripe.SKUListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.SKUList{} - err := c.B.CallRaw(http.MethodGet, "/skus", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/skus", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { @@ -78,7 +78,7 @@ func Del(id string, params *stripe.SKUParams) (*stripe.SKU, error) { // Del removes a SKU. func (c Client) Del(id string, params *stripe.SKUParams) (*stripe.SKU, error) { - path := stripe.FormatURLPath("/skus/%s", id) + path := stripe.FormatURLPath("/v1/skus/%s", id) s := &stripe.SKU{} err := c.B.Call(http.MethodDelete, path, c.Key, params, s) diff --git a/source/client.go b/source/client.go index 0242cf3c32..ea043b773c 100644 --- a/source/client.go +++ b/source/client.go @@ -21,7 +21,7 @@ func New(params *stripe.SourceObjectParams) (*stripe.Source, error) { // New creates a new source. func (c Client) New(params *stripe.SourceObjectParams) (*stripe.Source, error) { p := &stripe.Source{} - err := c.B.Call(http.MethodPost, "/sources", c.Key, params, p) + err := c.B.Call(http.MethodPost, "/v1/sources", c.Key, params, p) return p, err } @@ -32,7 +32,7 @@ func Get(id string, params *stripe.SourceObjectParams) (*stripe.Source, error) { // Get returns the details of a source. func (c Client) Get(id string, params *stripe.SourceObjectParams) (*stripe.Source, error) { - path := stripe.FormatURLPath("/sources/%s", id) + path := stripe.FormatURLPath("/v1/sources/%s", id) source := &stripe.Source{} err := c.B.Call(http.MethodGet, path, c.Key, params, source) return source, err @@ -45,7 +45,7 @@ func Update(id string, params *stripe.SourceObjectParams) (*stripe.Source, error // Update updates a source's properties. func (c Client) Update(id string, params *stripe.SourceObjectParams) (*stripe.Source, error) { - path := stripe.FormatURLPath("/sources/%s", id) + path := stripe.FormatURLPath("/v1/sources/%s", id) source := &stripe.Source{} err := c.B.Call(http.MethodPost, path, c.Key, params, source) return source, err @@ -62,7 +62,7 @@ func (c Client) Detach(id string, params *stripe.SourceObjectDetachParams) (*str return nil, errors.New("Invalid source detach params: Customer needs to be set") } - path := stripe.FormatURLPath("/customers/%s/sources/%s", + path := stripe.FormatURLPath("/v1/customers/%s/sources/%s", stripe.StringValue(params.Customer), id) source := &stripe.Source{} err := c.B.Call(http.MethodDelete, path, c.Key, params, source) diff --git a/sourcetransaction/client.go b/sourcetransaction/client.go index c9c0e8d450..989cdce484 100644 --- a/sourcetransaction/client.go +++ b/sourcetransaction/client.go @@ -28,7 +28,7 @@ func (c Client) List(listParams *stripe.SourceTransactionListParams) *Iter { if listParams == nil || listParams.Source == nil { outerErr = errors.New("Invalid source transaction params: Source needs to be set") } else { - path = stripe.FormatURLPath("/sources/%s/source_transactions", + path = stripe.FormatURLPath("/v1/sources/%s/source_transactions", stripe.StringValue(listParams.Source)) } diff --git a/stripe.go b/stripe.go index c3f3f5c51d..cad20b868e 100644 --- a/stripe.go +++ b/stripe.go @@ -32,7 +32,7 @@ const ( APIBackend SupportedBackend = "api" // APIURL is the URL of the API service backend. - APIURL string = "https://api.stripe.com/v1" + APIURL string = "https://api.stripe.com" // UnknownPlatform is the string returned as the system name if we couldn't get // one from `uname`. @@ -42,7 +42,7 @@ const ( UploadsBackend SupportedBackend = "uploads" // UploadsURL is the URL of the uploads service backend. - UploadsURL string = "https://files.stripe.com/v1" + UploadsURL string = "https://files.stripe.com" ) // @@ -649,10 +649,7 @@ func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) B config.URL = apiURL } - // Add the /v1/ prefix because all client packages expect it. We should - // probably change this to just make it explicit wherever it's needed - // to fulfill the principle of least astonishment. - config.URL += "/v1" + config.URL = normalizeURL(config.URL) return newBackendImplementation(backendType, config) @@ -661,10 +658,7 @@ func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) B config.URL = uploadsURL } - // Add the /v1/ prefix because all client packages expect it. We should - // probably change this to just make it explicit wherever it's needed - // to fulfill the principle of least astonishment. - config.URL += "/v1" + config.URL = normalizeURL(config.URL) return newBackendImplementation(backendType, config) } @@ -894,3 +888,17 @@ func newBackendImplementation(backendType SupportedBackend, config *BackendConfi networkRetriesSleep: true, } } + +func normalizeURL(url string) string { + // All paths include a leading slash, so to keep logs pretty, trim a + // trailing slash on the URL. + url = strings.TrimSuffix(url, "/") + + // For a long time we had the `/v1` suffix as part of a configured URL + // rather than in the per-package URLs throughout the library. Continue + // to support this for the time being by stripping one that's been + // passed for better backwards compatibility. + url = strings.TrimSuffix(url, "/v1") + + return url +} diff --git a/stripe_test.go b/stripe_test.go index bbf7b6f655..26af9972fd 100644 --- a/stripe_test.go +++ b/stripe_test.go @@ -166,12 +166,51 @@ func TestDo_RetryOnTimeout(t *testing.T) { } func TestFormatURLPath(t *testing.T) { - assert.Equal(t, "/resources/1/subresources/2", - stripe.FormatURLPath("/resources/%s/subresources/%s", "1", "2")) + assert.Equal(t, "/v1/resources/1/subresources/2", + stripe.FormatURLPath("/v1/resources/%s/subresources/%s", "1", "2")) // Tests that each parameter is escaped for use in URLs - assert.Equal(t, "/resources/%25", - stripe.FormatURLPath("/resources/%s", "%")) + assert.Equal(t, "/v1/resources/%25", + stripe.FormatURLPath("/v1/resources/%s", "%")) +} + +func TestGetBackendWithConfig_TrimV1Suffix(t *testing.T) { + { + backend := stripe.GetBackendWithConfig( + stripe.APIBackend, + &stripe.BackendConfig{ + URL: "https://api.stripe.com/v1", + }, + ).(*stripe.BackendImplementation) + + // The `/v1` suffix has been stripped. + assert.Equal(t, "https://api.stripe.com", backend.URL) + } + + // Also support trimming a `/v1/` with an extra trailing slash which is + // probably an often seen mistake. + { + backend := stripe.GetBackendWithConfig( + stripe.APIBackend, + &stripe.BackendConfig{ + URL: "https://api.stripe.com/v1/", + }, + ).(*stripe.BackendImplementation) + + assert.Equal(t, "https://api.stripe.com", backend.URL) + } + + // No-op otherwise. + { + backend := stripe.GetBackendWithConfig( + stripe.APIBackend, + &stripe.BackendConfig{ + URL: "https://api.stripe.com", + }, + ).(*stripe.BackendImplementation) + + assert.Equal(t, "https://api.stripe.com", backend.URL) + } } func TestParseID(t *testing.T) { diff --git a/sub/client.go b/sub/client.go index 403dd1a8ab..a27dd74606 100644 --- a/sub/client.go +++ b/sub/client.go @@ -22,7 +22,7 @@ func New(params *stripe.SubscriptionParams) (*stripe.Subscription, error) { // New creates a new subscription. func (c Client) New(params *stripe.SubscriptionParams) (*stripe.Subscription, error) { sub := &stripe.Subscription{} - err := c.B.Call(http.MethodPost, "/subscriptions", c.Key, params, sub) + err := c.B.Call(http.MethodPost, "/v1/subscriptions", c.Key, params, sub) return sub, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.SubscriptionParams) (*stripe.Subscription, er // Get returns the details of a subscription. func (c Client) Get(id string, params *stripe.SubscriptionParams) (*stripe.Subscription, error) { - path := stripe.FormatURLPath("/subscriptions/%s", id) + path := stripe.FormatURLPath("/v1/subscriptions/%s", id) sub := &stripe.Subscription{} err := c.B.Call(http.MethodGet, path, c.Key, params, sub) return sub, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.SubscriptionParams) (*stripe.Subscription, // Update updates a subscription's properties. func (c Client) Update(id string, params *stripe.SubscriptionParams) (*stripe.Subscription, error) { - path := stripe.FormatURLPath("/subscriptions/%s", id) + path := stripe.FormatURLPath("/v1/subscriptions/%s", id) sub := &stripe.Subscription{} err := c.B.Call(http.MethodPost, path, c.Key, params, sub) @@ -60,7 +60,7 @@ func Cancel(id string, params *stripe.SubscriptionCancelParams) (*stripe.Subscri // Cancel removes a subscription. func (c Client) Cancel(id string, params *stripe.SubscriptionCancelParams) (*stripe.Subscription, error) { - path := stripe.FormatURLPath("/subscriptions/%s", id) + path := stripe.FormatURLPath("/v1/subscriptions/%s", id) sub := &stripe.Subscription{} err := c.B.Call(http.MethodDelete, path, c.Key, params, sub) return sub, err @@ -75,7 +75,7 @@ func List(params *stripe.SubscriptionListParams) *Iter { func (c Client) List(listParams *stripe.SubscriptionListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.SubscriptionList{} - err := c.B.CallRaw(http.MethodGet, "/subscriptions", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/subscriptions", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/subitem/client.go b/subitem/client.go index dab7bc977a..ac4f3c3cb6 100644 --- a/subitem/client.go +++ b/subitem/client.go @@ -22,7 +22,7 @@ func New(params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error // New creates a new subscription item. func (c Client) New(params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) { item := &stripe.SubscriptionItem{} - err := c.B.Call(http.MethodPost, "/subscription_items", c.Key, params, item) + err := c.B.Call(http.MethodPost, "/v1/subscription_items", c.Key, params, item) return item, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.SubscriptionItemParams) (*stripe.Subscription // Get returns the details of a subscription item. func (c Client) Get(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) { - path := stripe.FormatURLPath("/subscription_items/%s", id) + path := stripe.FormatURLPath("/v1/subscription_items/%s", id) item := &stripe.SubscriptionItem{} err := c.B.Call(http.MethodGet, path, c.Key, params, item) return item, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.SubscriptionItemParams) (*stripe.Subscript // Update updates a subscription item's properties. func (c Client) Update(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) { - path := stripe.FormatURLPath("/subscription_items/%s", id) + path := stripe.FormatURLPath("/v1/subscription_items/%s", id) subi := &stripe.SubscriptionItem{} err := c.B.Call(http.MethodPost, path, c.Key, params, subi) return subi, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.SubscriptionItemParams) (*stripe.Subscription // Del removes a subscription item. func (c Client) Del(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) { - path := stripe.FormatURLPath("/subscription_items/%s", id) + path := stripe.FormatURLPath("/v1/subscription_items/%s", id) item := &stripe.SubscriptionItem{} err := c.B.Call(http.MethodDelete, path, c.Key, params, item) @@ -75,7 +75,7 @@ func List(params *stripe.SubscriptionItemListParams) *Iter { func (c Client) List(listParams *stripe.SubscriptionItemListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.SubscriptionItemList{} - err := c.B.CallRaw(http.MethodGet, "/subscription_items", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/subscription_items", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/terminal/connectiontoken/client.go b/terminal/connectiontoken/client.go index 15c093fb8c..d4862212fc 100644 --- a/terminal/connectiontoken/client.go +++ b/terminal/connectiontoken/client.go @@ -21,7 +21,7 @@ func New(params *stripe.TerminalConnectionTokenParams) (*stripe.TerminalConnecti // New creates a new terminal connection token. func (c Client) New(params *stripe.TerminalConnectionTokenParams) (*stripe.TerminalConnectionToken, error) { connectiontoken := &stripe.TerminalConnectionToken{} - err := c.B.Call(http.MethodPost, "/terminal/connection_tokens", c.Key, params, connectiontoken) + err := c.B.Call(http.MethodPost, "/v1/terminal/connection_tokens", c.Key, params, connectiontoken) return connectiontoken, err } diff --git a/terminal/location/client.go b/terminal/location/client.go index ff978701d4..3d51c4d121 100644 --- a/terminal/location/client.go +++ b/terminal/location/client.go @@ -22,7 +22,7 @@ func New(params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error // New creates a new terminal location. func (c Client) New(params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) { location := &stripe.TerminalLocation{} - err := c.B.Call(http.MethodPost, "/terminal/locations", c.Key, params, location) + err := c.B.Call(http.MethodPost, "/v1/terminal/locations", c.Key, params, location) return location, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLoca // Get returns the details of a terminal location. func (c Client) Get(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) { - path := stripe.FormatURLPath("/terminal/locations/%s", id) + path := stripe.FormatURLPath("/v1/terminal/locations/%s", id) location := &stripe.TerminalLocation{} err := c.B.Call(http.MethodGet, path, c.Key, params, location) return location, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalL // Update updates a terminal location. func (c Client) Update(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) { - path := stripe.FormatURLPath("/terminal/locations/%s", id) + path := stripe.FormatURLPath("/v1/terminal/locations/%s", id) location := &stripe.TerminalLocation{} err := c.B.Call(http.MethodPost, path, c.Key, params, location) return location, err @@ -61,7 +61,7 @@ func List(params *stripe.TerminalLocationListParams) *Iter { func (c Client) List(listParams *stripe.TerminalLocationListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.TerminalLocationList{} - err := c.B.CallRaw(http.MethodGet, "/terminal/locations", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/terminal/locations", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/terminal/reader/client.go b/terminal/reader/client.go index a508743847..b8c17db38c 100644 --- a/terminal/reader/client.go +++ b/terminal/reader/client.go @@ -22,7 +22,7 @@ func New(params *stripe.TerminalReaderParams) (*stripe.TerminalReader, error) { // New creates a new terminal reader. func (c Client) New(params *stripe.TerminalReaderParams) (*stripe.TerminalReader, error) { reader := &stripe.TerminalReader{} - err := c.B.Call(http.MethodPost, "/terminal/readers", c.Key, params, reader) + err := c.B.Call(http.MethodPost, "/v1/terminal/readers", c.Key, params, reader) return reader, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.TerminalReaderGetParams) (*stripe.TerminalRea // Get returns the details of a terminal reader. func (c Client) Get(id string, params *stripe.TerminalReaderGetParams) (*stripe.TerminalReader, error) { - path := stripe.FormatURLPath("/terminal/readers/%s", id) + path := stripe.FormatURLPath("/v1/terminal/readers/%s", id) reader := &stripe.TerminalReader{} err := c.B.Call(http.MethodGet, path, c.Key, params, reader) return reader, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.TerminalReaderParams) (*stripe.TerminalRea // Update updates a terminal reader. func (c Client) Update(id string, params *stripe.TerminalReaderParams) (*stripe.TerminalReader, error) { - path := stripe.FormatURLPath("/terminal/readers/%s", id) + path := stripe.FormatURLPath("/v1/terminal/readers/%s", id) reader := &stripe.TerminalReader{} err := c.B.Call(http.MethodPost, path, c.Key, params, reader) return reader, err @@ -61,7 +61,7 @@ func List(params *stripe.TerminalReaderListParams) *Iter { func (c Client) List(listParams *stripe.TerminalReaderListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.TerminalReaderList{} - err := c.B.CallRaw(http.MethodGet, "/terminal/readers", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/terminal/readers", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/threedsecure/client.go b/threedsecure/client.go index 96b3b32086..16a5769696 100644 --- a/threedsecure/client.go +++ b/threedsecure/client.go @@ -24,7 +24,7 @@ func New(params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) { // New creates a new 3D Secure object. func (c Client) New(params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) { tds := &stripe.ThreeDSecure{} - err := c.B.Call(http.MethodPost, "/3d_secure", c.Key, params, tds) + err := c.B.Call(http.MethodPost, "/v1/3d_secure", c.Key, params, tds) return tds, err } @@ -35,7 +35,7 @@ func Get(id string, params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, er // Get returns the details of a 3D Secure object. func (c Client) Get(id string, params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) { - path := stripe.FormatURLPath("/3d_secure/%s", id) + path := stripe.FormatURLPath("/v1/3d_secure/%s", id) tds := &stripe.ThreeDSecure{} err := c.B.Call(http.MethodGet, path, c.Key, params, tds) diff --git a/token/client.go b/token/client.go index 3093f7276d..9382373b2c 100644 --- a/token/client.go +++ b/token/client.go @@ -21,7 +21,7 @@ func New(params *stripe.TokenParams) (*stripe.Token, error) { // New creates a new token. func (c Client) New(params *stripe.TokenParams) (*stripe.Token, error) { tok := &stripe.Token{} - err := c.B.Call(http.MethodPost, "/tokens", c.Key, params, tok) + err := c.B.Call(http.MethodPost, "/v1/tokens", c.Key, params, tok) return tok, err } @@ -32,7 +32,7 @@ func Get(id string, params *stripe.TokenParams) (*stripe.Token, error) { // Get returns the details of a token. func (c Client) Get(id string, params *stripe.TokenParams) (*stripe.Token, error) { - path := stripe.FormatURLPath("/tokens/%s", id) + path := stripe.FormatURLPath("/v1/tokens/%s", id) token := &stripe.Token{} err := c.B.Call(http.MethodGet, path, c.Key, params, token) diff --git a/topup/client.go b/topup/client.go index d631d7f4ee..f71a420ede 100644 --- a/topup/client.go +++ b/topup/client.go @@ -20,7 +20,7 @@ func Cancel(id string, params *stripe.TopupParams) (*stripe.Topup, error) { // Cancel cancels a topup. func (c Client) Cancel(id string, params *stripe.TopupParams) (*stripe.Topup, error) { - path := stripe.FormatURLPath("/topups/%s/cancel", id) + path := stripe.FormatURLPath("/v1/topups/%s/cancel", id) topup := &stripe.Topup{} err := c.B.Call(http.MethodPost, path, c.Key, params, topup) return topup, err @@ -34,7 +34,7 @@ func New(params *stripe.TopupParams) (*stripe.Topup, error) { // New creates a new topup. func (c Client) New(params *stripe.TopupParams) (*stripe.Topup, error) { topup := &stripe.Topup{} - err := c.B.Call(http.MethodPost, "/topups", c.Key, params, topup) + err := c.B.Call(http.MethodPost, "/v1/topups", c.Key, params, topup) return topup, err } @@ -45,7 +45,7 @@ func Get(id string, params *stripe.TopupParams) (*stripe.Topup, error) { // Get returns the details of a topup. func (c Client) Get(id string, params *stripe.TopupParams) (*stripe.Topup, error) { - path := stripe.FormatURLPath("/topups/%s", id) + path := stripe.FormatURLPath("/v1/topups/%s", id) topup := &stripe.Topup{} err := c.B.Call(http.MethodGet, path, c.Key, params, topup) return topup, err @@ -58,7 +58,7 @@ func Update(id string, params *stripe.TopupParams) (*stripe.Topup, error) { // Update updates a topup's properties. func (c Client) Update(id string, params *stripe.TopupParams) (*stripe.Topup, error) { - path := stripe.FormatURLPath("/topups/%s", id) + path := stripe.FormatURLPath("/v1/topups/%s", id) topup := &stripe.Topup{} err := c.B.Call(http.MethodPost, path, c.Key, params, topup) return topup, err @@ -73,7 +73,7 @@ func List(params *stripe.TopupListParams) *Iter { func (c Client) List(listParams *stripe.TopupListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.TopupList{} - err := c.B.CallRaw(http.MethodGet, "/topups", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/topups", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/transfer/client.go b/transfer/client.go index 2394eaf872..e9ae0303e0 100644 --- a/transfer/client.go +++ b/transfer/client.go @@ -22,7 +22,7 @@ func New(params *stripe.TransferParams) (*stripe.Transfer, error) { // New creates a new transfer. func (c Client) New(params *stripe.TransferParams) (*stripe.Transfer, error) { transfer := &stripe.Transfer{} - err := c.B.Call(http.MethodPost, "/transfers", c.Key, params, transfer) + err := c.B.Call(http.MethodPost, "/v1/transfers", c.Key, params, transfer) return transfer, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.TransferParams) (*stripe.Transfer, error) { // Get returns the details of a transfer. func (c Client) Get(id string, params *stripe.TransferParams) (*stripe.Transfer, error) { - path := stripe.FormatURLPath("/transfers/%s", id) + path := stripe.FormatURLPath("/v1/transfers/%s", id) transfer := &stripe.Transfer{} err := c.B.Call(http.MethodGet, path, c.Key, params, transfer) return transfer, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.TransferParams) (*stripe.Transfer, error) // Update updates a transfer's properties. func (c Client) Update(id string, params *stripe.TransferParams) (*stripe.Transfer, error) { - path := stripe.FormatURLPath("/transfers/%s", id) + path := stripe.FormatURLPath("/v1/transfers/%s", id) transfer := &stripe.Transfer{} err := c.B.Call(http.MethodPost, path, c.Key, params, transfer) return transfer, err @@ -61,7 +61,7 @@ func List(params *stripe.TransferListParams) *Iter { func (c Client) List(listParams *stripe.TransferListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.TransferList{} - err := c.B.CallRaw(http.MethodGet, "/transfers", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/transfers", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data { diff --git a/usagerecord/client.go b/usagerecord/client.go index 9fc435c7e3..f06208bad3 100644 --- a/usagerecord/client.go +++ b/usagerecord/client.go @@ -20,7 +20,7 @@ func New(params *stripe.UsageRecordParams) (*stripe.UsageRecord, error) { // New creates a new usage record. func (c Client) New(params *stripe.UsageRecordParams) (*stripe.UsageRecord, error) { - path := stripe.FormatURLPath("/subscription_items/%s/usage_records", stripe.StringValue(params.SubscriptionItem)) + path := stripe.FormatURLPath("/v1/subscription_items/%s/usage_records", stripe.StringValue(params.SubscriptionItem)) record := &stripe.UsageRecord{} err := c.B.Call(http.MethodPost, path, c.Key, params, record) return record, err diff --git a/usagerecordsummary/client.go b/usagerecordsummary/client.go index faa8593374..d10198645a 100644 --- a/usagerecordsummary/client.go +++ b/usagerecordsummary/client.go @@ -22,7 +22,7 @@ func List(params *stripe.UsageRecordSummaryListParams) *Iter { // List returns an iterator that iterates all usage record summaries. func (c Client) List(listParams *stripe.UsageRecordSummaryListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { - path := stripe.FormatURLPath("/subscription_items/%s/usage_record_summaries", stripe.StringValue(listParams.SubscriptionItem)) + path := stripe.FormatURLPath("/v1/subscription_items/%s/usage_record_summaries", stripe.StringValue(listParams.SubscriptionItem)) list := &stripe.ChargeList{} err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) diff --git a/webhookendpoint/client.go b/webhookendpoint/client.go index fc00c03642..a808dc9478 100644 --- a/webhookendpoint/client.go +++ b/webhookendpoint/client.go @@ -22,7 +22,7 @@ func New(params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoint, error) // New creates a new webhook_endpoint. func (c Client) New(params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoint, error) { endpoint := &stripe.WebhookEndpoint{} - err := c.B.Call(http.MethodPost, "/webhook_endpoints", c.Key, params, endpoint) + err := c.B.Call(http.MethodPost, "/v1/webhook_endpoints", c.Key, params, endpoint) return endpoint, err } @@ -33,7 +33,7 @@ func Get(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoi // Get returns the details of a webhook endpoint. func (c Client) Get(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoint, error) { - path := stripe.FormatURLPath("/webhook_endpoints/%s", id) + path := stripe.FormatURLPath("/v1/webhook_endpoints/%s", id) endpoint := &stripe.WebhookEndpoint{} err := c.B.Call(http.MethodGet, path, c.Key, params, endpoint) return endpoint, err @@ -46,7 +46,7 @@ func Update(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEnd // Update updates a webhook endpoint's properties. func (c Client) Update(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoint, error) { - path := stripe.FormatURLPath("/webhook_endpoints/%s", id) + path := stripe.FormatURLPath("/v1/webhook_endpoints/%s", id) endpoint := &stripe.WebhookEndpoint{} err := c.B.Call(http.MethodPost, path, c.Key, params, endpoint) return endpoint, err @@ -59,7 +59,7 @@ func Del(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoi // Del removes a webhook endpoint. func (c Client) Del(id string, params *stripe.WebhookEndpointParams) (*stripe.WebhookEndpoint, error) { - path := stripe.FormatURLPath("/webhook_endpoints/%s", id) + path := stripe.FormatURLPath("/v1/webhook_endpoints/%s", id) endpoint := &stripe.WebhookEndpoint{} err := c.B.Call(http.MethodDelete, path, c.Key, params, endpoint) return endpoint, err @@ -74,7 +74,7 @@ func List(params *stripe.WebhookEndpointListParams) *Iter { func (c Client) List(listParams *stripe.WebhookEndpointListParams) *Iter { return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) { list := &stripe.WebhookEndpointList{} - err := c.B.CallRaw(http.MethodGet, "/webhook_endpoints", c.Key, b, p, list) + err := c.B.CallRaw(http.MethodGet, "/v1/webhook_endpoints", c.Key, b, p, list) ret := make([]interface{}, len(list.Data)) for i, v := range list.Data {