IAP/Subscription Tracking

We only support Unity IAP at the moment.

Here is the list of IntegrationEvents about IAP/Subscription:

IAPRequest

IAPResponse

SubscriptionRequest

SubscriptionResponse

HELPFUL SOURCES

Unity IAP (Includes with example code) -> https://learn.unity.com/tutorial/unity-iap#5c7f8528edbc2a002053b46e

About Receipt -> https://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html

Product Meta Datas -> https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Purchasing.ProductMetadata.html

Product Definitions -> https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Purchasing.ProductDefinition.html

IAPRequest

You need to call this method whenever users makes a product buy request. Example, when user click on "BuyConsumable" or "BuyNonConsumable" buttons.

USAGE

IAPRequest method takes 6 parameters. Here is the list:

-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.

-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.

-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.

-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.

-> cartType : Where does this item belong. e.g Shop Item/End page.

public void BuyConsumable()
{
    var currencyCode = "TRY";
    var localPrice = 0.59f;
    var productType = "Consumable";
    var productId = "consumable";
    var cartType = "Shop";
  
    CodaGameManager.Instance.GameEventManager.IntegrationEvents.IAPRequest(
      currencyCode, localPrice, productType, productId, cartType);
  
    BuyProductID(kProductIDConsumable);
}

IAPResponse

You need to call this method whenever product request has a response(in this case when Unity IAP's response callback comes).

USAGE

IAPResponse method takes 8 parameters. Here is the list:

-> receipt : Receipt that comes with Unity IAP, inside ProcessPurchase method if purchase is successfull, if not leave it blank.

-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.

-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.

-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.

-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.

-> cartType : Where does this item belong. e.g Shop Item/End page.

-> status : Status of response. true(Successful), false(Failed).

// This is one of Unity IAP's callback, for example you can send IAPResponse event here.
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
{
  var receipt = product.receipt;
  var productType = product.definition.type;
  var productId = product.definition.id;
  var productPrice = product.metadata.localizedPrice;
  var productCurrencyCode = product.metadata.isoCurrencyCode;

  if (productType == ProductType.Consumable)
  {
    CodaGameManager.Instance.GameEventManager.IntegrationEvents.IAPResponse(
      receipt, productCurrencyCode, (float)productPrice,
      productType.ToString(), productId, "Shop", false, 0.087f);
  }
}

SubscriptionRequest

You need to call this method whenever users makes a Subscription request. Example, when user click on "BuySubscription" button.

USAGE

SubscriptionRequest method takes 5 parameters. Here is the list:

-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.

-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.

-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.

-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.

public void BuySubscription()
{
    var currencyCode = "TRY";
    var localPrice = 0.59f;
    var productType = "Consumable";
    var productId = "consumable";
  
    CodaGameManager.Instance.GameEventManager.IntegrationEvents.SubscriptionRequest(
      currencyCode, localPrice, productType, productId);
  
    BuyProductID(kProductIDSubscription);
}

SubscriptionResponse

You need to call this method whenever subscription request has a response(in this case when Unity IAP's response callback comes).

USAGE

SubscriptionResponse method takes 7 parameters. Here is the list:

-> receipt : Receipt that comes with Unity IAP, inside ProcessPurchase method if purchase is successfull, if not leave it blank.

-> currencyCode : Local currency code. USD, EUR, TRY etc. You can get currency code when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check out iso currency codes to find your local currency code.

-> amount : Local Price. You can get local price when purchase if successful or fail but while requesting the purchase you need to enter this float manual. Check your store page to find your local prices.

-> productType : Product Type that comes with Unity IAP, inside ProcessPurchase method. There are 3 product types, "Consumable", "NonConsumable", "Subscription". Write these manually while requesting the purchase. You can get these from Unity IAP, inside ProcessPurchase method after purchase is handled.

-> productId : Product Id that comes with Unity IAP, inside ProcessPurchase method. You can get product id when purchase if successful or fail but while requesting the purchase you need to enter this string manual. Check your store page to find your item's product id.

-> status : Status of response. true(Successful), false(Failed).

// This is one of Unity IAP's callback, for example you can send SubscriptionResponse event here.
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
{
  var receipt = product.receipt;
  var productType = product.definition.type;
  var productId = product.definition.id;
  var productPrice = product.metadata.localizedPrice;
  var productCurrencyCode = product.metadata.isoCurrencyCode;

  if (productType == ProductType.Subscription)
  {
            CodaGameManager.Instance.GameEventManager.IntegrationEvents.SubscriptionResponse(
              receipt, productCurrencyCode,
              (float) productPrice,productType.ToString(), productId, false, 0.087f);
  }
}

Did this page help you?