Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support for the Issuing Dispute Submit API #676

Merged
merged 2 commits into from
Sep 2, 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.95.0
- STRIPE_MOCK_VERSION=0.98.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
9 changes: 9 additions & 0 deletions stripe/api_resources/issuing/dispute.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from __future__ import absolute_import, division, print_function

from stripe import util
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import custom_method


@custom_method("submit", http_verb="post")
class Dispute(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
):
OBJECT_NAME = "issuing.dispute"

def submit(self, idempotency_key=None, **params):
url = self.instance_url() + "/submit"
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
9 changes: 8 additions & 1 deletion tests/api_resources/issuing/test_dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TestDispute(object):
def test_is_creatable(self, request_mock):
resource = stripe.issuing.Dispute.create()
resource = stripe.issuing.Dispute.create(transaction="ipi_123")
request_mock.assert_requested("post", "/v1/issuing/disputes")
assert isinstance(resource, stripe.issuing.Dispute)

Expand All @@ -31,3 +31,10 @@ def test_is_retrievable(self, request_mock):
"get", "/v1/issuing/disputes/%s" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.issuing.Dispute)

def test_is_submittable(self, request_mock):
resource = stripe.issuing.Dispute.submit(TEST_RESOURCE_ID)
request_mock.assert_requested(
"post", "/v1/issuing/disputes/%s/submit" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.issuing.Dispute)
13 changes: 3 additions & 10 deletions tests/api_resources/test_list_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,10 @@ def test_create(self, request_mock, list_object):
def test_create_maintains_list_properties(self, request_mock, list_object):
# Testing with real requests because our mock makes it impossible to
# test otherwise
customer = stripe.Customer.retrieve(
"cus_123", api_key="sk_test_custom"
)

res = customer.sources.create(source="tok_123")

charge = stripe.Charge.retrieve("ch_123", api_key="sk_test_custom")
res = charge.refunds.create(amount=123)
request_mock.assert_requested(
"post",
"/v1/customers/cus_123/sources",
{"source": "tok_123"},
None,
"post", "/v1/charges/ch_123/refunds", {"amount": 123}, None
)
assert res.api_key == "sk_test_custom"

Expand Down
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.95.0"
MOCK_MINIMUM_VERSION = "0.98.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