From gateway usage to a Stripe invoice line
Stripe's usage-based billing is built on Meters. You create a meter with an event name and an aggregation (sum, count or last), attach a metered price to it, and send meter events carrying a Stripe customer id and a value. Stripe aggregates the events over the billing period and prices them on the invoice.
PALM SOUQ does the sending. In the console you connect a restricted Stripe key, map your tenant id to the Stripe customer id (by metadata field, by a lookup webhook, or by uploading a mapping), and choose what each meter counts: raw tokens, billable tokens after your allowance, or cost in cents with a markup. The gateway batches usage per tenant per minute and posts meter events with a deterministic identifier, so retries never double-bill.
Allowances, overages and credits
The common hybrid plan is a flat subscription that includes an allowance of tokens, with overage billed per million tokens beyond it. PALM SOUQ tracks the allowance per tenant in real time and only emits meter events for usage above it, so the overage price on Stripe stays simple and the subscription price stays the subscription price.
For prepaid credit plans, PALM SOUQ can also draw down a Stripe customer credit balance and, when the balance reaches a threshold you set, fire a webhook to your app so you can prompt the customer to top up before the quota engine starts degrading or blocking.
Reconciliation and margin
Because PALM SOUQ knows both sides of each request, it can join what you charged (from Stripe subscriptions and meter events) with what you paid the model provider. The result is a per-customer revenue versus COGS view that updates through the month instead of once the invoice closes.
If a Stripe API call fails, events are queued in the PALM SOUQ region that metered them and retried with backoff. The console shows any tenant whose events are behind, with the count of pending events and the oldest timestamp.
Rolling it out safely
Connect a Stripe test mode key first. PALM SOUQ sends meter events to test mode exactly as it would in live mode, so you can open a test customer's upcoming invoice and see the overage line take shape while you generate traffic in staging.
When the invoice preview looks right, swap in a restricted live key with meter event write access only. Keep the key restricted: PALM SOUQ has no reason to read payment methods, create charges or edit subscriptions, and a restricted key makes that explicit.