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 Checkout Session resource #510

Merged
merged 1 commit into from
Dec 21, 2018
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 @@ -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
Expand Down
1 change: 1 addition & 0 deletions stripe/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions stripe/api_resources/checkout_session.py
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 2 additions & 0 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion tests/api_resources/test_bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
33 changes: 33 additions & 0 deletions tests/api_resources/test_checkout_session.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down