Commit dfb1fcfe by ethanlamzs

testing ios pay

1 parent a53ff2fc
......@@ -12,7 +12,7 @@
"identifier" : "8ADF1697",
"nonRenewingSubscriptions" : [
{
"displayPrice" : "59.0",
"displayPrice" : "8.0",
"familyShareable" : false,
"internalID" : "9F78CD7A",
"localizations" : [
......@@ -27,7 +27,7 @@
"type" : "NonRenewingSubscription"
},
{
"displayPrice" : "120",
"displayPrice" : "16.0",
"familyShareable" : false,
"internalID" : "119703EA",
"localizations" : [
......@@ -42,7 +42,7 @@
"type" : "NonRenewingSubscription"
},
{
"displayPrice" : "180",
"displayPrice" : "22.0",
"familyShareable" : false,
"internalID" : "4768E67B",
"localizations" : [
......
......@@ -10,8 +10,8 @@ class SubscriptionService {
// App Store Connect 中配置的订阅产品 ID(组内唯一)
// 例如月度、年度两种方案
static const String monthlySubId_1 = 'cn.banxe.appframe.membership.1m';
// static const String monthlySubId_2 = 'cn.banxe.appframe.membership.2m';
// static const String monthlySubId_3 = 'cn.banxe.appframe.membership.3m';
static const String monthlySubId_2 = 'cn.banxe.appframe.membership.2m';
static const String monthlySubId_3 = 'cn.banxe.appframe.membership.3m';
final InAppPurchase _iap = InAppPurchase.instance;
late StreamSubscription<List<PurchaseDetails>> _purchaseUpdatedSubscription;
......@@ -45,7 +45,9 @@ class SubscriptionService {
// ---------- 获取产品信息 ----------
Future<void> _fetchProducts() async {
const Set<String> ids = {monthlySubId_1};
const Set<String> ids = {monthlySubId_1,monthlySubId_2,monthlySubId_3};
final ProductDetailsResponse response = await _iap.queryProductDetails(ids);
if (response.notFoundIDs.isNotEmpty) {
......@@ -56,8 +58,9 @@ class SubscriptionService {
_products = response.productDetails;
debugPrint('获取到 ${_products.length} 个产品');
for (var p in _products) {
debugPrint('产品ID: ${p.id}, 标题: ${p.title}, 价格: ${p.price}');
debugPrint('x1=====> 产品ID: ${p.id}, 标题: ${p.title}, 价格: ${p.price}');
}
}
// ---------- 购买订阅 ----------
......
......@@ -12,7 +12,9 @@ class SubscriptionPage extends StatefulWidget {
}
class _SubscriptionPageState extends State<SubscriptionPage> {
final SubscriptionService _subService = SubscriptionService();
bool _isInitialized = false;
@override
......@@ -32,32 +34,54 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
await _subService.buySubscription(product);
} catch (e) {
// 显示出错信息
debugPrint(e.toString());
}
}
@override
Widget build(BuildContext context) {
if (!_isInitialized) return CircularProgressIndicator();
return ListView.builder(
itemCount: _subService.products.length,
itemBuilder: (context, index) {
final product = _subService.products[index];
return ListTile(
title: Text(product.title),
subtitle: Text(product.description),
trailing: ElevatedButton(
onPressed: () => _buy(product),
child: Text(product.price),
// return ListView.builder(
// itemCount: _subService.products.length,
// itemBuilder: (context, index) {
// final product = _subService.products[index];
// return ListTile(
// title: Text(product.title),
// subtitle: Text(product.id),
// trailing: ElevatedButton(
// onPressed: () => _buy(product),
// child: Text(product.price),
// ),
// );
// },
// );
return Scaffold(
body: Center(
child: ListView.builder(
itemCount: _subService.products.length,
itemBuilder: (context, index) {
final product = _subService.products[index];
return ListTile(
title: Text(product.title),
subtitle: Text(product.description),
trailing: ElevatedButton(
onPressed: () => _buy(product),
child: Text(product.price),
),
);
},
),
);
},
),
);
}
@override
void dispose() {
_subService.dispose();
// _subService.dispose();
super.dispose();
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import flutter_image_compress_macos
import flutter_localization
import flutter_sound
import geolocator_apple
import in_app_purchase_storekit
import mobile_scanner
import network_info_plus
import open_file_mac
......@@ -23,10 +24,12 @@ import path_provider_foundation
import photo_manager
import shared_preferences_foundation
import sign_in_with_apple
import sqflite_darwin
import tencent_cloud_chat_sdk
import url_launcher_macos
import video_player_avfoundation
import volume_controller
import wakelock_plus
import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
......@@ -40,6 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterLocalizationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalizationPlugin"))
FlutterSoundPlugin.register(with: registry.registrar(forPlugin: "FlutterSoundPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
InAppPurchasePlugin.register(with: registry.registrar(forPlugin: "InAppPurchasePlugin"))
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin"))
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
......@@ -48,9 +52,11 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
TencentCloudChatSdkPlugin.register(with: registry.registrar(forPlugin: "TencentCloudChatSdkPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
VolumeControllerPlugin.register(with: registry.registrar(forPlugin: "VolumeControllerPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!