Skip to content

Commit

Permalink
billing: Set idempotency key to None when running test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
rishig committed Jan 30, 2019
1 parent 60f2213 commit db6e647
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion corporate/lib/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,17 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
plan.invoiced_through = ledger_entry
plan.invoicing_status = CustomerPlan.STARTED
plan.save(update_fields=['invoicing_status', 'invoiced_through'])
idempotency_key = 'ledger_entry:{}'.format(ledger_entry.id) # type: Optional[str]
if settings.TEST_SUITE:
idempotency_key = None
stripe.InvoiceItem.create(
currency='usd',
customer=plan.customer.stripe_customer_id,
description=description,
discountable=False,
period = {'start': datetime_to_timestamp(ledger_entry.event_time),
'end': datetime_to_timestamp(next_renewal_date(plan, ledger_entry.event_time))},
idempotency_key='ledger_entry:{}'.format(ledger_entry.id),
idempotency_key=idempotency_key,
**price_args)
invoice_item_created = True
plan.invoiced_through = ledger_entry
Expand Down
2 changes: 1 addition & 1 deletion stubs/stripe/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class InvoiceItem:
@staticmethod
def create(amount: int=..., currency: str=..., customer: str=..., description: str=...,
discountable: bool=..., period: Dict[str, int]=..., quantity: int=...,
unit_amount: int=..., idempotency_key: str=...) -> InvoiceItem:
unit_amount: int=..., idempotency_key: Optional[str]=...) -> InvoiceItem:
...

@staticmethod
Expand Down

0 comments on commit db6e647

Please sign in to comment.