Skip to content

Commit

Permalink
Add support for cancel on Topup
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 2, 2018
1 parent 9ef95c0 commit bc08ece
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions topup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions topup/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bc08ece

Please sign in to comment.