diff --git a/.travis.yml b/.travis.yml index fae982ad5e..3ab667c2c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ cache: env: global: # If changing this number, please also change it in `testing/testing.go`. - - STRIPE_MOCK_VERSION=0.24.0 + - STRIPE_MOCK_VERSION=0.25.0 go: - "1.7" diff --git a/testing/testing.go b/testing/testing.go index 5a7e813a86..5b7905fe2d 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -25,7 +25,7 @@ const ( // added in a more recent version of stripe-mock, we can show people a // better error message instead of the test suite crashing with a bunch of // confusing 404 errors or the like. - MockMinimumVersion = "0.24.0" + MockMinimumVersion = "0.25.0" // TestMerchantID is a token that can be used to represent a merchant ID in // simple tests. diff --git a/topup/client.go b/topup/client.go index 6b955a46a8..d631d7f4ee 100644 --- a/topup/client.go +++ b/topup/client.go @@ -13,6 +13,19 @@ type Client struct { Key string } +// Cancel cancels a topup. +func Cancel(id string, params *stripe.TopupParams) (*stripe.Topup, error) { + return getC().Cancel(id, params) +} + +// Cancel cancels a topup. +func (c Client) Cancel(id string, params *stripe.TopupParams) (*stripe.Topup, error) { + path := stripe.FormatURLPath("/topups/%s/cancel", id) + topup := &stripe.Topup{} + err := c.B.Call(http.MethodPost, path, c.Key, params, topup) + return topup, err +} + // New creates a new topup. func New(params *stripe.TopupParams) (*stripe.Topup, error) { return getC().New(params) diff --git a/topup/client_test.go b/topup/client_test.go index 896ef27624..7ed4949dd1 100644 --- a/topup/client_test.go +++ b/topup/client_test.go @@ -8,6 +8,12 @@ import ( _ "github.com/stripe/stripe-go/testing" ) +func TestTopupCancel(t *testing.T) { + topup, err := Cancel("tu_123", &stripe.TopupParams{}) + assert.Nil(t, err) + assert.NotNil(t, topup) +} + func TestTopupGet(t *testing.T) { topup, err := Get("tu_123", nil) assert.Nil(t, err)