Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 363e943

Browse files
committed
add dynamic data to extra
1 parent da1bf84 commit 363e943

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

services/billing.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,38 +727,55 @@ def update_billing_address(self, owner: Owner, name, billing_address):
727727

728728
try:
729729
customer = stripe.Customer.retrieve(owner.stripe_customer_id)
730-
log.info(f"Retrieved customer: {customer}")
730+
log.info("Retrieved customer", extra=dict(customer=customer))
731731

732732
default_payment_method = customer.invoice_settings.default_payment_method
733-
log.info(f"Retrieved default payment method: {default_payment_method}")
733+
log.info(
734+
"Retrieved default payment method",
735+
extra=dict(payment_method=default_payment_method),
736+
)
734737

735738
if default_payment_method is None:
736739
log.warning(
737-
f"Customer {owner.stripe_customer_id} has no default payment method, skipping payment method update"
740+
"Customer has no default payment method, skipping payment method update",
741+
extra=dict(
742+
stripe_customer_id=owner.stripe_customer_id,
743+
ownerid=owner.ownerid,
744+
),
738745
)
739746
# Still update the customer address even if there's no payment method
740747
stripe.Customer.modify(
741748
owner.stripe_customer_id, address=billing_address
742749
)
743750
log.info(
744-
f"Stripe successfully updated customer address for owner {owner.ownerid} by user #{self.requesting_user.ownerid}"
751+
"Stripe successfully updated customer address",
752+
extra=dict(
753+
ownerid=owner.ownerid,
754+
requesting_user_id=self.requesting_user.ownerid,
755+
),
745756
)
746757
return
747758

748759
log.info(
749-
f"Modifying payment method billing details for customer {owner.stripe_customer_id}"
760+
"Modifying payment method billing details",
761+
extra=dict(stripe_customer_id=owner.stripe_customer_id),
750762
)
751763
stripe.PaymentMethod.modify(
752764
default_payment_method,
753765
billing_details={"name": name, "address": billing_address},
754766
)
755767

756768
log.info(
757-
f"Modifying customer address for customer {owner.stripe_customer_id}"
769+
"Modifying customer address",
770+
extra=dict(stripe_customer_id=owner.stripe_customer_id),
758771
)
759772
stripe.Customer.modify(owner.stripe_customer_id, address=billing_address)
760773
log.info(
761-
f"Stripe successfully updated billing address for owner {owner.ownerid} by user #{self.requesting_user.ownerid}"
774+
"Stripe successfully updated billing address",
775+
extra=dict(
776+
ownerid=owner.ownerid,
777+
requesting_user_id=self.requesting_user.ownerid,
778+
),
762779
)
763780
except Exception as e:
764781
log.error(

0 commit comments

Comments
 (0)