update:更新tysdk:注意直接consume了
This commit is contained in:
@@ -25,4 +25,5 @@ public class ConfigManager {
|
||||
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "SKUListResult";
|
||||
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
||||
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
||||
public static final String INIT_CALLBACK_FUNCTION_NAME = "InitResult";
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public class FlexionSDKHelper implements SDKManager.ISDKHelper {
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "TuYoo SDK init failed, skip FLX init: " + e);
|
||||
TYUnityActivity.setSdkInited();
|
||||
SDKManager.notifyInitResult(false, "tuyoo_init_failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (sdkInitOk) {
|
||||
@@ -77,10 +78,12 @@ public class FlexionSDKHelper implements SDKManager.ISDKHelper {
|
||||
Log.i(TAG, "FLX.showFlexionScreens result=" + screenCode);
|
||||
initBillingService(activity);
|
||||
TYUnityActivity.setSdkInited();
|
||||
SDKManager.notifyInitResult(true, "ok");
|
||||
});
|
||||
} else {
|
||||
Log.e(TAG, "FLX.init failed: " + initCode);
|
||||
TYUnityActivity.setSdkInited();
|
||||
SDKManager.notifyInitResult(false, "flx_init_failed: " + initCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -114,8 +117,41 @@ public class FlexionSDKHelper implements SDKManager.ISDKHelper {
|
||||
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));
|
||||
Log.i(TAG, "[PAY-FLOW] billingService=" + billingService + " billingConnected=" + billingConnected);
|
||||
try {
|
||||
BillingResult result = billingService.launchBillingFlow(activity,
|
||||
new BillingFlowParams(productId, "inapp", finalPayload));
|
||||
Log.i(TAG, "[PAY-FLOW] launchBillingFlow result: code=" + result.getResponseCode()
|
||||
+ " debugMsg=" + result.getDebugMessage());
|
||||
if (result.getResponseCode() == 2001) {
|
||||
Log.i(TAG, "[PAY-FLOW] service not ready, retry after 3s...");
|
||||
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
|
||||
try {
|
||||
BillingResult retryResult = billingService.launchBillingFlow(activity,
|
||||
new BillingFlowParams(productId, "inapp", finalPayload));
|
||||
Log.i(TAG, "[PAY-FLOW] launchBillingFlow retry result: code=" + retryResult.getResponseCode()
|
||||
+ " debugMsg=" + retryResult.getDebugMessage());
|
||||
if (retryResult.getResponseCode() != 2000) {
|
||||
sendPayCallback(1, "billing_flow_error_" + retryResult.getResponseCode()
|
||||
+ "_" + retryResult.getDebugMessage(), null, null, null);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
sendPayCallback(1, "launch_billing_failed: " + ex.getMessage(), null, null, null);
|
||||
}
|
||||
}, 3000);
|
||||
return;
|
||||
}
|
||||
if (result.getResponseCode() != 2000) {
|
||||
Log.e(TAG, "[PAY-FLOW] launchBillingFlow error: code=" + result.getResponseCode()
|
||||
+ " debugMsg=" + result.getDebugMessage());
|
||||
sendPayCallback(1, "billing_flow_error_" + result.getResponseCode()
|
||||
+ "_" + result.getDebugMessage(), null, null, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "[PAY-FLOW] launchBillingFlow exception: " + e.getClass().getName()
|
||||
+ " msg=" + e.getMessage());
|
||||
sendPayCallback(1, "launch_billing_failed: " + e.getMessage(), null, null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,12 +220,15 @@ public class FlexionSDKHelper implements SDKManager.ISDKHelper {
|
||||
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());
|
||||
// 支付成功 → 回传数据给 Unity 做服务端验签,验签通过后由 C# 调 ConsumePurchase
|
||||
Log.i(TAG, "[PAY-FLOW] purchase success, sending to Unity for verification");
|
||||
sendPayCallback(0, "success",
|
||||
purchase.getPurchaseJson(), purchase.getSignature(), purchase.getToken());
|
||||
// [旧逻辑] 直接消费,跳过验签
|
||||
// Log.i(TAG, "[PAY-FLOW] auto-consuming pending purchase: " + purchase.getToken());
|
||||
// consumePurchase(purchase.getToken());
|
||||
} else if (purchase.getPurchaseState() == 2) {
|
||||
Log.i(TAG, "[PAY-FLOW] purchase state=2 (pending)");
|
||||
sendPayCallback(2, "pending", null, null, null);
|
||||
Log.i(TAG, "[PAY-FLOW] purchase state=2 (pending), skip");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,4 +25,5 @@ public class ConfigManager {
|
||||
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "SKUListResult";
|
||||
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
||||
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
||||
public static final String INIT_CALLBACK_FUNCTION_NAME = "InitResult";
|
||||
}
|
||||
|
||||
@@ -25,4 +25,5 @@ public class ConfigManager {
|
||||
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "SKUListResult";
|
||||
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
||||
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
||||
public static final String INIT_CALLBACK_FUNCTION_NAME = "InitResult";
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ dependencies {
|
||||
implementation 'com.appsflyer:purchase-connector:2.2.0' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:8
|
||||
implementation 'com.appsflyer:unity-wrapper:6.17.7' // Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml:6
|
||||
implementation 'com.google.android.ump:user-messaging-platform:2.1.0' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:5
|
||||
implementation 'com.tapjoy:tapjoy-android-unitybridge:14.5.0' // Packages/com.unity.package-offerwall/Editor/TJPluginDependencies.xml:10
|
||||
// Android Resolver Dependencies End
|
||||
**DEPS**}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ dependencyResolutionManagement {
|
||||
mavenCentral()
|
||||
// Android Resolver Repos Start
|
||||
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
|
||||
maven {
|
||||
url "https://sdk.tapjoy.com/" // Packages/com.unity.package-offerwall/Editor/TJPluginDependencies.xml:9
|
||||
}
|
||||
maven {
|
||||
url "https://android-sdk.is.com/" // Assets/MaxSdk/Mediation/IronSource/Editor/Dependencies.xml:8
|
||||
}
|
||||
|
||||
@@ -83,6 +83,10 @@ public class SDKTest : MonoBehaviour
|
||||
//===============================================================================
|
||||
//
|
||||
_InitBtn.onClick.AddListener(Init);
|
||||
TYSdkFacade.OnInitComplete += (success, msg) =>
|
||||
{
|
||||
_messageTxt.text = success ? $"Init OK: {msg}" : $"Init Failed: {msg}";
|
||||
};
|
||||
_loginGuestBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest));
|
||||
_loginGoogleBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle));
|
||||
_loginFbBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwFacebook));
|
||||
@@ -113,6 +117,7 @@ public class SDKTest : MonoBehaviour
|
||||
|
||||
void Init()
|
||||
{
|
||||
_messageTxt.text = "Initializing...";
|
||||
TYSdkFacade.Instance.Init();
|
||||
TDAnalytics.Init("0caf287574bd4a9bb08be8995705ef6f", "https://122-slg-online01.qijihdhk.com:8991");
|
||||
|
||||
@@ -132,6 +137,7 @@ public class SDKTest : MonoBehaviour
|
||||
Debug.Log($"customId = {customId}, customId_2 = {customId_2}");
|
||||
|
||||
UnityBridgeFunc.UnityResetServerUrl("https://128-hwsfsdk-sdk-test01.qijihdhk.com");
|
||||
GContext.container.Resolve<IConfig>().Set("PAY_VERIFY_URL", "https://192.168.9.91:7036/api/FlexionCallback");
|
||||
}
|
||||
|
||||
private void UpdateChannelTitle()
|
||||
|
||||
@@ -381,10 +381,6 @@ public class SDKManager {
|
||||
|
||||
public static void UnityKnow(String productId, String productName, String productCount,
|
||||
String prodorderId, String appInfo) {
|
||||
if (sdkHelper != null) {
|
||||
sdkHelper.pay(UnityPlayer.currentActivity, productId, productName, productCount, prodorderId, appInfo);
|
||||
return;
|
||||
}
|
||||
SDKLog.i("UnityKnow : " + productId);
|
||||
HashMap<String, String> extraInfo = new HashMap<String, String>();
|
||||
extraInfo.put("appInfo", appInfo);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
Reference in New Issue
Block a user