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 support for the Payout Reverse API #951

Merged
merged 2 commits into from
Oct 14, 2020
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change this test because stripe-ruby mutates the customer in place and changes its id as stripe-mock doesn't know this is an endpoint with the customer id in it

assert customer.is_a?(Stripe::Customer)
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/stripe/payout_test.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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