Skip to content

Commit

Permalink
Add support for the Payout Reverse API (#951)
Browse files Browse the repository at this point in the history
* Codegen for openapi 4bd4c01

* Add test
  • Loading branch information
remi-stripe committed Oct 14, 2020
1 parent f3b83f1 commit db24334
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -15,7 +15,7 @@ notifications:
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.99.0
- STRIPE_MOCK_VERSION=0.101.0

cache:
directories:
Expand Down
10 changes: 10 additions & 0 deletions lib/stripe/resources/payout.rb
Expand Up @@ -10,6 +10,7 @@ class Payout < APIResource
OBJECT_NAME = "payout"

custom_method :cancel, http_verb: :post
custom_method :reverse, http_verb: :post

def cancel(params = {}, opts = {})
request_stripe_object(
Expand All @@ -19,5 +20,14 @@ def cancel(params = {}, opts = {})
opts: opts
)
end

def reverse(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/reverse",
params: params,
opts: opts
)
end
end
end
2 changes: 1 addition & 1 deletion test/stripe/customer_test.rb
Expand Up @@ -57,7 +57,7 @@ class CustomerTest < Test::Unit::TestCase
should "delete a discount" do
customer = Stripe::Customer.retrieve("cus_123")
customer = customer.delete_discount
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount"
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/discount"
assert customer.is_a?(Stripe::Customer)
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/stripe/payout_test.rb
Expand Up @@ -53,5 +53,20 @@ class PayoutTest < Test::Unit::TestCase
assert payout.is_a?(Stripe::Payout)
end
end

context "#reverse" do
should "reverse a payout" do
payout = Stripe::Payout.retrieve("tr_123")
payout = payout.reverse
assert payout.is_a?(Stripe::Payout)
end
end

context ".reverse" do
should "reverse a payout" do
payout = Stripe::Payout.reverse("pm_123")
assert payout.is_a?(Stripe::Payout)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -16,7 +16,7 @@
require ::File.expand_path("stripe_mock", __dir__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.99.0"
MOCK_MINIMUM_VERSION = "0.101.0"
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down

0 comments on commit db24334

Please sign in to comment.