Create a checkout model by using the following code snippet:
AppChargeCheckoutModel checkoutModel = new AppChargeCheckoutModel(...);
Parameters required for the checkout model:
Parameter | Type | Description |
---|---|---|
customerId | string | The name of the customer |
customerEmail | string | Customer email address |
price | float | Offer price (in cents) |
currency | string | Offer price currency. For example: "usd", "eur" |
offerName | string | The name of the offer |
offerSku | string | Offer's sku |
offerAssetUrl | string | An image URL for the offer |
offerDescription | string | Offer's description |
Add a set of items (bundle) as followed:
Note: At least one item must be included.
// Utilize the model by adding extra items
checkoutModel.AddItem(...);
Here are the parameters needed for creating an item:
Parameter | Description |
---|---|
itemName | The name of the item |
assetUrl | An image which represents the item |
itemSku | Item's sku |
itemAmount | Item'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);
Open the checkout using the checkoutModel
:
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
.
Configure Success Screen and Close Checkout
To use the Appcharge success screen:
- Locate the
AppChargeConfig
file in the folderAssets/Resources/AppCharge
. - Turn on the success screen toggle.
- Listen to the
CheckoutEvents.OnOrderSuccess
event, and wait 1.5 seconds for the animation to finish running. - Close the Appcharge SDK using the
AppchargeManager.Close
function.
To use your own Success screen:
- Locate the
AppChargeConfig
file in the folderAssets/Resources/AppCharge
. - Turn off the success screen toggle.
- Listen to the
CheckoutEvents.OnOrderSuccess
event. - Close the Appcharge SDK using the
AppchargeManager.Close
function. - Show your own success screen. For example:
AppchargeManager.ListenToEvent(CheckoutEvents.OnOrderSuccess, (Dictionary<string, string> args) =>
{
Debug.Log("Checkout Success triggered");
AppchargeManager.Close(); // Close the checkout
});