Logo: In Game Purchases

In Game Purchases

Organisatioun
SummerEngine
in-game-purchases

Sell items for Sparks via the Summer purchase sheet: checkout, not enough Sparks, unlocks, grants.

Iwwersiicht

EditeurSummerEngine
Repositorysummer
Skill-Nummin-game-purchases
Stären
91
Forks
8
Matgeliwwert Dateien
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    SummerEngine huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill In Game Purchases an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/SummerEngine/summer/tree/main/library/skills/in-game-purchases
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SummerEngine/summer.git /tmp/summer
mkdir -p .claude/skills
cp -r /tmp/summer/library/skills/in-game-purchases .claude/skills/in-game-purchases
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert In Game Purchases an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet In Game Purchases automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass In Game Purchases net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

In-game purchases with Sparks

Sparks are Summer's currency. A game never takes money, never holds a balance and never approves a payment. It asks Summer for a checkout, Summer shows its own purchase sheet over the game, and the game reacts to the authoritative result.

The player wants toCallValidated by
buy an item with Sparks they haveSummer.client.store.request_checkout(lines)the Summer ledger (debit)
buy Sparks because they are shortno game call: the player gets Sparks in the Summer appthe Summer app

The engine has no call that sells Sparks from inside the game. When a checkout fails with insufficient_funds, tell the player they need more Sparks and that they can get them in the Summer app, then let them press Buy again.

This skill covers the purchase sheet and granting an effect on a server. For the rest of the store, use the summer-store skill: where items come from and how one becomes buyable, item slugs, summer.items.json, bundles and sales, owned items, and the authority's entitlement check.

When to sell with Sparks

  • Sell anything that persists across sessions or devices (cosmetics, unlocks, passes) as a Summer item with a Sparks price. Why: the platform owns the item, so ownership survives reinstalls and cannot be forged by editing the game.
  • Do not invent your own currency that is bought with money. Why: Summer can only refund, protect and pay you out for Sparks purchases.
  • Open the shop only from an explicit shop or buy button. Why: the Summer sheet interrupts play; surprise payment prompts read as pressure and get games reported.

Rules and the reason for each

  1. Never grant an item from a button press or a receipt. Unlock only when Summer.client.items shows the player owns it. Why: the receipt proves the debit; the inventory projection is what the platform guarantees the player owns, including after a crash or on another device.
  2. Never send prices or amounts. The game passes an offer ID and a quantity (SummerCheckoutLine.create(offer_id, quantity)). Why: the platform prices everything; a client-supplied price is exactly what a cheater edits.
  3. One call is one purchase. Every request_checkout creates a new identity. Never call again to "retry" an unknown outcome (SummerCheckoutOperation.is_outcome_unknown()). Why: the first request may already be charged; the SDK recovers it and delivers the result on the signal.
  4. Handle results in checkout_status_changed, and deduplicate by request_id plus version. Connect normally (not deferred) before requesting. To draw a checkout panel, read get_checkout_statuses() and has_pending_checkouts() instead of keeping your own list. Why: results can arrive after a restart or twice after a crash; a synchronous handler is how the SDK knows the result was delivered.
  5. Treat manual_review and pending as not done. Why: the platform has not decided yet; showing success or failure would be a guess.
  6. Check readiness and hide what is unavailable. check_checkout_readiness() (buying) and check_browse_readiness() (listing with list_items()) return a SummerResult. Why: editor play, guest sessions and older Summer apps do not offer purchases; a dead button is worse than no button.

Result states

checkout_status_changed(status: SummerCheckoutStatus) delivers a status whose state is one of:

StateMeaningWhat the game does
awaiting_approvalthe Summer sheet is opennothing; optionally dim the shop
pendingthe debit is in progressshow "processing"
purchaseddone; Sparks debited, status.receipt is setrefresh items and unlock from inventory
declinedthe player closed the sheetreturn to the shop quietly
expiredthe sheet timed outsame as declined
rejectedrefused; read error_codeinsufficient_funds: "Not enough Sparks. Get Sparks in the Summer app." Other codes: "The purchase was not completed."
manual_reviewplatform is checking it"We are confirming this purchase"

status.is_terminal() tells you whether the state can still change. Unknown future error_code values never mean success.

The operation returned by request_checkout also completes: ok on purchased, a failure otherwise. The status signal is the one to build UI on.

Minimal complete example

Items are named by slug (Studio's "Item key", e.g. sword), which is the same in staging and production. Definition ids (item_…) differ between them, so never hard-code one. The slug getters need a Summer version that carries them (newer than 0.7.3); on an older one, use each environment's definition id with has_owned_definition() and get_definition_id(). The summer-store skill shows how to check.

gdscript
extends Node
## A one-item shop. Buys `offer_id` and unlocks from inventory.

## From the store listing: item.price.offer_id of the item whose get_slug() is item_slug.
@export var offer_id := ""
@export var item_slug := "sword"

signal message(text: String)
var _seen := {}

func _ready() -> void:
	if Summer.client == null:
		return # not running as a player's game
	Summer.client.store.checkout_status_changed.connect(_on_checkout)
	Summer.client.items.refreshed.connect(_sync_owned)
	_sync_owned()

func buy() -> void:
	if not Summer.client.store.check_checkout_readiness().ok:
		message.emit("The shop is not available here.")
		return
	var lines: Array[SummerCheckoutLine] = [SummerCheckoutLine.create(offer_id, 1)]
	Summer.client.store.request_checkout(lines) # result arrives in _on_checkout

func _first_time(status: SummerCheckoutStatus) -> bool:
	var key := "%s:%d" % [status.request_id, status.version]
	if _seen.has(key):
		return false
	_seen[key] = true
	return true

func _on_checkout(status: SummerCheckoutStatus) -> void:
	if not _first_time(status):
		return
	match status.state:
		&"purchased":
			Summer.client.items.refresh() # ownership comes from inventory
		&"rejected":
			if status.error_code == &"insufficient_funds":
				message.emit("Not enough Sparks. Get Sparks in the Summer app, then buy again.")
			else:
				message.emit("The purchase was not completed.")
		&"manual_review":
			message.emit("We are confirming this purchase.")
		&"declined", &"expired":
			pass

func _sync_owned() -> void:
	if Summer.client.items.has_owned_slug(item_slug):
		message.emit("Sword unlocked.") # the only place the item is granted

Multiplayer: granting an effect on a dedicated authority

Anything the Sparks buy ("Grow now", "Summon rain") is a checkout for an item, and on a server the authority must never grant it because a client says it paid. Why: a client message is the one thing a cheater controls.

Model the effect as a catalog item with instance ownership (each purchase is a separate owned item, not a stack). Why: a stackable item shares one owned item ID across purchases, so the ID could not tell two purchases apart.

The client checks out; the receipt's items[i].owned_item_ids are the owned items. The client sends the authority only an owned item ID. The authority:

  1. reads that player's inventory with Summer.authority.items.inventory_for_session(session) and checks the item is there, owned, and the right item (its slug);
  2. checks its own record of redeemed item IDs, kept in the player's secret player data (Summer.authority.player_data), so the item grants once per player in every world;
  3. writes the new record, and applies the effect only after that write succeeds.
gdscript
# On the dedicated authority.
const EFFECT_SLUG := "grow_now"

func redeem(session: SummerSession, owned_item_id: String) -> void:
	var inv := Summer.authority.items.inventory_for_session(session)
	var read: SummerResult = await inv.get_result_or_completed_signal()
	if not read.ok:
		return # unavailable: the client may ask again later
	var item: SummerInventoryItem = null
	for candidate in inv.items:
		if candidate.get_owned_item_id() == owned_item_id:
			item = candidate
	if item == null or not item.is_owned() or item.get_slug() != EFFECT_SLUG:
		return # not owned by this player: never grant

	var load_op := Summer.authority.player_data.load(session)
	var loaded: SummerResult = await load_op.get_result_or_completed_signal()
	if not loaded.ok:
		return
	var data: Dictionary = load_op.secret_record.data
	var redeemed: Dictionary = data.get("redeemed", {})
	if redeemed.has(owned_item_id):
		return # a repeated message grants once
	redeemed[owned_item_id] = true
	data["redeemed"] = redeemed
	var save_id := "redeem_" + owned_item_id.sha256_text().substr(0, 40)
	var commit := Summer.authority.player_data.commit_secret(session, save_id, data)
	var saved: SummerResult = await commit.get_result_or_completed_signal()
	if not saved.ok:
		return # retryable: commit again with the same save_id
	apply_grow_now(session)
  • The save ID comes from the owned item ID. Why: resending the same save ID with the same content returns the earlier commit (commit.replayed), so a retry after a timeout records the redemption once.
  • Apply the effect when the commit succeeds even if commit.replayed is true and the effect is not in your world yet. Why: a replay means the redemption was recorded earlier, but your world may have crashed before it applied the effect.
  • The engine has no call that uses up an owned item. The item stays in the player's inventory after it is redeemed; the redeemed list is what stops a second grant. Show redeemed items as used in your UI.

Idempotency

The SDK generates the checkout request ID and replays it across transport failures and app restarts; the platform debits a checkout once per request. Your only job is the request_id:version dedupe above, so a replayed signal does not show a message or play an effect twice.

Per-surface behaviour

  • Summer Games app on iOS: a native Summer sheet over the game.
  • Summer desktop app: an overlay sheet; the result returns to the game on the signal.
  • Web: the same sheet in the page.
  • Editor play and local runs: readiness is unavailable. Build the unavailable path first.

The game code is identical on every surface.

Testing

  • Test against Summer staging, where Sparks come from test payments (sandbox Sparks). Why: no real money moves and results are identical to production. Use a staging account that bought Sparks in the staging Summer app. The summer-store skill covers staging access and what makes an item buyable there.
  • Walk every state: decline the sheet, let it expire, buy with too few Sparks, get Sparks in the Summer app, then buy the item. Kill the game while a checkout is pending and relaunch; the result must still arrive once.
  • Verify the unlock comes from items.refreshed, not from the checkout signal.

Store policy notes

  • Apple requires In-App Purchase for digital goods and currency sold inside iOS apps. Summer's iOS sheet and app handle this; never add your own payment links, web prices or "cheaper on the web" text inside the game. Why: it can get the Summer app removed from the App Store for every game.
  • Randomized paid rewards must disclose their odds before purchase (Apple and most regions require it).
  • Say what a purchase gives in plain words next to the price.

Availability

request_checkout, list_items, Summer.client.items, Summer.authority.items.inventory_for_session and Summer.authority.player_data ship in the engine today. Buying Sparks inside the game does not: players get Sparks in the Summer app.

See also

  • summer-store: items, slugs, bundles, owned items and the authority check
  • multiplayer-state
  • ui-basics

From a shell

No Summer MCP tools in this session? Run each one as a command; when summer --version is missing or below 4.0, use npx -y summer-engine@latest in place of summer. Fields are flags in kebab-case (--scene-path res://main.tscn) or one --input '<json>', and summer ops describe <op> prints the exact input. The summer-cli skill has the rest.

In this skillCommand
summer_get_scene_treesummer engine get-scene-tree
summer_get_script_errorssummer engine get-script-errors

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill In Game Purchases?

Sell items for Sparks via the Summer purchase sheet: checkout, not enough Sparks, unlocks, grants.

Firwat In Game Purchases op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. In Game Purchases besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech In Game Purchases an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/SummerEngine/summer/tree/main/library/skills/in-game-purchases an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen In Game Purchases benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat In Game Purchases benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir In Game Purchases domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill In Game Purchases gratis?

Jo. SummerEngine huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇