Skip to content

Purchases

Balancy facilitates a variety of purchase types to suit different game monetization strategies. Players can acquire:

  1. StoreItem
  2. GameOffer
  3. OfferGroup

Explore the four methods to process purchases:

Direct Purchase

Balancy automates price checks and validations, informing the client about the outcome through a callback. Learn more about the purchase flow.

Setup

  • Install the Balancy Payments package via Tools ► Balancy ► Updates.
  • Configure Payments in Balancy, providing necessary validation data.

Methods to initiate a purchase:

Balancy.LiveOps.Store.PurchaseStoreItem(StoreItem storeItem, 
                                        System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.PurchaseOffer(OfferInfo offerInfo, 
                                        System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.PurchaseOffer(OfferGroupInfo offerInfo, 
                                        StoreItem storeItem, 
                                        System.Action<PurchaseProductResponseData> callback);

Post-Purchase Notification

If you manage the transactions by yourself, use these methods to notify Balancy post-purchase, utilizing receipt validation. Detailed purchase flow.

Setup

  • Ensure the Balancy Payments package is installed. Tools ► Balancy ► Updates.
  • Complete Payments configuration for validation requirements.

Notification methods:

Balancy.LiveOps.Store.ItemWasPurchased(StoreItem storeItem, 
                                      PaymentInfo paymentInfo, 
                                      System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.OfferWasPurchased(OfferInfo offerInfo, 
                                      PaymentInfo paymentInfo, 
                                      System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.OfferWasPurchased(OfferGroupInfo offerInfo, 
                                      StoreItem storeItem, 
                                      PaymentInfo paymentInfo, 
                                      System.Action<PurchaseProductResponseData> callback);

Self-Validated Purchase

If you are handling both transaction and validation, inform Balancy post-completion without its validation. Currency conversion and segmentation still require PaymentInfo. Read more.

Balancy.LiveOps.Store.ItemWasPurchasedAndValidated(StoreItem storeItem, 
                                                  PaymentInfo paymentInfo, 
                                                  Constants.Platform paymentPlatform, 
                                                  System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.OfferWasPurchasedAndValidated(OfferInfo offerInfo, 
                                                  PaymentInfo paymentInfo, 
                                                  Constants.Platform paymentPlatform, 
                                                  System.Action<PurchaseProductResponseData> callback);
Balancy.LiveOps.GameOffers.OfferWasPurchasedAndValidated(OfferGroupInfo offerInfo, 
                                                  StoreItem storeItem, 
                                                  PaymentInfo paymentInfo, 
                                                  Constants.Platform paymentPlatform, 
                                                  System.Action<PurchaseProductResponseData> callback);

Soft Currency Purchases

For in-game currency acquisitions, these methods are recommended. In you are actively using the Inventory, you can use the Direct Purchase.

Balancy.LiveOps.Store.ItemWasPurchasedSoft(StoreItem storeItem);
Balancy.LiveOps.GameOffers.OfferWasPurchasedSoft(OfferInfo offerInfo);
Balancy.LiveOps.GameOffers.OfferWasPurchasedSoft(OfferGroupInfo offerInfo, 
                                                StoreItem storeItem);

Visualizing the Purchase Flow

Below is a schematic representation of Balancy's SDK logic for handling purchases:

Screenshot

Handling Ad-based Purchases

Since Balancy does not automatically process rewarded ads, the following code snippet is recommended for ad-based item acquisitions:

if (storeItem.IsAdsWatching())
{
    if (storeItem.IsEnoughResources())
    {
        LiveOps.Store.ItemWasPurchasedSoft(storeItem);
    }
    else
    {
        //TODO Show a rewarded Ad =>
        LiveOps.Store.AdWasWatchedForStoreItem(storeItem);
    }
}

For GameOffers and OfferGroups, similar methods are available under LiveOps.GameOffers.