Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Add support for automatic_tax
Browse files Browse the repository at this point in the history
  • Loading branch information
calm-mlin committed Aug 2, 2024
1 parent 1532fb1 commit 7e8d118
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion localstripe/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3083,7 +3083,7 @@ def __init__(self, customer=None, metadata=None, items=None,
payment_behavior='allow_incomplete',
trial_period_days=None, billing_cycle_anchor=None,
proration_behavior=None,
coupon=None, **kwargs):
coupon=None, automatic_tax=None, **kwargs):
if kwargs:
raise UserError(400, 'Unexpected ' + ', '.join(kwargs.keys()))

Expand Down Expand Up @@ -3150,6 +3150,11 @@ def __init__(self, customer=None, metadata=None, items=None,
'error_if_incomplete')
if coupon is not None:
assert type(coupon) is str
if automatic_tax is not None:
assert ('enabled' in automatic_tax
and automatic_tax['enabled'] in ("false", "true"))
enabled = try_convert_to_bool(automatic_tax['enabled'])
automatic_tax['enabled'] = enabled
except AssertionError:
raise UserError(400, 'Bad request')

Expand Down Expand Up @@ -3213,6 +3218,7 @@ def __init__(self, customer=None, metadata=None, items=None,
self.start_date = backdate_start_date or int(time.time())
self.billing_cycle_anchor = billing_cycle_anchor
self.coupon = coupon
self.automatic_tax = automatic_tax
self._enable_incomplete_payments = (
enable_incomplete_payments and
payment_behavior != 'error_if_incomplete')
Expand Down
6 changes: 6 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -985,3 +985,9 @@ charge=$(curl -sSfgG -u $SK: $HOST/v1/invoices \
-d expand[]=data.charge.refunds \
| grep -oE '"charge": null,')
[ -n "$charge" ]

# test support for automatic taxes
curl -sSfg -u $SK: $HOST/v1/subscriptions \
-d customer=$cus \
-d items[0][plan]=basique-mensuel \
-d automatic_tax[enabled]=true

0 comments on commit 7e8d118

Please sign in to comment.