Files
tysdk-intergration/ExtraPluginCfgs/Android/rustore/ChannelEntry.java
2026-05-21 00:37:19 +08:00

45 lines
1.5 KiB
Java

package com.unity3d.player;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ChannelEntry {
public static final String CHANNEL = "Rustore";
public static SDKManager.IChannelSDKAdapter createSDKAdapter() {
return null;
}
public static String normalizeSkuList(String msg) {
if (msg == null || msg.isEmpty()) return msg;
try {
JSONArray products = new JSONArray(msg);
for (int i = 0; i < products.length(); i++) {
JSONObject p = products.getJSONObject(i);
// price is in kopecks, convert to micros: kopecks * 10000
String price = p.optString("price", "0");
long micros = Long.parseLong(price) * 10000;
p.put("price_amount_micros", String.valueOf(micros));
// Map currency → price_currency_code
String currency = p.optString("currency", "");
if (!currency.isEmpty()) {
p.put("price_currency_code", currency);
}
// Convert display price: "199" → "₽1.99"
float rubles = Float.parseFloat(price) / 100;
p.put("price", String.format("₽%s", rubles));
}
return products.toString();
} catch (JSONException e) {
Log.e("ChannelEntry", "normalizeSkuList error: " + e.getMessage());
return msg;
}
}
}