Virtual currency
Earn it or buy it
BillDog virtual currency on Lumen, our demo app: link a store pack, grant and deduct coins for one customer, and see why the app’s public key can’t award coins.
Transcript
Every coin in your app got there one of two ways. Somebody earned it, or somebody bought it. Either way, you need one balance you can trust, and a record of every change.
In BillDog, that coin is a virtual currency. This one is for Lumen, our demo app. A code, which is what your code uses, and the name people see: Moons.
Then the “buy it” half. Link a store product, a consumable pack called a hundred Moons, and set what it’s worth: a hundred units on purchase.
Here’s what that link does. When a store purchase of the pack is recorded, BillDog credits its units times the quantity bought. Once per purchase, even if the store sends the same notification twice.
A sandbox purchase credits a test customer, so you can try the loop before release. Test Store and imported purchases never do. And this video makes no purchase. The link is configuration.
Which is the “earn it” half. Here’s one of Lumen’s customers, Maya, with no Moons yet. Grant fifty, for a seven-day listening streak.
The new balance comes straight back, and the ledger records it: the amount, the balance after, and why.
Inside your product, earning usually goes through your server. It calls BillDog with a secret key: which customer, which currency, how many, and an idempotency key, so a retry can’t pay twice.
The public key inside your app can’t do that. Send the same call with it, and the server refuses. An app can’t choose its own coins.
Spending goes the other way. Deduct twenty to unlock a soundscape. Thirty left, and a second line in the ledger.
Now ask for more than she has. A hundred. Refused: insufficient balance. Nothing moved, and a balance never goes below zero.
The currency keeps the totals. Fifty granted, twenty deducted, thirty in circulation, and one customer holding them.
Earned or bought, it’s the same coin, in the same balance, with the same record.