XPay converts accepted meter events into invoice amounts by applying each meter's aggregation rule and each pricing model attached to the subscription's plan.
Billing flow
- The merchant sends meter events for an eligible subscription.
- XPay applies each event to the ongoing invoice cycle.
- XPay aggregates usage separately for each meter.
- XPay evaluates every pricing model attached to the plan.
- XPay creates the invoice and records the calculation in
pricing_model_breakdown. - XPay attempts payment with the subscription's payment token.
- XPay sends subscription and invoice payment events.
XPay uses the aggregation rule defined by each Billing meters. It evaluates every attached pricing model separately, then records each result in the invoice. See Usage-based pricing models for how component charges and multiple models affect the total.
Invoice breakdown
The generated invoice's pricing_model_breakdown contains the usage and calculated amounts for each pricing model.
Each pricing model entry can include:
For three Nexa Cloud API-request events priced at PKR 5.00 per request with a 15% non-inclusive tax, a shortened breakdown can look like:
{
"pricing_model_breakdown": [
{
"pricing_model_id": "api-request-pricing",
"pricing_model_name": "Nexa Cloud API request pricing",
"charge_type": "standard",
"base_amount": 0,
"usage_amount": 17.25,
"total_amount": 17.25,
"components": [
{
"meter_id": "api_requests",
"meter_name": "Nexa Cloud API requests",
"aggregation_type": "count",
"pricing_type": "standard",
"usage": 3,
"amount_without_taxes": 15,
"amount": 17.25,
"standard_or_percentage": {
"amount": 5
},
"taxes": [
{
"key": "sales_tax",
"value": 15,
"type": "percentage",
"inclusive": false
}
]
}
],
"meters_used": [
"api_requests"
]
}
]
}pricing_model_breakdown as the reconciliation record.Payment outcome
- A successful payment sets the invoice to
paidand keeps or returns the subscription topaid. - A failed payment changes the subscription to
inactiveand triggers the configured Failed payments and retries. - Manually paying an invoice through Invoices and recurring payments returns an eligible subscription to
paid.
Store the invoice and subscription states separately, even when one payment outcome updates both.