Skip to content

Commit

Permalink
Merge pull request #671 from stripe/ob-topup-cancel
Browse files Browse the repository at this point in the history
Add cancel support for topups
  • Loading branch information
ob-stripe committed Aug 3, 2018
2 parents 7e914bc + d698bd6 commit a24b69c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/stripe/topup.rb
Expand Up @@ -7,5 +7,10 @@ class Topup < APIResource
include Stripe::APIOperations::Save

OBJECT_NAME = "topup".freeze

def cancel
resp, api_key = request(:post, resource_url + "/cancel")
initialize_from(resp.data, api_key)
end
end
end
9 changes: 9 additions & 0 deletions test/stripe/topup_test.rb
Expand Up @@ -41,5 +41,14 @@ class TopupTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/topups/tu_123"
assert topup.is_a?(Stripe::Topup)
end

context "#cancel" do
should "cancel the topup" do
topup = Stripe::Topup.retrieve("tu_123")
topup = topup.cancel
assert_requested :post, "#{Stripe.api_base}/v1/topups/#{topup.id}/cancel"
assert topup.is_a?(Stripe::Topup)
end
end
end
end

0 comments on commit a24b69c

Please sign in to comment.