diff --git a/.travis.yml b/.travis.yml index f5854e9cb..b8815148c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ cache: env: global: # If changing this number, please also change it in `tests/conftest.py`. - - STRIPE_MOCK_VERSION=0.39.0 + - STRIPE_MOCK_VERSION=0.40.0 before_install: # Unpack and start stripe-mock so that the test suite can talk to it diff --git a/stripe/api_resources/__init__.py b/stripe/api_resources/__init__.py index 78193290f..7866dfce1 100644 --- a/stripe/api_resources/__init__.py +++ b/stripe/api_resources/__init__.py @@ -17,6 +17,7 @@ from stripe.api_resources.bitcoin_transaction import BitcoinTransaction from stripe.api_resources.card import Card from stripe.api_resources.charge import Charge +from stripe.api_resources.checkout_session import CheckoutSession from stripe.api_resources.country_spec import CountrySpec from stripe.api_resources.coupon import Coupon from stripe.api_resources.customer import Customer diff --git a/stripe/api_resources/checkout_session.py b/stripe/api_resources/checkout_session.py new file mode 100644 index 000000000..bde2f3490 --- /dev/null +++ b/stripe/api_resources/checkout_session.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from stripe.api_resources.abstract import CreateableAPIResource + + +class CheckoutSession(CreateableAPIResource): + OBJECT_NAME = 'checkout_session' diff --git a/stripe/util.py b/stripe/util.py index c7f918d2e..0acba9f81 100644 --- a/stripe/util.py +++ b/stripe/util.py @@ -156,6 +156,8 @@ def load_object_classes(): api_resources.BitcoinTransaction, api_resources.Card.OBJECT_NAME: api_resources.Card, api_resources.Charge.OBJECT_NAME: api_resources.Charge, + api_resources.CheckoutSession.OBJECT_NAME: + api_resources.CheckoutSession, api_resources.CountrySpec.OBJECT_NAME: api_resources.CountrySpec, api_resources.Coupon.OBJECT_NAME: api_resources.Coupon, api_resources.Customer.OBJECT_NAME: api_resources.Customer, diff --git a/tests/api_resources/test_bank_account.py b/tests/api_resources/test_bank_account.py index 430c2d0b1..60a75a68a 100644 --- a/tests/api_resources/test_bank_account.py +++ b/tests/api_resources/test_bank_account.py @@ -58,7 +58,6 @@ def test_is_deletable(self, request_mock): 'delete', '/v1/customers/cus_123/sources/%s' % TEST_RESOURCE_ID ) - assert resource.deleted is True def test_is_verifiable(self, request_mock): resource = self.construct_resource(customer='cus_123') diff --git a/tests/api_resources/test_checkout_session.py b/tests/api_resources/test_checkout_session.py new file mode 100644 index 000000000..309ad8708 --- /dev/null +++ b/tests/api_resources/test_checkout_session.py @@ -0,0 +1,33 @@ +from __future__ import absolute_import, division, print_function + +import stripe + + +class TestCheckoutSession(object): + def test_is_creatable(self, request_mock): + resource = stripe.CheckoutSession.create( + allowed_source_types=['card'], + cancel_url='https://stripe.com/cancel', + client_reference_id='1234', + line_items=[ + { + 'amount': 123, + 'currency': 'usd', + 'description': 'item 1', + 'images': [ + 'https://stripe.com/img1', + ], + 'name': 'name', + 'quantity': 2, + }, + ], + payment_intent_data={ + 'receipt_email': 'test@stripe.com', + }, + success_url='https://stripe.com/success' + ) + request_mock.assert_requested( + 'post', + '/v1/checkout_sessions' + ) + assert isinstance(resource, stripe.CheckoutSession) diff --git a/tests/conftest.py b/tests/conftest.py index 1553b63f9..97c7c55d6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,7 @@ from tests.request_mock import RequestMock -MOCK_MINIMUM_VERSION = '0.39.0' +MOCK_MINIMUM_VERSION = '0.40.0' MOCK_PORT = os.environ.get('STRIPE_MOCK_PORT', 12111)