Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancel support for topups #671

Merged
merged 1 commit into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/stripe/topup.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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