Usage examples

These operations allow you to configure the plugin.

  1. Getting a Receipt for Revenue

Getting a Receipt for Revenue

The example below is based on the use of Unity IAP.

// Declaration of the Receipt structure for getting information about the IAP.
public struct Receipt
    public string Store;
    public string TransactionID;
    public string Payload;

// Additional information about the IAP for Android.
public struct PayloadAndroid
    public string Json;
    public string Signature;

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    var product = args.purchasedProduct;
    if(String.Equals(, kProductIDConsumable, StringComparison.Ordinal)) {
        string currency = product.metadata.isoCurrencyCode;
        decimal price = product.metadata.localizedPrice;

        // Creating the instance of the YandexAppMetricaRevenue class.
        YandexAppMetricaRevenue revenue = new YandexAppMetricaRevenue(price, currency);
        if(product.receipt != null) {
            // Creating the instance of the YandexAppMetricaReceipt class.
            YandexAppMetricaReceipt yaReceipt = new YandexAppMetricaReceipt();
            Receipt receipt = JsonUtility.FromJson<Receipt>(product.receipt);
            PayloadAndroid payloadAndroid = JsonUtility.FromJson<PayloadAndroid>(receipt.Payload);
            yaReceipt.Signature = payloadAndroid.Signature;
            yaReceipt.Data = payloadAndroid.Json;
            yaReceipt.TransactionID = receipt.TransactionID;
            yaReceipt.Data = receipt.Payload;
            revenue.Receipt = yaReceipt;
        // Sending data to the AppMetrica server.
    return PurchaseProcessingResult.Complete;
Copied to clipboard