from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Get billing history for a subscription
subscription_id = "625f5cee-259b-4994-b7eb-416b9e551f2c"
response = client.subscriptions.get_billing_history(subscription_id)
for invoice in response['data']:
print(f"Invoice: {invoice['invoice_number'] or 'Draft'}")
print(f" Amount: {invoice['currency']} {invoice['total_amount']}")
print(f" Status: {invoice['status']}")
print(f" Due: {invoice['due_date']}")
print(f" Source: {invoice['source_type']}"){
"statusCode": 200,
"message": "Billing history fetched successfully",
"meta": {},
"data": [
{
"invoice_id": "0d9e5a0e-7de4-48c6-b01a-b1759394578b",
"invoice_number": null,
"issued_date": "2026-03-12T16:55:21.847Z",
"due_date": "2026-04-01T23:59:59.999Z",
"total_amount": 21,
"amount_paid": 0,
"balance_due": 21,
"currency": "USD",
"status": "draft",
"payment_method": null,
"source_type": "billing_cycle",
"created_at": "2026-02-13T13:01:32.715Z"
},
{
"invoice_id": "762d8b5f-e416-4d88-8461-2a357b91ff25",
"invoice_number": "INV027",
"issued_date": "2026-02-13T13:01:01.520Z",
"due_date": "2026-03-05T23:59:59.999Z",
"total_amount": -23.0356,
"amount_paid": 0,
"balance_due": -23.0356,
"currency": "USD",
"status": "paid",
"payment_method": null,
"source_type": "order",
"created_at": "2026-02-13T13:01:02.598Z"
}
],
"errors": {}
}Retrieve the billing history for a subscription, including all invoices, credit notes, and payment statuses
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Get billing history for a subscription
subscription_id = "625f5cee-259b-4994-b7eb-416b9e551f2c"
response = client.subscriptions.get_billing_history(subscription_id)
for invoice in response['data']:
print(f"Invoice: {invoice['invoice_number'] or 'Draft'}")
print(f" Amount: {invoice['currency']} {invoice['total_amount']}")
print(f" Status: {invoice['status']}")
print(f" Due: {invoice['due_date']}")
print(f" Source: {invoice['source_type']}"){
"statusCode": 200,
"message": "Billing history fetched successfully",
"meta": {},
"data": [
{
"invoice_id": "0d9e5a0e-7de4-48c6-b01a-b1759394578b",
"invoice_number": null,
"issued_date": "2026-03-12T16:55:21.847Z",
"due_date": "2026-04-01T23:59:59.999Z",
"total_amount": 21,
"amount_paid": 0,
"balance_due": 21,
"currency": "USD",
"status": "draft",
"payment_method": null,
"source_type": "billing_cycle",
"created_at": "2026-02-13T13:01:32.715Z"
},
{
"invoice_id": "762d8b5f-e416-4d88-8461-2a357b91ff25",
"invoice_number": "INV027",
"issued_date": "2026-02-13T13:01:01.520Z",
"due_date": "2026-03-05T23:59:59.999Z",
"total_amount": -23.0356,
"amount_paid": 0,
"balance_due": -23.0356,
"currency": "USD",
"status": "paid",
"payment_method": null,
"source_type": "order",
"created_at": "2026-02-13T13:01:02.598Z"
}
],
"errors": {}
}The unique subscription identifier (UUID)