feat: Flexion 先验签后消费支付流程 + playerId 绑定

实现 Flexion 渠道支付验签重构:支付成功后不立即消费,将 purchaseJson/signature/purchaseToken
回调至 Unity,由服务端 SHA1withRSA 验签并校验 developerPayload.playerId 后再调用 consume。
同步更新 SDKManager 接口、UnityBridgeFunc 桥接、TYSdkModel 字段及 ExtraPluginCfgs。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-09 16:04:29 +08:00
parent 7fddc4e0f3
commit f60a1dd0c2
16 changed files with 343 additions and 96 deletions

View File

@@ -62,6 +62,9 @@ public class SDKTest : MonoBehaviour
[SerializeField]
private Text _messageTxt;
[SerializeField]
private Text _titleText;
void Start()
{
@@ -71,6 +74,7 @@ public class SDKTest : MonoBehaviour
GContext.container.RegisterInstance<IConfig>(config);
Debug.Log("SDKTest Start");
UpdateChannelTitle();
//===============================================================================
//====================== Test Server ===========================
// UnityBridgeFunc.UnityResetServerUrl("https://128-hwsfsdk-sdk-test01.qijihdhk.com");
@@ -130,6 +134,18 @@ public class SDKTest : MonoBehaviour
UnityBridgeFunc.UnityResetServerUrl("https://128-hwsfsdk-sdk-test01.qijihdhk.com");
}
private void UpdateChannelTitle()
{
#if UNITY_ANDROID
using (var cls = new AndroidJavaClass("com.unity3d.player.ChannelHelpers"))
{
string channel = cls.GetStatic<string>("CHANNEL");
Debug.Log($"[SDKTest] Channel from Java: {channel}");
_titleText.text = $" {channel}";
}
#endif
}
int retryAttempt;
public void InitializeRewardedAds()
@@ -161,6 +177,7 @@ public class SDKTest : MonoBehaviour
_messageTxt.text = $"Login: {info.isSuccess}";
if (info.isSuccess)
{
_messageTxt.text += $" UserId:{info.userId}";
_messageTxt.text += $"\n{info.msg}";
_messageTxt.text += $"\n{TYSdkFacade.TYAccountInfo.token}";
}
@@ -187,10 +204,23 @@ public class SDKTest : MonoBehaviour
public async void OnPayTestBtn()
{
_messageTxt.text = "";
if (ChannelConfig.Channel.Equals("Flexion"))
{
sku = new SKUDetail
{
productId = "com.arkgame.ft.pack0199",
ourProductId = "com.arkgame.ft.pack0199",
price = "1.99",
price_amount_micros = "1990000",
title = "Flexion Test Pack",
type = "inapp"
};
}
if (sku == null){
_messageTxt.text = "no product";
return;
}
}
#if !UNITY_EDITOR && UNITY_IOS
sku.productId = "comarkgameftpack0199";
@@ -201,7 +231,7 @@ public class SDKTest : MonoBehaviour
var purchaseInfo = new JObject();
purchaseInfo["pfid"] = "TestPlayer";
purchaseInfo["customData"] = "{\"test\":\"test\"}";
purchaseInfo["playerId"] = TYSdkFacade.TYAccountInfo.strUserId;
PaymentInfo payResult = await TYSdkFacade.Instance.Pay(sku, 1, sku.ProdPrice, purchaseInfo);
_messageTxt.text = "\n" + $"Success : {payResult.isSuccess}";
@@ -220,6 +250,7 @@ public class SDKTest : MonoBehaviour
_messageTxt.text = "products count:::" + result.products.Count;
_messageTxt.text += "\n" + result.products[0].ToString();
sku = result.products[0];
Debug.Log($"Sku -> {sku}");
}
else
{