Commit dfb1fcfe by ethanlamzs

testing ios pay

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