amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

Trying figure it out with Amplitude.Instance.logRevenue #45

Closed Vladeng closed 4 years ago

Vladeng commented 4 years ago

Hi folks, Would you kindly to help me! We're trying to implement [Amplitude] Revenue with Verified status. Our code looks like this:

double usd_price = 0;
USD_PRICES.TryGetValue(product_id, out usd_price);

if (Application.platform == RuntimePlatform.IPhonePlayer)
{
    Amplitude.Instance.logRevenue(product_id, 1, usd_price, args.purchasedProduct.receipt, null, "purchase", eventProperties);
}
else if (Application.platform == RuntimePlatform.Android)
{
    Receipt receipt = JsonUtility.FromJson<Receipt>(args.purchasedProduct.receipt);
    Payload payload = JsonUtility.FromJson<Payload>(receipt.Payload);
    Debug.Log("Purchase signature = " + payload.signature);
    Amplitude.Instance.logRevenue(product_id, 1, usd_price, args.purchasedProduct.receipt, payload.signature, "purchase", eventProperties);
}

But it didn't work. We still see only "[Amplitude] Revenue" events.

help page https://developers.amplitude.com/docs/tracking-revenue looks like a mess. There is using .logRevenueV2 but in new version doesn't have any .logRevenueV2 method only .logRevenue.

Examples didn't explain anything. For example

if (Application.platform == RuntimePlatform.IPhonePlayer) {
 Amplitude.Instance.logRevenue("sku", 1, 1.99, "cmVjZWlwdA==", null, "purchase", eventProperties);
}

Where we can take "cmVjZWlwdA==" & it's Payload object or full product.receipt on Base64. I have no idea.

Ps. We inserted all platform keys in Integrations section.

haoliu-amp commented 4 years ago

Hello, have you figured out the problem already?

Vladeng commented 4 years ago

Hello, have you figured out the problem already?

yep.