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 #684

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 @@ -26,7 +26,7 @@ cache:
env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.99.0
- STRIPE_MOCK_VERSION=0.101.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
7 changes: 7 additions & 0 deletions stripe/api_resources/payout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


@custom_method("cancel", http_verb="post")
@custom_method("reverse", http_verb="post")
class Payout(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
):
Expand All @@ -18,3 +19,9 @@ def cancel(self, idempotency_key=None, **params):
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def reverse(self, idempotency_key=None, **params):
url = self.instance_url() + "/reverse"
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
15 changes: 15 additions & 0 deletions tests/api_resources/test_payout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,18 @@ def test_can_cancel_classmethod(self, request_mock):
"post", "/v1/payouts/%s/cancel" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)

def test_can_reverse(self, request_mock):
payout = stripe.Payout.retrieve(TEST_RESOURCE_ID)
resource = payout.reverse()
request_mock.assert_requested(
"post", "/v1/payouts/%s/reverse" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)

def test_can_reverse_classmethod(self, request_mock):
resource = stripe.Payout.reverse(TEST_RESOURCE_ID)
request_mock.assert_requested(
"post", "/v1/payouts/%s/reverse" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# When changing this number, don't forget to change it in `.travis.yml` too.
MOCK_MINIMUM_VERSION = "0.99.0"
MOCK_MINIMUM_VERSION = "0.101.0"

# Starts stripe-mock if an OpenAPI spec override is found in `openapi/`, and
# otherwise fall back to `STRIPE_MOCK_PORT` or 12111.
Expand Down