Unity Mobile Checkout SDK FE Integration

Overview

This document is an appendix to the Unity SDK Integration Guide, specifically for publishers using the direct communication model with the Secret Publisher Token. For further assistance please refer to the DirectCheckoutSample file.

Prerequisites

Before starting, you need to gather some information from the Appcharge dashboard:

  • Secret Publisher Token: Navigate to Admin -> Integration -> Publisher Token to get your secret token. This enables direct communication with Appcharge servers.

Setup the AppChargeConfig File

  1. Locate the AppChargeConfig file in the folder Assets/Resources/AppCharge.
  2. Configure the Secret Publisher Token setting:
SettingDescription
Secret Publisher TokenPaste your secret token if you plan to use direct access to the checkout.

Initialize the Checkout

Create a checkout model by using the following code snippet:

AppChargeCheckoutModel checkoutModel = new AppChargeCheckoutModel(...);

Parameters required for the checkout model:

ParameterTypeDescription
customerIdstringThe name of the customer
customerEmailstringCustomer email address
pricefloatOffer price (in cents)
currencystringOffer price currency. For example: "usd", "eur"
offerNamestringThe name of the offer
offerSkustringOffer's sku
offerAssetUrlstringAn image URL for the offer
offerDescriptionstringOffer's description

If your offer contains a set of items (bundle), add these as followed:

// Utilize the model by adding extra items
checkoutModel.AddItem(...);

Here are the parameters needed for creating an item:

ParameterDescription
itemNameThe name of the item
assetUrlAn image which represents the item
itemSkuItem's sku
itemAmountItem's Quantity

Example:

// Prepare checkout model
string customerId = "JohnDoe";
string customerEmail = "[email protected]";
int price = 129; // in USD cents 
string currency = "usd";
string offerName = "BestDealPackage"; 
string offerSku = "best_deal_package";
string offerAssetUrl = "https://media-dev.appcharge.com/media/64ad4f25cc1a482bac467ae5/fire-fire-logo-fire-fire-icon-fire-sign-fire-symbol-transparent-background-ai-generative-free-png.png";
string offerDescription = "Coin Pack Bundle";

// Declare a model for getting session token
checkoutModel = new RequestModel(
customerId,
customerEmail,
price,
currency,
offerName,
offerSku,
offerAssetUrl,
offerDescription
);

// Utilize the model by adding extra items
string itemName = "Coins";
string itemAssetUrl = "https://media-dev.appcharge.com/media/product-3.png";
string itemSku = "coins";
int itemAmount = 300;
checkoutModel.AddItem(itemName, itemAssetUrl, itemSku, itemAmount);

Launch the Checkout

Open the checkout using the checkoutModel (step 5 in the full SDK Guide):

AppchargeManager.OpenCheckoutDirect(checkoutModel);

This function should be called when a user presses a button in your in-game store and once you initialized the checkoutModel.