Skip to content

Commit

Permalink
Add support for the Checkout Session resource
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Dec 19, 2018
1 parent e3417e9 commit 4a9d2cd
Show file tree
Hide file tree
Showing 7 changed files with 54,978 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.39.0
- STRIPE_MOCK_PORT=12111

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand All @@ -33,7 +34,11 @@ before_install:
tar -zxf "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -C "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/"
fi
- |
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock \
-http-port ${STRIPE_MOCK_PORT} \
-spec tests/openapi/spec3.json \
-fixtures tests/openapi/fixtures3.json \
> /dev/null &
STRIPE_MOCK_PID=$!
install:
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
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)
Loading

0 comments on commit 4a9d2cd

Please sign in to comment.