Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt

Use this file to discover all available pages before exploring further.

Callback methods

To implement the Unity Payment Links SDK, include the following callback methods:
MethodDescriptionArgumentType
OnInitializedTriggered when SDK initialization was successful.
OnInitializeFailedTriggered when SDK initialization failed.errorErrorMessage
OnPricePointsSuccessTriggered when price points are successfully retrieved, after calling GetPricePoints.pricePointsPricePointsModel
OnPricePointsFailTriggered when price points can’t be retrieved or are unavailable, after calling GetPricePoints.errorErrorMessage
OnPurchaseSuccessTriggered when a purchase was successful.orderOrderResponseModel
OnPurchaseFailedTriggered when the checkout window closed or if a server-to-server error occurred during the purchasing process. Returns an error code, message, JSON, and order details.error, orderErrorMessage, OrderResponseModel

OrderResponseModel properties

The OrderResponseModel argument type contains the following properties:
Property NameTypeDescriptionExample
dateIntUnix timestamp of the order.1718182312
sessionTokenStringUnique token for the current session."xxxxXXXXxxxxXXXXxxxx"
offerNameStringName of the purchased offer."Starter Pack"
offerSkuStringSKU identifier for the offer."starter_pack_001"
items[Item]List of items included in the purchase.[{ name: "Gems", sku: "gem_01", quantity: "100" }]
items.nameStringDisplay name of the item."Gems"
items.skuStringUnique SKU code for the item."gem_01"
items.quantityStringQuantity of the item included."100"
priceIntPrice of the order in minor units. For example, cents for USD.499
currencyStringISO 4217 currency code"USD"
customerIdStringID of the player who made the purchase."cust_98765"
customerCountryStringCountry code of the player in ISO 3166-1 alpha-2 format."US"
paymentMethodNameStringPayment method."Visa"
orderIdStringOrder ID."1234567890"
purchaseIdStringA unique ID to track the transaction."pr_xxxxxx"

ErrorMessage properties

The ErrorMessage argument type contains the following properties:
Property NameTypeDescriptionExample
codeIntError code identifying the failure.3002
messageStringDetailed message describing the failure."Purchase canceled because the user closed the checkout interface."

Example code

using Appcharge.PaymentLinks.Models;
using Appcharge.PaymentLinks.Interfaces;
using UnityEngine;

public class AppchargeCallbackImpl : ICheckoutPurchase
{
    public void OnInitialized()
    {
        Debug.Log("SDK initialization was successful.");
    }

    public void OnInitializeFailed(ErrorMessage error)
    {
        Debug.Log("SDK initialization failed.");
    }

    public void OnPricePointsSuccess(PricePointsModel pricePoints)
    {
       Debug.Log("Price points retrived.");
    }

    public void OnPricePointsFail(ErrorMessage error)
    {
        Debug.Log("Failed to retrieve price points.");
    }

    public void OnPurchaseSuccess(OrderResponseModel order)
    {
        Debug.Log("Purchase was successful: " + order.orderId);
    }

    public void OnPurchaseFailed(ErrorMessage error, OrderResponseModel order)
    {
        Debug.Log("Purchase failed: " + (order != null ? order.orderId : "no order found"));
    }
}