Commit 45d44847 by ethanlamzs

调试订单

1 parent 01c75d92
...@@ -60,6 +60,12 @@ if [ ! -z "$ot" ]; then ...@@ -60,6 +60,12 @@ if [ ! -z "$ot" ]; then
if [ "$ot" == '11' ]; then if [ "$ot" == '11' ]; then
flutter run --dart-define=env=$env --dart-define=version=$_main_ver$_ver -d 00008030-001C75810E42402E flutter run --dart-define=env=$env --dart-define=version=$_main_ver$_ver -d 00008030-001C75810E42402E
fi fi
if [ "$ot" == 'sim' ]; then
flutter run --debug --dart-define=env=$env --dart-define=version=$_main_ver$_ver -d 89482737-FAA1-4145-BB2D-4B1B122B5B37
fi
else else
echo 'build else ' echo 'build else '
fi fi
......
...@@ -20,7 +20,7 @@ flutter pub get ...@@ -20,7 +20,7 @@ flutter pub get
#pod deintegrate #pod deintegrate
# 4. 清理 CocoaPods 本地缓存 (这一步很重要,ffmpeg 包很大,容易缓存损坏) # 4. 清理 CocoaPods 本地缓存 (这一步很重要,ffmpeg 包很大,容易缓存损坏)
pod cache clean --all #pod cache clean --all
# 5. 重新安装 Pods 并更新仓库索引 # 5. 重新安装 Pods 并更新仓库索引
# 注意:这一步可能比较慢,因为 ffmpeg 库非常大(几百MB),请保持网络通畅 # 注意:这一步可能比较慢,因为 ffmpeg 库非常大(几百MB),请保持网络通畅
......
...@@ -73,9 +73,6 @@ ...@@ -73,9 +73,6 @@
ReferencedContainer = "container:Runner.xcodeproj"> ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier = "../Runner/LocalIAP.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Profile" buildConfiguration = "Profile"
......
{
"appPolicies" : {
"eula" : "",
"policies" : [
{
"locale" : "en_US",
"policyText" : "",
"policyURL" : ""
}
]
},
"identifier" : "8ADF1697",
"nonRenewingSubscriptions" : [
{
"displayPrice" : "8.0",
"familyShareable" : false,
"internalID" : "9F78CD7A",
"localizations" : [
{
"description" : "vipm1",
"displayName" : "vipm1",
"locale" : "zh_Hans"
}
],
"productID" : "cn.banxe.appframe.membership.1m",
"referenceName" : "month1",
"type" : "NonRenewingSubscription"
},
{
"displayPrice" : "16.0",
"familyShareable" : false,
"internalID" : "119703EA",
"localizations" : [
{
"description" : "vipm2",
"displayName" : "vipm2",
"locale" : "zh_Hans"
}
],
"productID" : "cn.banxe.appframe.membership.2m",
"referenceName" : "month2",
"type" : "NonRenewingSubscription"
},
{
"displayPrice" : "22.0",
"familyShareable" : false,
"internalID" : "4768E67B",
"localizations" : [
{
"description" : "vipm3",
"displayName" : "vipm3",
"locale" : "zh_Hans"
}
],
"productID" : "cn.banxe.appframe.membership.3m",
"referenceName" : "month3",
"type" : "NonRenewingSubscription"
}
],
"products" : [
],
"settings" : {
"_askToBuyEnabled" : false,
"_billingGracePeriodEnabled" : false,
"_billingIssuesEnabled" : false,
"_disableDialogs" : false,
"_failTransactionsEnabled" : false,
"_locale" : "en_US",
"_renewalBillingIssuesEnabled" : false,
"_storefront" : "USA",
"_storeKitErrors" : [
],
"_timeRate" : 0
},
"subscriptionGroups" : [
],
"version" : {
"major" : 4,
"minor" : 0
}
}
...@@ -31,7 +31,7 @@ class XeCreateOrderHandler extends MessageHandler { ...@@ -31,7 +31,7 @@ class XeCreateOrderHandler extends MessageHandler {
@override @override
Future<dynamic> handleMessage(params) async { Future<dynamic> handleMessage(params) async {
print("handleMessage "+params); print("############## handleMessage #############");
// 从 params 中提取支付参数 // 从 params 中提取支付参数
final String chargeCode = params['chargeCode'] as String? ?? ''; final String chargeCode = params['chargeCode'] as String? ?? '';
final int durationType = params['durationType'] as int? ?? 0; final int durationType = params['durationType'] as int? ?? 0;
...@@ -64,7 +64,7 @@ class XeCreateOrderHandler extends MessageHandler { ...@@ -64,7 +64,7 @@ class XeCreateOrderHandler extends MessageHandler {
await _wx_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, useCoin); await _wx_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, useCoin);
}else if (deviceType == 'ios'){ }else if (deviceType == 'ios'){
// 暂时不支持使用学币扣减 // 暂时不支持使用学币扣减
await _ios_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, 0); await _ios_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, false);
} }
} }
...@@ -77,7 +77,6 @@ class XeCreateOrderHandler extends MessageHandler { ...@@ -77,7 +77,6 @@ class XeCreateOrderHandler extends MessageHandler {
throw Exception('设备上未安装微信App,不支持微信支付'); throw Exception('设备上未安装微信App,不支持微信支付');
} }
var result = await _userAuthRepository.createOrder(userCode, tbxStuId, chargeCode, duration, durationType, totalFee, var result = await _userAuthRepository.createOrder(userCode, tbxStuId, chargeCode, duration, durationType, totalFee,
renew, phone, stuId, ext, useCoin ? 1 : 0, deviceType); renew, phone, stuId, ext, useCoin ? 1 : 0, deviceType);
if (result == null) { if (result == null) {
...@@ -202,28 +201,31 @@ class XeCreateOrderHandler extends MessageHandler { ...@@ -202,28 +201,31 @@ class XeCreateOrderHandler extends MessageHandler {
// 执行ios的微信支付 // 执行ios的微信支付
Future<dynamic> _ios_pay_proc_ (String userCode, tbxStuId, chargeCode,deviceType,phone,stuId,ext,int duration, durationType, totalFee,bool renew, useCoin) async{ Future<dynamic> _ios_pay_proc_ (String userCode, tbxStuId, chargeCode,deviceType,phone,stuId,ext,int duration, durationType, totalFee,bool renew, useCoin) async{
print("[debug]. _ios_pay_proc_ 11 ");
// 暂时用固定的价格
var result = await _userAuthRepository.createOrder(userCode, tbxStuId, chargeCode, duration, durationType, totalFee, var result = await _userAuthRepository.createOrder(userCode, tbxStuId, chargeCode, duration, durationType, totalFee,
renew, phone, stuId, ext, useCoin ? 1 : 0, deviceType); renew, phone, stuId, ext, useCoin ? 1 : 0, deviceType);
print("[debug]. _ios_pay_proc_ 1 "); print("[debug]. _ios_pay_proc_ 12 ");
print(result);
// map[nonceStr:qNfHK6a95jjJkwzDkh0h3fhfUVuS0jZ9 paySign: timeStamp:1783497438 wxTradeNo:to1281644408384671744]
var data = result['data'] as Map<String, dynamic>?; var data = result['data'] as Map<String, dynamic>?;
if (data == null) { if (data == null) {
throw Exception('支付参数获取失败'); throw Exception('支付参数获取失败');
} }
print("[debug]. _ios_pay_proc_ 2 "); print("[debug]. _ios_pay_proc_ 13 ");
// 3. 从后端响应中提取预支付ID // 3. 从后端响应中提取预支付ID
final prepayId = data['prepayId'] as String?; final wxTradeNo = data['wxTradeNo'] as String?;
if (prepayId == null || prepayId.isEmpty) { if (wxTradeNo == null || wxTradeNo.isEmpty) {
throw Exception('预支付订单ID获取失败'); throw Exception('订单生成失败');
} }
// 4. 从后端响应中提取支付参数(nonceStr、timestamp、paySign 由后端生成) // 4. 从后端响应中提取支付参数(nonceStr、timestamp、paySign 由后端生成)
final timestamp = data['timeStamp'] as int; final timestamp = data['timeStamp'] as int;
final wxTradeNo = data['wxTradeNo'] as String;
print("[debug]. _ios_pay_proc_ 3 "); print("[debug]. _ios_pay_proc_ 3 ");
debugPrint('_ios_pay_proc_ => prepayId: $prepayId');
debugPrint('_ios_pay_proc_ => timestamp: $timestamp'); debugPrint('_ios_pay_proc_ => timestamp: $timestamp');
debugPrint('_ios_pay_proc_ => wxTradeNo: $wxTradeNo'); debugPrint('_ios_pay_proc_ => wxTradeNo: $wxTradeNo');
...@@ -235,9 +237,14 @@ class XeCreateOrderHandler extends MessageHandler { ...@@ -235,9 +237,14 @@ class XeCreateOrderHandler extends MessageHandler {
await _subService.initialize(); await _subService.initialize();
// 为了调试,先模拟 // 为了调试,先模拟
final product = _subService.products[0]; var product;
_subService.buySubscription(product, userCode, tbxStuId,wxTradeNo);
for (var p in _subService.products) {
debugPrint('x1=====> 产品ID: ${p.id}, 标题: ${p.title}, 价格: ${p.price}');
}
product = _subService.products[0];
_subService.buySubscription(product, userCode, tbxStuId,wxTradeNo);
} }
......
...@@ -163,8 +163,10 @@ class UserAuthRepository { ...@@ -163,8 +163,10 @@ class UserAuthRepository {
} }
// 检查ios的订单是否已经订阅 // 检查ios的订单是否已经订阅
Future<dynamic> orderCheck(String userId,String receipt,String orderid, String platform) async { Future<dynamic> orderCheck(String userId,String receipt,String orderid, String platform,int isSandbox ) async {
try { try {
debugPrint('收据长度: ${receipt.length}');
debugPrint('收据前100字符: ${receipt.substring(0, receipt.length > 100 ? 100 : receipt.length)}');
Response resp = await _appService.post( Response resp = await _appService.post(
'/api/v1/comm/user/ordercheck', '/api/v1/comm/user/ordercheck',
{ {
...@@ -172,6 +174,7 @@ class UserAuthRepository { ...@@ -172,6 +174,7 @@ class UserAuthRepository {
"receipt": receipt, "receipt": receipt,
"orderid":orderid, "orderid":orderid,
"platform": platform, "platform": platform,
"isSandbox":isSandbox,
}, },
); );
return resp.statusCode == HttpStatus.ok ? resp.data : null; return resp.statusCode == HttpStatus.ok ? resp.data : null;
......
...@@ -36,7 +36,6 @@ class MessageDispatcher { ...@@ -36,7 +36,6 @@ class MessageDispatcher {
Future<void> dispatch(String message, Function callback, {WebCubit? webCubit}) async { Future<void> dispatch(String message, Function callback, {WebCubit? webCubit}) async {
final Map<String, dynamic> data = json.decode(message); final Map<String, dynamic> data = json.decode(message);
H5Message h5Message = H5Message.fromJson(data); H5Message h5Message = H5Message.fromJson(data);
print(data);
var handler = _handlers[h5Message.cmd]; var handler = _handlers[h5Message.cmd];
if (handler == null) { if (handler == null) {
try { try {
......
// subscription_service.dart // subscription_service.dart
import 'dart:async'; import 'dart:async';
import 'package:in_app_purchase/in_app_purchase.dart'; import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:appframe/data/repositories/user_auth_repository.dart'; import 'package:appframe/data/repositories/user_auth_repository.dart';
import 'package:appframe/config/locator.dart'; import 'package:appframe/config/locator.dart';
...@@ -12,8 +11,9 @@ class SubscriptionService { ...@@ -12,8 +11,9 @@ 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_3 = 'cn.banxe.appframe.membership.3m'; static const String monthlySubId_3 = 'cn.banxe.appframe.membership.3m';
static const String monthlySubId_6 = 'cn.banxe.appframe.membership.6m';
static const String monthlySubId_12 = 'cn.banxe.appframe.membership.12m';
// 纯粹的数据容器,不继承任何类 // 纯粹的数据容器,不继承任何类
final Map<String, Map<String, dynamic>> _pendingContexts = {}; final Map<String, Map<String, dynamic>> _pendingContexts = {};
...@@ -54,7 +54,7 @@ class SubscriptionService { ...@@ -54,7 +54,7 @@ class SubscriptionService {
// ---------- 获取产品信息 ---------- // ---------- 获取产品信息 ----------
Future<void> _fetchProducts() async { Future<void> _fetchProducts() async {
const Set<String> ids = {monthlySubId_1,monthlySubId_2,monthlySubId_3}; const Set<String> ids = {monthlySubId_1,monthlySubId_3,monthlySubId_6,monthlySubId_12};
final ProductDetailsResponse response = await _iap.queryProductDetails(ids); final ProductDetailsResponse response = await _iap.queryProductDetails(ids);
...@@ -114,6 +114,7 @@ class SubscriptionService { ...@@ -114,6 +114,7 @@ class SubscriptionService {
final orderId = _orderIdMap.remove(purchaseDetails.productID); // 取出并删除 final orderId = _orderIdMap.remove(purchaseDetails.productID); // 取出并删除
final ctx = _pendingContexts[purchaseDetails.productID]; final ctx = _pendingContexts[purchaseDetails.productID];
print(ctx);
// 1. 验证收据(必须!) // 1. 验证收据(必须!)
_verifyReceipt(purchaseDetails,orderId??''); _verifyReceipt(purchaseDetails,orderId??'');
...@@ -147,7 +148,7 @@ class SubscriptionService { ...@@ -147,7 +148,7 @@ class SubscriptionService {
debugPrint('无收据数据'); debugPrint('无收据数据');
return; return;
} }
debugPrint("[info] _verifyReceipt is start "+purchaseDetails.productID +" : "+purchaseDetails.toString()); debugPrint("[info] _verifyReceipt is start "+purchaseDetails.productID);
// 将收据发送到你的后端进行验证 // 将收据发送到你的后端进行验证
final String receipt = purchaseDetails.verificationData.serverVerificationData; final String receipt = purchaseDetails.verificationData.serverVerificationData;
...@@ -164,10 +165,10 @@ class SubscriptionService { ...@@ -164,10 +165,10 @@ class SubscriptionService {
// 示例:发送收据到自己的服务器进行二次验证 // 示例:发送收据到自己的服务器进行二次验证
Future<bool> _sendReceiptToBackend(String receipt,String orderid) async { Future<bool> _sendReceiptToBackend(String receipt,String orderid) async {
var result = _userAuthRepository.orderCheck("",receipt,orderid,"ios"); var result = _userAuthRepository.orderCheck("",receipt,orderid,"ios",1);
//var data = result['data'] as Map<String, dynamic>?; //var data = result['data'] as Map<String, dynamic>?;
//debugPrint(result); //debugPrint(result);
debugPrint("[info] _sendReceiptToBackend is done receipt is "+receipt); debugPrint("[info] _sendReceiptToBackend is done");
return true; return true;
} }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!