Handle invoice item in line items also
This commit is contained in:
parent
0a22ced19c
commit
ecfec9dd21
1 changed files with 9 additions and 3 deletions
|
@ -139,6 +139,14 @@ class StripeUtils(object):
|
||||||
)
|
)
|
||||||
has_more_invoices = invoices.has_more
|
has_more_invoices = invoices.has_more
|
||||||
for invoice in invoices.data:
|
for invoice in invoices.data:
|
||||||
|
sub_ids = []
|
||||||
|
for line in invoice.lines.data:
|
||||||
|
if line.type == 'subscription':
|
||||||
|
sub_ids.append(line.id)
|
||||||
|
elif line.type == 'invoiceitem':
|
||||||
|
sub_ids.append(line.subscription)
|
||||||
|
else:
|
||||||
|
sub_ids.append('')
|
||||||
invoice_details = {
|
invoice_details = {
|
||||||
'created': invoice.created,
|
'created': invoice.created,
|
||||||
'receipt_number': invoice.receipt_number,
|
'receipt_number': invoice.receipt_number,
|
||||||
|
@ -156,9 +164,7 @@ class StripeUtils(object):
|
||||||
'lines_meta_data_csv': ','.join(
|
'lines_meta_data_csv': ','.join(
|
||||||
[line.metadata.VM_ID if hasattr(line.metadata, 'VM_ID') else '' for line in invoice.lines.data]
|
[line.metadata.VM_ID if hasattr(line.metadata, 'VM_ID') else '' for line in invoice.lines.data]
|
||||||
),
|
),
|
||||||
'subscription_ids_csv': ','.join(
|
'subscription_ids_csv': ','.join(sub_ids),
|
||||||
[line.id if line.type == 'subscription' else '' for line in invoice.lines.data]
|
|
||||||
),
|
|
||||||
'line_items': invoice.lines.data
|
'line_items': invoice.lines.data
|
||||||
}
|
}
|
||||||
starting_after = invoice.id
|
starting_after = invoice.id
|
||||||
|
|
Loading…
Reference in a new issue