Skip to content

Commit 0dd243a

Browse files
committed
feat:update upm
0 parents  commit 0dd243a

36 files changed

+915
-0
lines changed

Mobile.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mobile/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mobile/Editor/NativeDependencies.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
<dependencies>
3+
<androidPackages>
4+
<repositories>
5+
<repository>https://repo.maven.apache.org/maven2</repository>
6+
</repositories>
7+
<androidPackage spec="com.taptap.android.payment:unity:4.5.3"/>
8+
<androidPackage spec="com.taptap.android.payment:stripe:4.5.3"/>
9+
<androidPackage spec="com.taptap.android.payment:alipay:4.5.3"/>
10+
<androidPackage spec="com.taptap.android.payment:braintree:4.5.3"/>
11+
<androidPackage spec="com.taptap.android.payment:alipaycn:4.5.3"/>
12+
<androidPackage spec="com.taptap.android.payment:wechat:4.5.3"/>
13+
</androidPackages>
14+
</dependencies>

Mobile/Editor/NativeDependencies.xml.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "TapSDK.IAP.Mobile.Editor",
3+
"references": [
4+
"GUID:56f3da7a178484843974054bafe77e73"
5+
],
6+
"includePlatforms": [
7+
"Editor"
8+
],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": false,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}

Mobile/Editor/TapSDK.IAP.Mobile.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using UnityEditor.Build.Reporting;
3+
using TapSDK.Core.Editor;
4+
5+
namespace TapSDK.IAP.Mobile.Editor {
6+
public class TapTapIAPMobileProcessBuild : SDKLinkProcessBuild {
7+
public override int callbackOrder => 0;
8+
9+
public override string LinkPath => "TapSDK/IAP/link.xml";
10+
11+
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
12+
new LinkedAssembly { Fullname = "TapSDK.IAP.Runtime" },
13+
new LinkedAssembly { Fullname = "TapSDK.IAP.Mobile.Runtime" }
14+
};
15+
16+
public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
17+
return BuildTargetUtils.IsSupportMobile(report.summary.platform);
18+
};
19+
}
20+
}

Mobile/Editor/TapTapIAPMobileProcessBuild.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mobile/Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "TapSDK.IAP.Mobile.Runtime",
3+
"references": [
4+
"GUID:52a25e2ba3ce94089bad4a5a6b3df5e1",
5+
"GUID:7d5ef2062f3704e1ab74aac0e4d5a1a7",
6+
"GUID:10560023d8780423cb943c7a324b69f2"
7+
],
8+
"includePlatforms": [
9+
"Android",
10+
"iOS"
11+
],
12+
"excludePlatforms": [],
13+
"allowUnsafeCode": false,
14+
"overrideReferences": false,
15+
"precompiledReferences": [],
16+
"autoReferenced": true,
17+
"defineConstraints": [],
18+
"versionDefines": [],
19+
"noEngineReferences": false
20+
}

Mobile/Runtime/TapSDK.IAP.Mobile.Runtime.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mobile/Runtime/TapTapIAPMobile.cs

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
using System.Collections.Generic;
2+
using TapSDK.Core;
3+
using TapSDK.IAP;
4+
using UnityEngine;
5+
using Newtonsoft.Json;
6+
using Newtonsoft.Json.Linq;
7+
using Newtonsoft.Json.Serialization;
8+
9+
namespace TapSDK.IAP.Mobile
10+
{
11+
public class SDKInitConfig
12+
{
13+
public static int ReginCode_CN = 0;
14+
public static int ReginCode_Global = 1;
15+
public int RegionCode { get; set; }// 0 = CN 1 = Global
16+
public bool EnableLog { get; set; }
17+
public bool IsRNDMode { get; set; }
18+
19+
public SDKInitConfig(int regionCode, bool enableLog, bool isRNDMode)
20+
{
21+
RegionCode = regionCode;
22+
EnableLog = enableLog;
23+
IsRNDMode = isRNDMode;
24+
}
25+
}
26+
27+
public class TapTapIAPMobile : ITapTapIAPBridge
28+
{
29+
public static string TAP_IAP_SERVICE = "BridgePaymentService";
30+
31+
public static string TDS_IAP_SERVICE_CLZ = "com.taptap.payment.sdk.unity.BridgePaymentService";
32+
33+
public static string TDS_IAP_SERVICE_IMPL = "com.taptap.payment.sdk.unity.BridgePaymentServiceImpl";
34+
35+
public TapTapIAPMobile()
36+
{
37+
EngineBridge.GetInstance().Register(TDS_IAP_SERVICE_CLZ, TDS_IAP_SERVICE_IMPL);
38+
}
39+
40+
public void Initialize(string clientId, string clientToken, int regionCode, bool enableLog, bool isRNDMode)
41+
{
42+
var config = new SDKInitConfig(regionCode, enableLog, isRNDMode);
43+
var settings = new JsonSerializerSettings
44+
{
45+
ContractResolver = new CamelCasePropertyNamesContractResolver(),
46+
Formatting = Formatting.Indented
47+
};
48+
49+
50+
// 将对象转换为 JSON 字符串
51+
string configStr = JsonConvert.SerializeObject(config, settings);
52+
var command = new Command.Builder()
53+
.Service(TAP_IAP_SERVICE)
54+
.Method("initSDK")
55+
.Args("clientId", clientId)
56+
.Args("clientToken", clientToken)
57+
.Args("initConfig", configStr)
58+
.CommandBuilder();
59+
EngineBridge.GetInstance().CallHandler(command);
60+
}
61+
62+
public void RetrieveProducts(string[] productIds, ITapTapIAPRetrieveProductCallback callback)
63+
{
64+
var command = new Command.Builder()
65+
.Service(TAP_IAP_SERVICE)
66+
.Method("retrieveProducts")
67+
.Args("products", productIds)
68+
.Callback(true)
69+
.OnceTime(false)
70+
.CommandBuilder();
71+
EngineBridge.GetInstance().CallHandler(command, (result) =>
72+
{
73+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
74+
{
75+
callback.OnQueryFailed(result.code, result.message + $"content = {result.content}");
76+
return;
77+
}
78+
79+
ApiResponse response = null;
80+
try
81+
{
82+
response = JsonConvert.DeserializeObject<ApiResponse>(result.content);
83+
}
84+
catch (JsonException ex)
85+
{
86+
callback.OnQueryFailed(Result.RESULT_ERROR, $"Failed to parse JSON: {ex.Message}");
87+
return;
88+
}
89+
90+
if (response != null && response.Code == 0)
91+
{
92+
callback.OnQuerySuccess(response.Content.ToArray());
93+
}
94+
else
95+
{
96+
callback.OnQueryFailed(result.code, response?.Message ?? "Unknown error");
97+
}
98+
});
99+
}
100+
101+
public void PurchaseProduct(string productId, string payload, ITapTapIAPPurchaseProductCallback callback)
102+
{
103+
var command = new Command.Builder()
104+
.Service(TAP_IAP_SERVICE)
105+
.Method("purchase")
106+
.Args("productId", productId)
107+
.Args("payload", payload)
108+
.Callback(true)
109+
.OnceTime(false)
110+
.CommandBuilder();
111+
EngineBridge.GetInstance().CallHandler(command, (result) =>
112+
{
113+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
114+
{
115+
callback.OnPurchaseFailed(productId, result.code, result.message + $"content = {result.content}");
116+
return;
117+
}
118+
119+
PurchaseApiResponse response = null;
120+
try
121+
{
122+
response = JsonConvert.DeserializeObject<PurchaseApiResponse>(result.content);
123+
}
124+
catch (JsonException ex)
125+
{
126+
callback.OnPurchaseFailed(productId, Result.RESULT_ERROR, $"purchase Failed to parse JSON: {ex.Message}");
127+
return;
128+
}
129+
130+
if (response != null && response.Code == 0 && response.Content.ProductId == productId && !string.IsNullOrEmpty(response.Content.PurchaseToken) && !string.IsNullOrEmpty(response.Content.OrderId))
131+
{
132+
callback.OnPurchaseSuccess(productId, response.Content.PurchaseToken, response.Content.OrderId);
133+
}
134+
else
135+
{
136+
callback.OnPurchaseFailed(productId, response.Code, $"illegal purchase result{response}");
137+
}
138+
139+
});
140+
}
141+
142+
143+
public void FinishTransaction(string transactionId)
144+
{
145+
var command = new Command.Builder()
146+
.Service(TAP_IAP_SERVICE)
147+
.Method("finishTransaction")
148+
.Args("transactionId", transactionId)
149+
.CommandBuilder();
150+
EngineBridge.GetInstance().CallHandler(command);
151+
}
152+
153+
public void RestorePurchase(ITapTapIAPUnFinishPurchaseCallback callback)
154+
{
155+
var command = new Command.Builder()
156+
.Service(TAP_IAP_SERVICE)
157+
.Method("restorePurchase")
158+
.Callback(true)
159+
.OnceTime(false);
160+
161+
EngineBridge.GetInstance().CallHandler(command.CommandBuilder(), (result) =>
162+
{
163+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
164+
{
165+
callback.OnFetchFailed(result.code, result.message + $"content = {result.content}");
166+
return;
167+
}
168+
169+
RestorePurchaseApiResponse response = null;
170+
try
171+
{
172+
response = JsonConvert.DeserializeObject<RestorePurchaseApiResponse>(result.content);
173+
}
174+
catch (JsonException ex)
175+
{
176+
callback.OnFetchFailed(Result.RESULT_ERROR, $"purchase Failed to parse JSON: {ex.Message}");
177+
return;
178+
}
179+
180+
if (response.Code == 0)
181+
{
182+
callback.OnFetchSuccess(response.Content.ToArray());
183+
}
184+
else
185+
{
186+
callback.OnFetchFailed(response.Code, $"restore failed internal {response}");
187+
}
188+
});
189+
}
190+
191+
}
192+
}

Mobile/Runtime/TapTapIAPMobile.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)