
Twórz kody promocyjne do własnej gry
Ustawiaj w panelu kody dające graczom przedmioty, walutę lub inne nagrody w grze.
Elastyczne payloady nagród
Dane nagrody to dowolny JSON, więc możesz przyznawać dowolną kombinację walut, przedmiotów lub flag, które rozumie Twoja gra.
Wartości gracza na serwerze
Serwer przyznaje do ośmiu skonfigurowanych wartości przy realizacji kodu. giftData pozostaje osobnymi danymi gry. Wyświetl zwrócone saldo bez ponownego dodawania nagrody lokalnie.
Kontrola unieważniania
Natychmiast unieważnij kod z poziomu dashboardu, jeśli wycieknie lub będzie nadużywany: bez potrzeby aktualizacji aplikacji.
Szybka integracja
Zrealizuj kod
Wpisz kod podarunkowy
Wpisz poniżej swój kod promocyjny
// Develop Unity SDK: signed-in player, durable original redemption intent.
using PM.horizOn.Cloud.Manager;
using UnityEngine;
// Run from one explicit player action; serialize this handler until it completes.
string userId = UserManager.Instance.CurrentUser.UserId;
string project = HorizonApp.Network.GetApiKey();
string scope = PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent.ProjectFingerprint(project);
string pendingKey = "horizOn_gift_v2_" + scope + "_" + userId;
// Preserve an old V1 demo record for reconciliation. Never reinterpret its UUID as a count.
if (PlayerPrefs.HasKey("horizOn_gift_pending_" + userId)) return;
PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent pending;
if (PlayerPrefs.HasKey(pendingKey)) {
pending = JsonUtility.FromJson<PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent>(PlayerPrefs.GetString(pendingKey));
if (pending == null || !pending.IsValidFor(project, userId)) return;
} else {
pending = await GiftCodeManager.Instance.PrepareRedemption("WELCOME");
if (pending == null || !pending.IsValidFor(project, userId) || PlayerPrefs.HasKey(pendingKey)) return;
PlayerPrefs.SetString(pendingKey, JsonUtility.ToJson(pending));
PlayerPrefs.Save(); // All seven fields before the first mutating request.
}
string original = JsonUtility.ToJson(pending);
if (PlayerPrefs.GetString(pendingKey) != original) return;
var result = await GiftCodeManager.Instance.RedeemPrepared(pending);
if (result == null || !result.success) return; // Keep the exact tuple after any uncertain result.
if (PlayerPrefs.GetString(pendingKey) == original) {
PlayerPrefs.DeleteKey(pendingKey);
PlayerPrefs.Save();
}
if (result.playerValues != null) {
foreach (var value in result.playerValues.values) Debug.Log(value.key + "=" + value.balance);
}
// alreadyApplied/replayed means the sequence slot was consumed, with no copied historical rewards.
// Replace balances with playerValues. Never add grantedValues locally.Te przykłady używają SDK Unity (C#) i REST API. Godot i Unreal mają te same wywołania we własnych SDK: zobacz quickstart
Najczęściej zadawane pytania
Gotowy do integracji?
Zacznij budować z horizOn już dziś. Free Tier w zestawie.
