Add in-app purchases and paywalls to your Unity game with one C# API for iOS, Android, and desktop.
The Unity SDK is on the roadmap and is not published yet.com.cashsdk.unity does not
resolve from any registry today, so the code on this page describes the
intended API rather than a package you can install.
Shipping now? Use the iOS or Android SDK, which are
available today. To be notified when this one lands, contact
support@cashsdk.com.
The CashSDK Unity SDK gives your game a single, fully typed C# API that runs on
iOS (StoreKit 2), Android (Play Billing), and desktop. Fetch offerings, run
purchases, and read entitlements with the same async/await code on every
build target.
Purchases are validated server-side, so entitlements stay trustworthy even on
a jailbroken device or a modified build. The SDK targets Unity 2021.3 LTS
and newer.
Initialize CashSDK once, as early as possible in your game's lifecycle. A
RuntimeInitializeOnLoadMethod runs before the first scene loads, which makes it
a good home for configuration. Use your publishable key.
csharp
using UnityEngine;
using CashSDKUnity;
public static class Bootstrap
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Init()
{
CashSDK.Configure("csk_pk_…");
}
}
Only ship publishable keys (csk_pk_… / csk_pk_…) in your build. Secret
keys (csk_sk_…) belong on your backend.
Fetch the offering, present its packages as buttons, and unlock on success.
csharp
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using CashSDKUnity;
public class PaywallScreen : MonoBehaviour
{
[SerializeField] Button monthlyButton;
[SerializeField] Text priceLabel;
async void Start()
{
var offering = await CashSDK.Offerings();
priceLabel.text = offering.Monthly.LocalizedPrice;
monthlyButton.onClick.AddListener(() => _ = Buy(offering.Monthly));
}
async Task Buy(Package package)
{
var result = await CashSDK.Purchase(package);
if (result.Entitlements["pro"].IsActive)
{
// Dismiss and unlock
}
}
}