Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'
def __init__(self, type, data):
# All exceptions must be raised before this point.
super().__init__()
self.type = type
self.data = {'object': data._export()}
self.api_version = '2017-08-15'
@classmethod
def _api_create(cls, **data):
assert type(period_start) is int and period_start > 1500000000
assert type(period_end) is int and period_end > 1500000000
else:
period_start = period_end = int(time.time())
assert type(proration) is bool
if description is not None:
assert type(description) is str
else:
description = 'Invoice item'
if tax_rates is not None:
assert type(tax_rates) is list
assert all(type(tr) is str for tr in tax_rates)
except AssertionError:
raise UserError(400, 'Bad request')
Customer._api_retrieve(customer) # to return 404 if not existant
if invoice is not None:
Invoice._api_retrieve(invoice) # to return 404 if not existant
if plan is not None:
plan = Plan._api_retrieve(plan) # to return 404 if not existant
if tax_rates is not None:
# To return 404 if not existant:
tax_rates = [TaxRate._api_retrieve(tr) for tr in tax_rates]
# All exceptions must be raised before this point.
super().__init__()
self.invoice = invoice
self.subscription = subscription
self.plan = plan
self.quantity = 1
self.amount = amount
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'
def __init__(self, type, data):
# All exceptions must be raised before this point.
super().__init__()
self.type = type
self.data = {'object': data._export()}
self.api_version = '2017-08-15'
if obj.customer != id:
raise UserError(404, 'Customer ' + id + ' does not have a '
'subscription with ID ' + subscription_id)
return Subscription._api_update(subscription_id, **data)
extra_apis.extend((
('POST', '/v1/customers/{id}/sources', Customer._api_add_source),
# Retrieve single source by id:
('GET', '/v1/customers/{id}/sources/{source_id}',
Customer._api_retrieve_source),
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
('GET', '/v1/customers/{id}/sources/{source_id}',
Customer._api_retrieve_source),
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'
def __init__(self, type, data):
# All exceptions must be raised before this point.
super().__init__()
self.type = type
self.data = {'object': data._export()}
@classmethod
def _api_update_subscription(cls, id, subscription_id, **data):
obj = Subscription._api_retrieve(subscription_id)
if obj.customer != id:
raise UserError(404, 'Customer ' + id + ' does not have a '
'subscription with ID ' + subscription_id)
return Subscription._api_update(subscription_id, **data)
extra_apis.extend((
('POST', '/v1/customers/{id}/sources', Customer._api_add_source),
# Retrieve single source by id:
('GET', '/v1/customers/{id}/sources/{source_id}',
Customer._api_retrieve_source),
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'
def __init__(self, type, data):
# All exceptions must be raised before this point.
super().__init__()
self.type = type
self.data = {'object': data._export()}
self.api_version = '2017-08-15'
@classmethod
('POST', '/v1/customers/{id}/sources', Customer._api_add_source),
# Retrieve single source by id:
('GET', '/v1/customers/{id}/sources/{source_id}',
Customer._api_retrieve_source),
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'
def __init__(self, type, data):
# All exceptions must be raised before this point.
super().__init__()
return Subscription._api_update(subscription_id, **data)
extra_apis.extend((
('POST', '/v1/customers/{id}/sources', Customer._api_add_source),
# Retrieve single source by id:
('GET', '/v1/customers/{id}/sources/{source_id}',
Customer._api_retrieve_source),
# Update single source by id:
('POST', '/v1/customers/{id}/sources/{source_id}',
Customer._api_update_source),
# Delete single source by id:
('DELETE', '/v1/customers/{id}/sources/{source_id}',
Customer._api_remove_source),
('GET', '/v1/customers/{id}/subscriptions',
Customer._api_list_subscriptions),
('POST', '/v1/customers/{id}/subscriptions',
Customer._api_add_subscription),
('GET', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_retrieve_subscription),
('POST', '/v1/customers/{id}/subscriptions/{subscription_id}',
Customer._api_update_subscription),
# This is the old API route:
('POST', '/v1/customers/{id}/cards', Customer._api_add_source),
('POST', '/v1/customers/{id}/tax_ids', Customer._api_add_tax_id),
('GET', '/v1/customers/{id}/tax_ids', Customer._api_list_tax_ids)))
class Event(StripeObject):
object = 'event'
_id_prefix = 'evt_'