billing: Use Subscription.save() instead of calling save on instances.

Continuation of 03d77bc.
This commit is contained in:
Rishi Gupta 2018-11-17 18:52:45 -08:00
parent 8470affb5b
commit 61e0c2693d
2 changed files with 6 additions and 2 deletions

View File

@ -311,7 +311,7 @@ def do_set_subscription_quantity(
stripe_subscription = extract_current_subscription(stripe_customer) stripe_subscription = extract_current_subscription(stripe_customer)
stripe_subscription.quantity = quantity stripe_subscription.quantity = quantity
stripe_subscription.proration_date = timestamp stripe_subscription.proration_date = timestamp
stripe_subscription.save(idempotency_key=idempotency_key) stripe.Subscription.save(stripe_subscription, idempotency_key=idempotency_key)
def do_adjust_subscription_quantity( def do_adjust_subscription_quantity(
customer: Customer, timestamp: int, idempotency_key: str, delta: int) -> None: customer: Customer, timestamp: int, idempotency_key: str, delta: int) -> None:
@ -319,7 +319,7 @@ def do_adjust_subscription_quantity(
stripe_subscription = extract_current_subscription(stripe_customer) stripe_subscription = extract_current_subscription(stripe_customer)
stripe_subscription.quantity = stripe_subscription.quantity + delta stripe_subscription.quantity = stripe_subscription.quantity + delta
stripe_subscription.proration_date = timestamp stripe_subscription.proration_date = timestamp
stripe_subscription.save(idempotency_key=idempotency_key) stripe.Subscription.save(stripe_subscription, idempotency_key=idempotency_key)
def increment_subscription_quantity( def increment_subscription_quantity(
customer: Customer, timestamp: int, idempotency_key: str) -> None: customer: Customer, timestamp: int, idempotency_key: str) -> None:

View File

@ -64,6 +64,10 @@ class Subscription:
prorate: bool=..., tax_percent: float=...) -> Subscription: prorate: bool=..., tax_percent: float=...) -> Subscription:
... ...
@staticmethod
def save(subscription: Subscription, idempotency_key: str=...) -> Subscription:
...
class Card: class Card:
id: str id: str
last4: str last4: str