amount
and expiry_date
. At any given time, the total credit balance for a customer is the sum of the remaining amount in their unexpired credit blocks.
invoice_settings.require_successful_payment
when creating a credit increment. Note that this is an option within the invoice_settings
dictionary because invoice creation is necessary for this behavior.
With this option enabled, the credit block will be initialized with a status
of pending_payment
until the relevant invoice is paid. Although the block will be returned when fetching the customer credit balance, it will not be eligible to be drawn from until it’s in status=active
.
If you’re using Orb invoicing with a payment gateway integration, Orb is responsible for listening to the gateway webhooks and will automatically mark the block as active once the payment is successful. If the invoice is in a synced
state (e.g. a different invoicing provider is used), it will need to be manually marked as paid via the API for the credit block to be considered part of the balance.
Note that this option is also available when creating a credit top-up and is configured when first creating the top-up via the API.
customer.credit_balance_depleted
or customer.credit_balance_dropped
webhook anytime the customer’s credit balance goes below the specified threshold.
To quickly test that the webhook is working, you can:
price_id
since all deductions are associated with a specific price.description
field for business-specific attribution.amount
in the newly expired block.identifier
for the currency
field in the request body.
effective_date
of an automatic deduction is the beginning of the day in the customer’s timezone. This means that a given credit block must be effective before the beginning of the day in order to be eligible for usage drawdown for that day’s usage. In most circumstances, Orb recommends creating credit blocks aligned to the previous day boundary in the customer’s timezone.
timestamp
, which is the time the usage occurred. To account for this, Orb maintains pending ledger entries until the reporting grace period has passed. After this point, Orb commits the entry, making it immutable.
This is important to the fidelity of the ledger because the ordering of operations can have a significant impact to the credit balance. For example, if an event with timestamp = 2022-02-02T23:00:00
is reported 10 hours later and a block expires at timestamp = 2022-02-03T00:00:00
, Orb will automatically create the deduction ledger entry for the event before the block expiry, properly allowing it to deduct credit balance from an eligible block.
Note that an entry that is pending is not the same as a block that is not active. The status
of a block is only relevant when payment is a condition to adding credits; in contrast, a pending entry is related to the grace period of the ledger.