refactor: FlexionSDKHelper 迁移至 ExtraPluginCfgs + 构建配置更新

- 删除 tysdk/Plugins/Android 下的 FlexionSDKHelper(已迁移至 ExtraPluginCfgs/flexion)
- 更新 AndroidManifest/mainTemplate.gradle/settingsTemplate.gradle 配置
- 更新 ChannelHelpers/ConfigManager 渠道配置
- 更新 tuyoosdk AAR 和 google-services.json

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 11:24:52 +08:00
parent f60a1dd0c2
commit fd5ba9297d
10 changed files with 58 additions and 477 deletions

View File

@@ -1,52 +1,48 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.arkgame.ft.flexion" xmlns:tools="http://schemas.android.com/tools"> <manifest
<uses-permission android:name="android.permission.VIBRATE" /> xmlns:android="http://schemas.android.com/apk/res/android"
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> package="com.arkgame.ft"
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> xmlns:tools="http://schemas.android.com/tools">
<application android:extractNativeLibs="true" android:name="com.unity3d.player.TYApp" tools:replace="android:usesCleartextTraffic,android:fullBackupContent" android:fullBackupContent="@xml/flexion_backup_rules" android:usesCleartextTraffic="true"> <uses-permission android:name="android.permission.VIBRATE" />
<activity android:name="com.unity3d.player.TYUnityActivity" android:theme="@style/UnityThemeSelector"> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<intent-filter> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<action android:name="android.intent.action.MAIN" /> <application android:extractNativeLibs="true" android:name="com.unity3d.player.TYApp" android:usesCleartextTraffic="true">
<category android:name="android.intent.category.LAUNCHER" /> <activity android:name="com.unity3d.player.TYUnityActivity"
</intent-filter> android:theme="@style/UnityThemeSelector">
<intent-filter android:autoVerify="true"> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" /> </intent-filter>
<data android:scheme="https" android:host="fishingtraveliae.onelink.me" android:pathPrefix="/jT1Q" />
</intent-filter> <intent-filter android:autoVerify="true">
<intent-filter> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="fishingtraveliae.onelink.me" android:pathPrefix="/jT1Q"/>
<data android:host="mainactivity" android:scheme="zzft" /> </intent-filter>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" /> <intent-filter>
</activity> <action android:name="android.intent.action.VIEW" />
<!-- 渠道标识ChannelManager 读取此值以识别 Flexion 渠道 --> <category android:name="android.intent.category.DEFAULT" />
<meta-data android:name="CHANNEL" android:value="Flexion" /> <category android:name="android.intent.category.BROWSABLE" />
<!-- 覆盖 gasdk 与 tuyoosdk 的 MainProcessName 冲突 --> <data android:host="mainactivity" android:scheme="zzft" />
<meta-data android:name="com.sensorsdata.analytics.android.MainProcessName" android:value="com.arkgame.ft.flexion" tools:replace="android:value" /> </intent-filter>
<!-- Flexion SDK 应用标识,从 DropPoint 获取 -->
<meta-data android:name="com.flexionmobile.fdk.apptoken" android:value="fishingtravel" /> <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<!-- 告知 Flexion SDK 当前为 Unity 项目,必须声明 -->
<meta-data android:name="com.flexionmobile.fdk.sdk-type" android:value="unity" /> <meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="true" />
<!-- <meta-data android:name="google_analytics_default_allow_ad_storage" android:value="true" />
覆盖 tuyoosdk AAR 中硬编码的 Facebook ContentProvider authority。 <meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="true" />
AAR 原值com.facebook.app.FacebookContentProvider162066986963808 <meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="true" />
追加 ${applicationId}Flexion 包名)作为后缀后,与 GP 版 authority 不同,
两个渠道包可同时安装在同一设备上,不会触发 INSTALL_FAILED_CONFLICTING_PROVIDER。 </activity>
参考Flexion 官方文档《Unique package name - follow-on requirements》 <meta-data android:name="CHANNEL" android:value="GooglePlay" />
</application>
<provider <queries>
android:name="com.facebook.FacebookContentProvider" <provider android:authorities="com.facebook.katana.provider.PlatformProvider" /> <!-- allows app to access Facebook app features -->
android:authorities="com.facebook.app.FacebookContentProvider162066986963808.${applicationId}" <provider android:authorities="com.facebook.orca.provider.PlatformProvider" /> <!-- allows sharing to Messenger app -->
android:exported="true" <intent>
tools:replace="android:authorities" /> <action android:name="android.intent.action.MAIN"/>
--> </intent>
</application> </queries>
<queries> </manifest>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
<provider android:authorities="com.facebook.orca.provider.PlatformProvider" />
</queries>
</manifest>

View File

@@ -13,14 +13,7 @@ android {
} }
// Android Resolver Exclusions End // Android Resolver Exclusions End
android { android {
namespace "com.unity3d.player" namespace "com.unity3d.player"
}
// Flexion 渠道专用:排除不需要的 AppsFlyer 模块
// - purchase-connector: 基于 Google Play BillingFlexion 不走 GP 计费,没用还增大包
// 即使 Unity Android Resolver 下次又把 implementation 行写回来,这里的 exclude 也兜底排除
configurations.all {
exclude group: 'com.appsflyer', module: 'purchase-connector'
} }
dependencies { dependencies {
@@ -38,17 +31,13 @@ dependencies {
api "io.reactivex:rxandroid:1.2.1" api "io.reactivex:rxandroid:1.2.1"
api "io.reactivex:rxjava:1.1.9" api "io.reactivex:rxjava:1.1.9"
// Google Play In-App Review // Google Play In-App Review
implementation 'com.google.android.play:review:2.0.1' implementation 'com.google.android.play:review:2.0.1'
// Google Play Billing — tuyoosdk AAR references BillingManager during init
implementation 'com.android.billingclient:billing:6.0.1'
implementation 'net.aihelp:android-aihelp-aar:5.3.+' implementation 'net.aihelp:android-aihelp-aar:5.3.+'
implementation 'com.google.android.gms:play-services-auth:20.2.0' implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation('com.android.billingclient:billing:7.0.0')
// Flexion SDK (includes wrapped billing)
implementation("com.flexionmobile:sdk:4.0.1")
implementation 'com.google.android.gms:play-services-basement:18.2.0' implementation 'com.google.android.gms:play-services-basement:18.2.0'
implementation 'androidx.fragment:fragment:1.3.6' implementation 'androidx.fragment:fragment:1.3.6'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.41" implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.41"
@@ -59,7 +48,7 @@ dependencies {
implementation 'com.miui.referrer:homereferrer:1.0.0.6' implementation 'com.miui.referrer:homereferrer:1.0.0.6'
implementation platform('com.google.firebase:firebase-bom:32.7.4') implementation platform('com.google.firebase:firebase-bom:34.6.0')
implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-analytics'
implementation('com.facebook.android:facebook-android-sdk:16.2.0') implementation('com.facebook.android:facebook-android-sdk:16.2.0')
@@ -70,8 +59,6 @@ dependencies {
implementation "androidx.credentials:credentials-play-services-auth:1.3.0" implementation "androidx.credentials:credentials-play-services-auth:1.3.0"
implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1" implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
// Android Resolver Dependencies Start // Android Resolver Dependencies Start
implementation 'com.android.installreferrer:installreferrer:2.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:7 implementation 'com.android.installreferrer:installreferrer:2.1' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:7
implementation 'com.applovin.mediation:facebook-adapter:[6.18.0.1]' // Assets/MaxSdk/Mediation/Facebook/Editor/Dependencies.xml:8 implementation 'com.applovin.mediation:facebook-adapter:[6.18.0.1]' // Assets/MaxSdk/Mediation/Facebook/Editor/Dependencies.xml:8
@@ -88,27 +75,14 @@ dependencies {
// Android Resolver Dependencies End // Android Resolver Dependencies End
**DEPS**} **DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android { android {
ndkPath "**NDKPATH**" ndkPath "**NDKPATH**"
compileSdkVersion **APIVERSION** compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**' buildToolsVersion '**BUILDTOOLS**'
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_11 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11
coreLibraryDesugaringEnabled true
} }
defaultConfig { defaultConfig {
@@ -117,7 +91,6 @@ android {
ndk { ndk {
abiFilters **ABIFILTERS** abiFilters **ABIFILTERS**
} }
versionCode **VERSIONCODE** versionCode **VERSIONCODE**
versionName '**VERSIONNAME**' versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD** consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**

View File

@@ -16,17 +16,6 @@ dependencyResolutionManagement {
**ARTIFACTORYREPOSITORY** **ARTIFACTORYREPOSITORY**
google() google()
mavenCentral() mavenCentral()
// Flexion SDK Maven Repository
maven {
url = uri("https://maven.pkg.github.com/FlexionSDK/JavaSDK")
credentials {
username = "FlexionSDK"
// Replace with your actual Flexion PAT from DropPoint
password = "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"
}
}
// Android Resolver Repos Start // Android Resolver Repos Start
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/") def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven { maven {

View File

@@ -2,7 +2,7 @@
"project_info": { "project_info": {
"project_number": "481260393117", "project_number": "481260393117",
"project_id": "fishing-travel", "project_id": "fishing-travel",
"storage_bucket": "fishing-travel.firebasestorage.app" "storage_bucket": "fishing-travel.appspot.com"
}, },
"client": [ "client": [
{ {
@@ -21,14 +21,6 @@
"certificate_hash": "c9cf2f5eaba383cbdd5b968d0342c49afabc32a2" "certificate_hash": "c9cf2f5eaba383cbdd5b968d0342c49afabc32a2"
} }
}, },
{
"client_id": "481260393117-vfn1jueugjqjach8kgc0kfi54g085q6l.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.arkgame.ft",
"certificate_hash": "53fd6ff623712411792a4665163e4cbf4a7a22ec"
}
},
{ {
"client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com", "client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
@@ -45,51 +37,6 @@
{ {
"client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com", "client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
},
{
"client_id": "481260393117-88n0v3ht8ashhk0r5ri47hced7o5qj62.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.arkgame.ft",
"app_store_id": "6505145935"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:481260393117:android:eafec4a060b0224907fa74",
"android_client_info": {
"package_name": "com.arkgame.ft.flexion"
}
},
"oauth_client": [
{
"client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBU6gAwu0O28jg7-TRd_Vx2YMCH_Baa8Bw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "481260393117-0ah0ekk7lu5r44ko2uqlfoebgak8dmhj.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "481260393117-88n0v3ht8ashhk0r5ri47hced7o5qj62.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.arkgame.ft",
"app_store_id": "6505145935"
}
} }
] ]
} }

View File

@@ -1,20 +1,13 @@
package com.unity3d.player; package com.unity3d.player;
public class ChannelHelpers { public class ChannelHelpers {
public static final String CHANNEL = "GooglePlay";
public static final String CHANNEL = "Flexion";
static void register() { static void register() {
SDKManager.registerHelper(new FlexionSDKHelper()); // GooglePlay uses default behavior, no additional SDKHelper
} }
// Flexion provides price in micros and currency code, so no normalization needed
// 支付的变化,可能会修改这里
public static String normalizeSkuList(String msg) { public static String normalizeSkuList(String msg) {
return msg; return msg;
} }
//public SDKExtBuilder;
} }

View File

@@ -6,7 +6,7 @@ public class ConfigManager {
public static String SDK_GAMEID = "20587"; public static String SDK_GAMEID = "20587";
public static String SDK_PROJECTID = "20587"; public static String SDK_PROJECTID = "20587";
public static String SDK_CLOUDID = "128"; public static String SDK_CLOUDID = "128";
public static String SDK_CLIENTID = "Android_5.00_tyGuest,facebook.googleplay.0-hall20587.flexion.FishingMaster"; public static String SDK_CLIENTID = "Android_5.00_tyGuest,facebook.googleplay.0-hall20587.googleplay.FishingMaster";
public static String SDK_LOGIN_SERVER_URL = "https://128-hwsfsdk-sdk-online01.qijihdhk.com"; public static String SDK_LOGIN_SERVER_URL = "https://128-hwsfsdk-sdk-online01.qijihdhk.com";

View File

@@ -1,285 +0,0 @@
package com.unity3d.player;
import android.app.Activity;
import android.util.Log;
import com.flexionmobile.ddpx.listener.ConnectionStateListener;
import com.flexionmobile.ddpx.listener.PurchasesUpdateListener;
import com.flexionmobile.ddpx.model.BillingResult;
import com.flexionmobile.ddpx.model.BillingResults;
import com.flexionmobile.ddpx.model.Purchase;
import com.flexionmobile.ddpx.model.ProductDetails;
import com.flexionmobile.ddpx.model.params.BillingFlowParams;
import com.flexionmobile.ddpx.model.params.ConsumeParams;
import com.flexionmobile.ddpx.model.params.QueryPurchasesParams;
import com.flexionmobile.ddpx.model.params.ProductDetailsParams;
import com.flexionmobile.ddpx.service.BillingService;
import com.flexionmobile.fdk.FLX;
import com.tuyoo.gamesdk.api.SDKAPI;
import com.tuyoo.gamesdk.api.SDKCallBack;
import com.tuyoo.gamesdk.model.InitParam;
import com.tuyoo.gamesdk.util.SDKLog;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Base64;
import java.util.List;
public class FlexionSDKHelper implements SDKManager.ISDKHelper {
private static final String TAG = "FlexionSDKHelper";
private static BillingService billingService;
private static boolean billingConnected = false;
private static final PurchasesUpdateListener purchasesListener = (billingResult, purchase) -> {
Log.i(TAG, "[PAY-FLOW] PurchasesUpdateListener: code=" + billingResult.getResponseCode()
+ " hasPurchase=" + (purchase != null));
if (billingResult.getResponseCode() == BillingResults.ResultCode.PURCHASE_SUCCESS_CODE) {
if (purchase != null) handlePurchase(purchase);
} else if (billingResult.getResponseCode() == BillingResults.ResultCode.PURCHASE_USER_CANCELLED_CODE) {
Log.i(TAG, "[PAY-FLOW] user cancelled");
sendPayCallback(1, "user_cancelled", null, null, null);
} else {
Log.e(TAG, "[PAY-FLOW] purchase failed: code=" + billingResult.getResponseCode());
sendPayCallback(1, "purchase_failed_" + billingResult.getResponseCode(), null, null, null);
}
};
@Override
public void init(Activity activity) {
activity.runOnUiThread(() -> {
SDKAPI.getIns().lightModeEnable();
boolean sdkInitOk = false;
try {
SDKAPI.getIns().init(new InitParam.Builder()
.withActivity(activity)
.withAppId(ConfigManager.SDK_APPID)
.withClientId(ConfigManager.SDK_CLIENTID)
.withServerUrl(ConfigManager.SDK_LOGIN_SERVER_URL)
.build());
SDKAPI.getIns().onActivityStart(activity);
SDKAPI.getIns().onActivityResume(activity);
sdkInitOk = true;
} catch (Exception e) {
Log.e(TAG, "TuYoo SDK init failed, skip FLX init: " + e);
TYUnityActivity.setSdkInited();
}
if (sdkInitOk) {
FLX.init(activity, (initCode, initMsg) -> {
Log.i(TAG, "FLX.init result=" + initCode);
if (initCode == 0) {
FLX.showFlexionScreens(activity, (screenCode, screenMsg) -> {
Log.i(TAG, "FLX.showFlexionScreens result=" + screenCode);
initBillingService(activity);
TYUnityActivity.setSdkInited();
});
} else {
Log.e(TAG, "FLX.init failed: " + initCode);
TYUnityActivity.setSdkInited();
}
});
}
});
}
@Override
public void pay(Activity activity, String productId, String productName,
String productCount, String prodorderId, String appInfo) {
Log.i(TAG, "[PAY-FLOW] pay called: productId=" + productId + " billingReady=" + billingConnected);
if (billingService == null || !billingConnected) {
Log.e(TAG, "[PAY-FLOW] billing not ready");
sendPayCallback(1, "billing_not_ready", null, null, null);
return;
}
String developerPayload = "";
try {
byte[] decoded = Base64.getDecoder().decode(appInfo);
JSONObject json = new JSONObject(new String(decoded, "UTF-8"));
JSONObject payload = new JSONObject();
payload.put("playerId", json.optString("playerId", ""));
payload.put("customData", json.optString("customData", ""));
developerPayload = payload.toString();
} catch (Exception e) {
Log.w(TAG, "Failed to extract playerId/customData from appInfo: " + e.getMessage());
}
String finalPayload = developerPayload;
activity.runOnUiThread(() -> {
Log.i(TAG, "[PAY-FLOW] launching billing flow for: " + productId + " payload=" + finalPayload);
billingService.launchBillingFlow(activity,
new BillingFlowParams(productId, "inapp", finalPayload));
});
}
@Override
public void queryProducts() {
Log.i(TAG, "queryProducts called, billingConnected=" + billingConnected);
if (billingService == null || !billingConnected) {
Log.w(TAG, "queryProducts: billing not ready");
sendExtensionError("billing_not_ready");
return;
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("action", "ACTION_GET_SKU_DETAILS_LIST");
} catch (JSONException e) {
throw new RuntimeException(e);
}
SDKAPI.getIns().thirdExtend(jsonObject.toString(), new SDKCallBack.Extend() {
@Override
public void callback(int code, String msg) {
Log.i(TAG, "TuYoo thirdExtend callback: code=" + code + " msg=" + msg);
if (code == SDKCallBack.Extend.EXTEND_CODE_SUCCESS && msg != null) {
try {
JSONArray products = new JSONArray(msg);
List<String> productIds = new java.util.ArrayList<>();
for (int i = 0; i < products.length(); i++) {
JSONObject p = products.getJSONObject(i);
String pid = p.optString("productId", "");
if (!pid.isEmpty()) productIds.add(pid);
}
Log.i(TAG, "queryProductDetails with " + productIds.size() + " items: " + productIds);
queryProductDetails(productIds);
} catch (JSONException e) {
sendExtensionError("parse_error: " + e.getMessage());
}
} else {
sendExtensionError("tuyoo_query_failed: " + msg);
}
}
});
}
// ---- Billing Infrastructure ----
private static void initBillingService(Activity activity) {
Log.i(TAG, "[PAY-FLOW] initBillingService");
billingService = FLX.createBillingService(activity, purchasesListener);
billingService.startConnection(activity, new ConnectionStateListener() {
@Override
public void onBillingSetupFinished(BillingResult result) {
Log.i(TAG, "[PAY-FLOW] onBillingSetupFinished: code=" + result.getResponseCode());
if (result.getResponseCode() == BillingResults.ResultCode.CONNECTION_SUCCESS_CODE) {
billingConnected = true;
queryPendingPurchases();
}
}
@Override
public void onBillingServiceDisconnected() {
Log.w(TAG, "[PAY-FLOW] billing service disconnected");
billingConnected = false;
}
});
}
private static void handlePurchase(Purchase purchase) {
Log.i(TAG, "[PAY-FLOW] handlePurchase: state=" + purchase.getPurchaseState()
+ " token=" + purchase.getToken());
if (purchase.getPurchaseState() == 0) {
Log.i(TAG, "[PAY-FLOW] purchaseJson=" + purchase.getPurchaseJson());
Log.i(TAG, "[PAY-FLOW] signature=" + purchase.getSignature());
sendPayCallback(0, "success", purchase.getPurchaseJson(), purchase.getSignature(), purchase.getToken());
} else if (purchase.getPurchaseState() == 2) {
Log.i(TAG, "[PAY-FLOW] purchase state=2 (pending)");
sendPayCallback(2, "pending", null, null, null);
}
}
private static void queryPendingPurchases() {
if (billingService == null || !billingConnected) return;
billingService.queryPurchasesAsync(
new QueryPurchasesParams("inapp"),
(result, purchases) -> {
if (purchases != null) for (Purchase p : purchases) handlePurchase(p);
});
}
private static void queryProductDetails(List<String> productIds) {
billingService.queryProductDetailsAsync(
new ProductDetailsParams("inapp", productIds),
(billingResult, productDetails) -> {
try {
JSONObject result = new JSONObject();
if (billingResult.getResponseCode() == BillingResults.ResultCode.QUERY_PRODUCT_DETAILS_SUCCESS_CODE
&& productDetails != null) {
JSONArray arr = new JSONArray();
for (ProductDetails detail : productDetails) {
JSONObject item = new JSONObject();
item.put("productId", detail.getId());
item.put("ourProductId", detail.getId());
item.put("title", detail.getTitle());
item.put("description", detail.getDescription());
item.put("price", detail.getPrice());
item.put("price_amount_micros", detail.getPriceAmountMicros());
item.put("price_currency_code", detail.getPriceCurrencyCode());
item.put("type", detail.getType());
arr.put(item);
}
result.put("code", 0);
result.put("respObj", arr.toString());
} else {
result.put("code", 1);
result.put("thirdExtend_errStr",
"flexion_query_failed: " + billingResult.getDebugMessage());
}
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_TYPE_CALLBACK_FUNCTION_NAME, result.toString());
} catch (JSONException e) {
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_TYPE_CALLBACK_FUNCTION_NAME, "{\"code\":1}");
}
});
}
// ---- Callbacks to Unity ----
private static void sendPayCallback(int code, String errStr,
String purchaseJson, String signature, String purchaseToken) {
Log.i(TAG, "[PAY-FLOW] sendPayCallback: code=" + code + " errStr=" + errStr
+ " hasPurchaseJson=" + (purchaseJson != null) + " hasSignature=" + (signature != null)
+ " hasToken=" + (purchaseToken != null));
try {
JSONObject result = new JSONObject();
result.put("code", code);
result.put("errStr", errStr != null ? errStr : "");
if (purchaseJson != null) result.put("purchaseJson", purchaseJson);
if (signature != null) result.put("signature", signature);
if (purchaseToken != null) result.put("purchaseToken", purchaseToken);
Log.i(TAG, "[PAY-FLOW] UnitySendMessage callback: " + result.toString());
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_CALLBACK_FUNCTION_NAME, result.toString());
} catch (JSONException e) {
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_CALLBACK_FUNCTION_NAME, "{\"code\":1,\"errStr\":\"json_error\"}");
}
}
public static void consumePurchase(String token) {
if (billingService == null || token == null || token.isEmpty()) {
Log.w(TAG, "[PAY-FLOW] consumePurchase: billingService or token is null");
return;
}
Log.i(TAG, "[PAY-FLOW] consumePurchase: token=" + token);
billingService.consumeAsync(
new ConsumeParams(token),
r -> Log.i(TAG, "[PAY-FLOW] consume result: " +
(r.getResponseCode() == BillingResults.ResultCode.CONSUME_SUCCESS_CODE ? "ok" : "fail")));
}
private static void sendExtensionError(String errStr) {
try {
JSONObject result = new JSONObject();
result.put("code", 1);
result.put("thirdExtend_errStr", errStr);
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_TYPE_CALLBACK_FUNCTION_NAME, result.toString());
} catch (JSONException e) {
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME,
ConfigManager.PAY_TYPE_CALLBACK_FUNCTION_NAME, "{\"code\":1}");
}
}
}

View File

@@ -1,32 +0,0 @@
fileFormatVersion: 2
guid: 4932bae8b9e69a447b0e2d7d3bcd0917
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -163,7 +163,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1 androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: applicationIdentifier:
Android: com.arkgame.ft.flexion Android: com.arkgame.ft
Standalone: com.Unity-Technologies.com.unity.template.urp-blank Standalone: com.Unity-Technologies.com.unity.template.urp-blank
iPhone: com.arkgame.ft iPhone: com.arkgame.ft
buildNumber: buildNumber: