A game can sell access to a single level, to a hint, or to any piece of the task text. The scheme is this: the author creates a product, puts a payment button into the task, and closes off the paid content with a template that checks whether the product has been paid for.
Before you start: the payment system is switched on by the domain administrator, not by the game author. If payment is not configured on the domain, the payment button simply never appears on the page. The paywall can still be tested without configured payment — see the “How to Test It” section.
In the game editor open “Products / Paid access (Paywall)“. The products screen has four fields:
A game may have as many products as you like: a separate product for each paid level, for example.
At the spot in the task where the button should appear, write:
%pay_button product_key%
The engine replaces this with a “Pay {price} {currency}“ button. Pressing it opens a separate payment system window.
What is worth knowing about the button:
{%= no} branch.
The button on its own hides nothing — the paid text has to be closed off with the product_KEY template. It has three values:
yes — the product is bought, access granted.pending — payment has started but the bank has not confirmed it yet. Rare, but the branch is better provided for.no — not paid.{% match product_level_5 }:{
{%= yes}:{
Thank you for your purchase! The code to pass the level: ZOO
%}
{%= pending}:{
Your payment is being processed by the bank. Wait a moment and refresh the page.
%}
{%= no}:{
This level contains paid content.
%pay_button level_5%
%}
%}
The template is evaluated on the server, so unpaid content never reaches the page source — there is no way to peek at it.
If the product name has a typo in it, the template does not complain — it simply always returnsno. Check the key against the button: in that case it will show “Product not found”.
When the player completes the payment, the payment system window closes by itself and the game page reloads — the paid content appears without the player having to do anything.
Access is granted to the team, not to the player: one pays, everyone gets it. In single-player games that is, naturally, the same person.
The list of purchases for the game is visible to the author on the game purchases screen — unfinished payment attempts are shown there too. Access can also be granted by hand from that screen: handy when a player paid you some other way, or when a payment got stuck and has to be closed manually.
Enter the game through “Test Game”. For a test team the engine substitutes a test payment system of its own, regardless of what is configured on the domain, or whether anything is configured at all. The payment button works like the real one, but instead of the bank it opens a form with a field for a code — the code you need is written right there in the form. No real money is charged.
That way the whole chain can be checked end to end: the no branch with the button, and the switch to the yes branch after “payment”.
What is described here is selling content inside a game. Charging for taking part in a game is a separate mechanism: the price is set in the game settings, and teams are admitted to the game automatically once they have paid. See Game Settings.