ENGINEERING NOTE 14 / 50 · SMS
Estimate SMS cost per receipt with refunds included
The sticker price per number is not the same as cost per received message. Use settled debits, completed refunds and a clearly defined receipt count.
Published by OPEN RAMBO. The engineering patterns and pseudocode illustrate designs, not a documented product API. Numerical examples are illustrative.
Use a closed window
Select a cohort whose orders and refunds have had time to settle. Pending refunds belong in a separate column; treating them as already returned understates cost. Keep the billing currency stable or disclose the conversion method.
Separate operational cost
Compute net number fees independently from support time, infrastructure and payment fees. A low number price with repeated manual intervention may cost more overall. Do not compare providers using different service-country mixes and call the difference a quality result.
Handle zero receipts
If no messages arrived, cost per receipt is undefined, not zero. Show the spend and zero receipts explicitly. Use the metric alongside receipt rate and waiting time; minimizing cost alone can select a cheap but unsuitable channel.
Illustrative implementation
net_cost = settled_debits - completed_refunds
cost_per_receipt = net_cost / receipts if receipts else NoneAcceptance check
Reconcile the net cost to ledger entries and keep pending refunds outside the completed-refund total.