A lightweight Unity SDK for integrating Appcharge Payment Links into your game. Use it to open a secure checkout, handle purchase callbacks, and fetch price points with minimal setup.
- 🔗 Open Appcharge checkout directly from your Unity game
- 💳 Receive purchase success / failure callbacks
- 💰 Fetch available price points
- 🧩 Easy integration using
ICheckoutPurchase - 📦 Distributed as a Unity Package Manager (UPM) package
- Open Unity
- Go to Window → Package Manager
- Click the + button → Add package from git URL…
- Enter your Git URL
- Click Add
using Appcharge.PaymentLinks;
using Appcharge.PaymentLinks.Interfaces;
using Appcharge.PaymentLinks.Models;
using UnityEngine;
Create a MonoBehaviour that receives callbacks from the SDK:
public class CheckoutSample : MonoBehaviour, ICheckoutPurchase
{
public AppchargeEnvironment Environment;
public string CustomerId = "John Doe";
// Initialize the SDK
public void Init()
{
PaymentLinksController.Instance.Init(CustomerId, this);
}
// Backend returns checkout session → open checkout
public void OnSessionSuccess(CheckoutResponse response)
{
PaymentLinksController.Instance.OpenCheckout(response.purchaseId, response.parsedUrl);
}
// Fetch price points
public void GetPricePoints()
{
PaymentLinksController.Instance.GetPricePoints();
}
// --- ICheckoutPurchase callbacks ---
public void OnPurchaseSuccess(OrderResponseModel order)
{
Debug.Log($"Purchase Success: OrderId={order.orderId}, PaymentMethod={order.paymentMethodName}");
}
public void OnPurchaseFailed(ErrorMessage error, OrderResponseModel order)
{
Debug.LogError($"Purchase Failed: Code={error.code}, Message={error.message}, OrderId={order?.orderId}");
}
public void OnInitialized()
{
Debug.Log("Payment Links SDK Initialized: " + PaymentLinksController.Instance.GetSdkVersion());
}
public void OnInitializeFailed(ErrorMessage error)
{
Debug.LogError($"Init Failed: Code={error.code}, Message={error.message}");
}
public void OnPricePointsSuccess(PricePointsModel pricePoints)
{
Debug.Log($"Price Points Success: {pricePoints.pricingPoints.Length} price points received");
}
public void OnPricePointsFail(ErrorMessage error)
{
Debug.LogError($"Price Points Fail: {error.message}");
}
} PaymentLinksController.Instance.Init(CustomerId, this);Your backend returns the following:
purchaseIdparsedUrl(recommended), orurl,checkoutSessionToken, andpurchaseId
PaymentLinksController.Instance.OpenCheckout(purchaseId, parsedUrl);
// or (legacy):
PaymentLinksController.Instance.OpenCheckout(url, checkoutSessionToken, purchaseId);OnPurchaseSuccess(OrderResponseModel order)OnPurchaseFailed(ErrorMessage error, OrderResponseModel order)
PaymentLinksController.Instance.GetPricePoints();Callbacks:
OnPricePointsSuccess(PricePointsModel pricePoints)OnPricePointsFail(ErrorMessage error)
- Init(string customerId, ICheckoutPurchase callback)
- Init(string checkoutToken, string environment, string customerId, ICheckoutPurchase callback)
- OpenCheckout(string purchaseId, string parsedUrl)
- OpenCheckout(string url, string checkoutSessionToken, string purchaseId)
- GetPricePoints()
- GetSdkVersion()
- CheckoutResponse
- OrderResponseModel
- PricePointsModel
- ErrorMessage
- ICheckoutPurchase
For help or integration questions: Contact your Appcharge representative or open an issue in your repository.