Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdk-public
unity_sdk_demo
Commits
b14817ef
Commit
b14817ef
authored
Oct 15, 2025
by
fengchao
Browse files
fix(code):修改支付
parent
bf801037
Changes
7
Hide whitespace changes
Inline
Side-by-side
Assets/Plugins/iOS/UnityAppController.h.meta
deleted
100644 → 0
View file @
bf801037
fileFormatVersion: 2
guid: 7c52c6bae4f6d42c296f0de9df536ef5
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:
Assets/Plugins/iOS/UnityAppController.mm.meta
deleted
100644 → 0
View file @
bf801037
fileFormatVersion: 2
guid: 12d3c24cb8df145abb64f72b45206b99
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:
Assets/Plugins/iOS/UnityBridge.h.meta
deleted
100644 → 0
View file @
bf801037
fileFormatVersion: 2
guid: fbcc30c9db7014f8f8e136ddfd11516e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:
Assets/Plugins/iOS/UnityBridge.mm
View file @
b14817ef
...
@@ -38,24 +38,24 @@ extern "C" {
...
@@ -38,24 +38,24 @@ extern "C" {
@"channelId"
:
@
(
initResult
.
channelId
)
@"channelId"
:
@
(
initResult
.
channelId
)
};
};
NSString
*
json
=
jsonStringWithObject
(
dict
);
NSString
*
json
=
jsonStringWithObject
(
dict
);
UnitySendMessage
(
"
SdkManager"
,
"OnSdkInit
"
,
[
json
UTF8String
]);
UnitySendMessage
(
"
PlatformCallback"
,
"onInitSuccess
"
,
[
json
UTF8String
]);
}
}
-
(
void
)
initFailed
{
-
(
void
)
initFailed
{
NSLog
(
@"🍎 SDK初始化失败"
);
NSLog
(
@"🍎 SDK初始化失败"
);
UnitySendMessage
(
"
SdkManager"
,
"OnSdkInit
"
,
"failed"
);
UnitySendMessage
(
"
PlatformCallback"
,
"onInitFailed
"
,
"failed"
);
}
}
#pragma mark - HLPaymentDelegate
#pragma mark - HLPaymentDelegate
-
(
void
)
paySuccess
{
-
(
void
)
paySuccess
{
NSLog
(
@"🍎 支付成功"
);
NSLog
(
@"🍎 支付成功"
);
UnitySendMessage
(
"
SdkManager"
,
"OnSdkPay
"
,
"pay_success"
);
UnitySendMessage
(
"
PlatformCallback"
,
"onPaySuccess
"
,
"pay_success"
);
}
}
-
(
void
)
payError
:(
NSError
*
)
error
{
-
(
void
)
payError
:(
NSError
*
)
error
{
NSLog
(
@"🍎 支付失败: %@"
,
error
.
localizedDescription
);
NSLog
(
@"🍎 支付失败: %@"
,
error
.
localizedDescription
);
NSString
*
errorMsg
=
[
NSString
stringWithFormat
:
@"pay_failed:%@"
,
error
.
localizedDescription
];
NSString
*
errorMsg
=
[
NSString
stringWithFormat
:
@"pay_failed:%@"
,
error
.
localizedDescription
];
UnitySendMessage
(
"
SdkManager"
,
"OnSdkPay
"
,
[
errorMsg
UTF8String
]);
UnitySendMessage
(
"
PlatformCallback"
,
"onPayFailed
"
,
[
errorMsg
UTF8String
]);
}
}
-
(
void
)
payGoodsList
:(
NSArray
<
AccessGoodsInfo
*>*
)
info
{
-
(
void
)
payGoodsList
:(
NSArray
<
AccessGoodsInfo
*>*
)
info
{
...
@@ -76,12 +76,12 @@ extern "C" {
...
@@ -76,12 +76,12 @@ extern "C" {
[
array
addObject
:
dict
];
[
array
addObject
:
dict
];
}
}
NSString
*
json
=
jsonStringWithObject
(
array
);
NSString
*
json
=
jsonStringWithObject
(
array
);
UnitySendMessage
(
"
SdkManager
"
,
"
O
nPayGoodsList"
,
[
json
UTF8String
]);
UnitySendMessage
(
"
PlatformCallback
"
,
"
o
nPayGoodsList"
,
[
json
UTF8String
]);
}
}
-
(
void
)
payGpodsListFail
{
-
(
void
)
payGpodsListFail
{
NSLog
(
@"🍎 获取商品列表失败"
);
NSLog
(
@"🍎 获取商品列表失败"
);
UnitySendMessage
(
"
SdkManager
"
,
"OnGoodsList"
,
"get_goods_failed"
);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnGoodsList"
,
"get_goods_failed"
);
}
}
#pragma mark - HLAccountDelegate
#pragma mark - HLAccountDelegate
...
@@ -96,7 +96,7 @@ extern "C" {
...
@@ -96,7 +96,7 @@ extern "C" {
@"extendInfo"
:
accountInfo
.
extendInfo
?:
@{}
@"extendInfo"
:
accountInfo
.
extendInfo
?:
@{}
};
};
NSString
*
json
=
jsonStringWithObject
(
dict
);
NSString
*
json
=
jsonStringWithObject
(
dict
);
UnitySendMessage
(
"
SdkManager
"
,
"OnLoginSuccess"
,
[
json
UTF8String
]);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnLoginSuccess"
,
[
json
UTF8String
]);
}
}
-
(
void
)
refreshUser
:(
AccessLoginInfo
*
)
refreshAccountInfo
{
-
(
void
)
refreshUser
:(
AccessLoginInfo
*
)
refreshAccountInfo
{
...
@@ -110,28 +110,28 @@ extern "C" {
...
@@ -110,28 +110,28 @@ extern "C" {
@"extendInfo"
:
refreshAccountInfo
.
extendInfo
?:
@{}
@"extendInfo"
:
refreshAccountInfo
.
extendInfo
?:
@{}
};
};
NSString
*
json
=
jsonStringWithObject
(
dict
);
NSString
*
json
=
jsonStringWithObject
(
dict
);
UnitySendMessage
(
"
SdkManager
"
,
"OnUserRefresh"
,
[
json
UTF8String
]);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnUserRefresh"
,
[
json
UTF8String
]);
}
}
-
(
void
)
loginFailure
{
-
(
void
)
loginFailure
{
NSLog
(
@"🍎 登录失败"
);
NSLog
(
@"🍎 登录失败"
);
UnitySendMessage
(
"
SdkManager
"
,
"OnSdkLogin"
,
"login_failed"
);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnSdkLogin"
,
"login_failed"
);
}
}
-
(
void
)
logout
{
-
(
void
)
logout
{
NSLog
(
@"🍎 用户登出"
);
NSLog
(
@"🍎 用户登出"
);
UnitySendMessage
(
"
SdkManager
"
,
"OnSdkLogout"
,
"logout_success"
);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnSdkLogout"
,
"logout_success"
);
}
}
#pragma mark - HLShareCallback
#pragma mark - HLShareCallback
-
(
void
)
shareSucceeded
:(
BOOL
)
result
{
-
(
void
)
shareSucceeded
:(
BOOL
)
result
{
NSLog
(
@"🍎 分享成功: %@"
,
result
?
@"YES"
:
@"NO"
);
NSLog
(
@"🍎 分享成功: %@"
,
result
?
@"YES"
:
@"NO"
);
UnitySendMessage
(
"
SdkManager
"
,
"OnSdkShare"
,
"share_success"
);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnSdkShare"
,
"share_success"
);
}
}
-
(
void
)
shareFailed
:(
BOOL
)
result
{
-
(
void
)
shareFailed
:(
BOOL
)
result
{
NSLog
(
@"🍎 分享失败: %@"
,
result
?
@"YES"
:
@"NO"
);
NSLog
(
@"🍎 分享失败: %@"
,
result
?
@"YES"
:
@"NO"
);
UnitySendMessage
(
"
SdkManager
"
,
"OnSdkShare"
,
"share_failed"
);
UnitySendMessage
(
"
PlatformCallback
"
,
"OnSdkShare"
,
"share_failed"
);
}
}
@end
@end
...
@@ -255,12 +255,12 @@ extern "C" {
...
@@ -255,12 +255,12 @@ extern "C" {
if
(
error
)
return
;
if
(
error
)
return
;
// 直接映射字段
// 直接映射字段
payInfo
.
productIdentifier
=
jsonDict
[
@"
Product
Id"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
Product
Id"
]]
:
@""
;
payInfo
.
productIdentifier
=
jsonDict
[
@"
item
Id"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
item
Id"
]]
:
@""
;
payInfo
.
price
=
jsonDict
[
@"
Price
"
]
?
[
jsonDict
[
@"
Price
"
]
intValue
]
:
0
;
payInfo
.
price
=
jsonDict
[
@"
amount
"
]
?
[
jsonDict
[
@"
amount
"
]
intValue
]
:
0
;
payInfo
.
currencyLocale
=
jsonDict
[
@"
C
urrency"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
C
urrency"
]]
:
@""
;
payInfo
.
currencyLocale
=
jsonDict
[
@"
c
urrency"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
c
urrency"
]]
:
@""
;
payInfo
.
notifyUrl
=
jsonDict
[
@"
N
otifyUrl"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
N
otifyUrl"
]]
:
@""
;
payInfo
.
notifyUrl
=
jsonDict
[
@"
n
otifyUrl"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
n
otifyUrl"
]]
:
@""
;
payInfo
.
gameInfo
=
jsonDict
[
@"
Game
Info"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
Game
Info"
]]
:
@""
;
payInfo
.
gameInfo
=
jsonDict
[
@"
callback
Info"
]
?
[
NSString
stringWithFormat
:
@"%@"
,
jsonDict
[
@"
callback
Info"
]]
:
@""
;
NSLog
(
@"🍎 支付信息: productId=%@, price=%d"
,
payInfo
.
productIdentifier
,
payInfo
.
price
);
NSLog
(
@"🍎 支付信息: productId=%@, price=%d"
,
payInfo
.
productIdentifier
,
payInfo
.
price
);
[
sdk
pay
:
payInfo
];
[
sdk
pay
:
payInfo
];
}
}
...
...
Assets/Plugins/iOS/UnityBridge.mm.meta
deleted
100644 → 0
View file @
bf801037
fileFormatVersion: 2
guid: 8a2bed7a3301d4300827ecb96648cd28
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/sdk/core/PlatformCallback.cs
View file @
b14817ef
...
@@ -67,6 +67,9 @@ public class PlatformCallback : MonoBehaviour
...
@@ -67,6 +67,9 @@ public class PlatformCallback : MonoBehaviour
public
void
onInitSuccess
(
string
jsonStr
)
public
void
onInitSuccess
(
string
jsonStr
)
{
{
Debug
.
Log
(
"Unity onInitSuccess: "
+
jsonStr
);
NativeLogger
.
I
(
"fastsdk_unity_result"
,
"[AndroidBrigsCall] onInitSuccess called with result: "
+
jsonStr
);
NativeLogger
.
I
(
"fastsdk_unity_result"
,
"[AndroidBrigsCall] onInitSuccess called with result: "
+
jsonStr
);
InitResult
result
=
JsonConvert
.
DeserializeObject
<
InitResult
>(
jsonStr
);
InitResult
result
=
JsonConvert
.
DeserializeObject
<
InitResult
>(
jsonStr
);
if
(
result
!=
null
)
if
(
result
!=
null
)
...
...
Assets/Scripts/sdk/util/NativeLogger.cs
View file @
b14817ef
...
@@ -29,7 +29,7 @@ public static class NativeLogger
...
@@ -29,7 +29,7 @@ public static class NativeLogger
#elif UNITY_IOS
#elif UNITY_IOS
// 在 iOS 设备上,调用自定义的 NSLog 封装
// 在 iOS 设备上,调用自定义的 NSLog 封装
// (需要在 Xcode 项目中添加一个 .mm 文件来实现 _logToConsole)
// (需要在 Xcode 项目中添加一个 .mm 文件来实现 _logToConsole)
//
_logToConsole($"[I] [{tag}] {message}");
_logToConsole
(
$"[I] [
{
tag
}
]
{
message
}
"
);
#endif
#endif
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment