Примеры использования методов

Данные операции позволяют настроить работу плагина.

  1. Получение Receipt для Revenue

Получение Receipt для Revenue

Данный пример основан на использовании Unity IAP.

// Declaration of the Receipt structure for getting information about the IAP.
[System.Serializable]
public struct Receipt
{
    public string Store;
    public string TransactionID;
    public string Payload;
}

// Additional information about the IAP for Android.
[System.Serializable]
public struct PayloadAndroid
{
    public string Json;
    public string Signature;
}

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
    var product = args.purchasedProduct;
    if(String.Equals(product.definition.id, 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);
#if UNITY_ANDROID
            PayloadAndroid payloadAndroid = JsonUtility.FromJson<PayloadAndroid>(receipt.Payload);
            yaReceipt.Signature = payloadAndroid.Signature;
            yaReceipt.Data = payloadAndroid.Json;
#elif UNITY_IPHONE
            yaReceipt.TransactionID = receipt.TransactionID;
            yaReceipt.Data = receipt.Payload;
#endif
            revenue.Receipt = yaReceipt;
        }
        // Sending data to the AppMetrica server.
        AppMetrica.Instance.ReportRevenue(revenue);
    }
    return PurchaseProcessingResult.Complete;
}
Скопировано

Если вы не нашли ответ на свой вопрос, то вы можете задать его через форму обратной связи. Пожалуйста, опишите возникшую проблему как можно подробнее. Если возможно, приложите скриншот.