Skip to content

Payments

  1. Open the Platforms section and add all the information about the Platform where the game is available. It's required to validate the purchases.
  2. Open the Products section and fill in all the information about the Products your game has. In most cases you just need the main table, however, if you have different ProductId, Name, or Price for different platforms, you might want to use the override section for each of the platforms.
  3. Get a list Of Products:

    Balancy.Payments.GetProducts(productsResponse =>
    {
        Debug.Log("Products Received " + productsResponse.Success);
        if (productsResponse.Success)
            Debug.Log("Products Count: " + productsResponse.Products.Length);
    });
    
  4. Make a purchase:

    Balancy.Payments.PurchaseProduct(<product_id>, doneCallback =>
    {
        Debug.Log("Purchase was made " + doneCallback.Success);
    });
    
  5. If you are using our Smart Offers, use the next method to purchase an Offer and a Store Item

    Balancy.SmartObjects.Manager.PurchaseOffer(offerInfo, purchaseResponse =>
    {
        Debug.Log("Purchase status " + purchaseResponse.Success + " for " + purchaseResponse.ProductId);
    });
    
    Balancy.SmartObjects.Manager.PurchaseStoreItem(storeItem, purchaseResponse =>
    {
        Debug.Log("Purchase status " + purchaseResponse.Success + " for " + purchaseResponse.ProductId);
    });
    
  6. If you are using your own Payment/Validation system, you just need to confirm the purchase with Balancy. This information will only be used for future Segmentation and will be saved in the profile history if the purchase is valid.

    var paymentInfo = new PaymentInfo
    {
        Receipt = unityProduct.receipt,
        Price = (float)unityProduct.metadata.localizedPrice,
        Currency = unityProduct.metadata.isoCurrencyCode,
        ItemId = unityProduct.definition.id
    };
    
    Balancy.SmartObjects.Manager.OfferWasPurchased(offerInfo, paymentInfo, purchaseResponse =>
    {
        Debug.Log("Purchase status " + purchaseResponse.Success + " for " + purchaseResponse.ProductId);
    });
    <-- OR -->
    Balancy.SmartObjects.Manager.ItemWasPurchased(storeItem, paymentInfo, purchaseResponse =>
    {
        Debug.Log("Purchase status " + purchaseResponse.Success + " for " + purchaseResponse.ProductId);
    });
    
  7. To get the list of all the payments the user made, call the following method (make sure to do that after ExternalEvents.SmartObjects.SmartObjectsInitializedEvent is invoked)

    UnnyProfileManager.GetPaymentsInfo();