@@ -64,19 +64,20 @@ func (s *BillingService) FinalizeInvoice(ctx context.Context, in *v1.FinalizeInv
64
64
return nil , status .Errorf (codes .InvalidArgument , "Missing InvoiceID" )
65
65
}
66
66
67
- invoice , err := s .stripeClient .GetInvoice (ctx , in .GetInvoiceId ())
67
+ invoice , err := s .stripeClient .GetInvoiceWithCustomer (ctx , in .GetInvoiceId ())
68
68
if err != nil {
69
69
logger .WithError (err ).Error ("Failed to retrieve invoice from Stripe." )
70
70
return nil , status .Errorf (codes .NotFound , "Failed to get invoice with ID %s: %s" , in .GetInvoiceId (), err .Error ())
71
71
}
72
72
73
- subscription := invoice .Subscription
74
- if subscription == nil {
75
- logger .Error ("No subscription information available for invoice." )
76
- return nil , status .Errorf (codes .Internal , "Failed to retrieve subscription details from invoice." )
73
+ customer := invoice .Customer
74
+ if customer == nil {
75
+ logger .Error ("No customer information available for invoice." )
76
+ return nil , status .Errorf (codes .Internal , "Failed to retrieve customer details from invoice." )
77
77
}
78
+ logger = logger .WithField ("stripe_customer" , customer .ID ).WithField ("stripe_customer_name" , customer .Name )
78
79
79
- teamID , found := subscription .Metadata [stripe .AttributionIDMetadataKey ]
80
+ teamID , found := customer .Metadata [stripe .AttributionIDMetadataKey ]
80
81
if ! found {
81
82
logger .Error ("Failed to find teamID from subscription metadata." )
82
83
return nil , status .Errorf (codes .Internal , "Failed to extra teamID from Stripe subscription." )
0 commit comments