Skip to content

Commit

Permalink
API Updates and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhch committed Apr 25, 2022
1 parent e3c8eff commit 86a363d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions async_stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ async def list_payment_methods_patch(self, idempotency_key=None, **params):
stripe_object._retrieve_params = params
return stripe_object

async def create_funding_instructions_patch(self, idempotency_key=None, **params):
url = self.instance_url() + "/funding_instructions"
headers = util.populate_headers(idempotency_key)
resp = await self.request("post", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
return stripe_object


stripe.Customer.delete_discount = delete_discount_patch
stripe.Customer.list_payment_methods = list_payment_methods_patch

Expand All @@ -36,5 +44,6 @@ async def list_payment_methods_patch(self, idempotency_key=None, **params):
custom_resources = [
{"name": "delete_discount", "http_verb": "delete", "http_path": "discount"},
{"name": "list_payment_methods", "http_verb": "get", "http_path": "payment_methods"},
{"name": "create_funding_instructions", "http_verb": "post", "http_path": "funding_instructions"},
]
patch_custom_methods(stripe.Customer, custom_resources)
40 changes: 40 additions & 0 deletions tests/api_resources/terminal/test_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import absolute_import, division, print_function

import stripe

import pytest


pytestmark = pytest.mark.asyncio


class TestConfiguration(object):
async def test_terminal_configuration_list(self, request_mock):
await stripe.terminal.Configuration.list()
request_mock.assert_requested("get", "/v1/terminal/configurations")

async def test_terminal_configuration_retrieve(self, request_mock):
await stripe.terminal.Configuration.retrieve("uc_123")
request_mock.assert_requested(
"get", "/v1/terminal/configurations/uc_123"
)

async def test_terminal_configuration_create(self, request_mock):
await stripe.terminal.Configuration.create()
request_mock.assert_requested("post", "/v1/terminal/configurations")

async def test_terminal_configuration_update(self, request_mock):
await stripe.terminal.Configuration.modify(
"uc_123",
tipping={"usd": {"fixed_amounts": [10]}},
)
request_mock.assert_requested(
"post", "/v1/terminal/configurations/uc_123"
)

async def test_terminal_configuration_delete(self, request_mock):
await stripe.terminal.Configuration.delete("uc_123")
request_mock.assert_requested(
"delete",
"/v1/terminal/configurations/uc_123",
)
17 changes: 17 additions & 0 deletions tests/api_resources/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,20 @@ async def test_is_listable_on_object(self, request_mock):
"get", "/v1/customers/%s/payment_methods" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.ListObject)


class TestCustomerFundingInstructions(object):
async def test_customer_create_funding_instructions(self, request_mock):
await stripe.Customer.create_funding_instructions(
"cus_123",
bank_transfer={
"requested_address_types": ["zengin"],
"type": "jp_bank_transfer",
},
currency="usd",
funding_type="bank_transfer",
)
request_mock.assert_requested(
"post",
"/v1/customers/cus_123/funding_instructions",
)

0 comments on commit 86a363d

Please sign in to comment.