Skip to content

Commit

Permalink
chore(server): Format checkout service
Browse files Browse the repository at this point in the history
  • Loading branch information
birkjernstrom committed Jan 2, 2025
1 parent d74d451 commit ab841e9
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions server/polar/checkout/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,11 @@ async def handle_stripe_success(
customer=stripe_customer_id,
currency=checkout.currency or "usd",
price=stripe_price_id,
coupon=checkout.discount.stripe_coupon_id
if checkout.discount
else None,
coupon=(
checkout.discount.stripe_coupon_id
if checkout.discount
else None
),
automatic_tax=checkout.product.is_tax_applicable,
metadata=metadata,
invoice_metadata={
Expand All @@ -963,9 +965,11 @@ async def handle_stripe_success(
subscription_id=subscription.stripe_subscription_id,
old_price=subscription.price.stripe_price_id,
new_price=stripe_price_id,
coupon=checkout.discount.stripe_coupon_id
if checkout.discount
else None,
coupon=(
checkout.discount.stripe_coupon_id
if checkout.discount
else None
),
automatic_tax=checkout.product.is_tax_applicable,
metadata=metadata,
invoice_metadata={
Expand All @@ -984,9 +988,9 @@ async def handle_stripe_success(
customer=stripe_customer_id,
currency=checkout.currency or "usd",
price=stripe_price_id,
coupon=checkout.discount.stripe_coupon_id
if checkout.discount
else None,
coupon=(
checkout.discount.stripe_coupon_id if checkout.discount else None
),
automatic_tax=checkout.product.is_tax_applicable,
metadata={
**metadata,
Expand Down Expand Up @@ -1072,9 +1076,9 @@ async def handle_free_success(
customer=stripe_customer_id,
currency=checkout.currency or "usd",
price=stripe_price_id,
coupon=checkout.discount.stripe_coupon_id
if checkout.discount
else None,
coupon=(
checkout.discount.stripe_coupon_id if checkout.discount else None
),
automatic_tax=False,
metadata=metadata,
invoice_metadata={
Expand All @@ -1092,9 +1096,9 @@ async def handle_free_success(
customer=stripe_customer_id,
currency=checkout.currency or "usd",
price=stripe_price_id,
coupon=checkout.discount.stripe_coupon_id
if checkout.discount
else None,
coupon=(
checkout.discount.stripe_coupon_id if checkout.discount else None
),
automatic_tax=False,
metadata=metadata,
idempotency_key=idempotency_key,
Expand Down Expand Up @@ -1552,9 +1556,11 @@ async def _update_checkout_tax(
checkout.subtotal_amount,
checkout.product.stripe_product_id,
checkout.customer_billing_address,
[checkout.customer_tax_id]
if checkout.customer_tax_id is not None
else [],
(
[checkout.customer_tax_id]
if checkout.customer_tax_id is not None
else []
),
)
checkout.tax_amount = tax_amount
except TaxCalculationError:
Expand Down Expand Up @@ -1642,9 +1648,11 @@ async def _create_or_update_customer(
update_params["address"] = checkout.customer_billing_address.to_dict() # type: ignore
await stripe_service.update_customer(
stripe_customer_id,
tax_id=to_stripe_tax_id(checkout.customer_tax_id)
if checkout.customer_tax_id is not None
else None,
tax_id=(
to_stripe_tax_id(checkout.customer_tax_id)
if checkout.customer_tax_id is not None
else None
),
**update_params,
)
customer.stripe_customer_id = stripe_customer_id
Expand Down

0 comments on commit ab841e9

Please sign in to comment.