Commit a7977028 by ethanlamzs

调试订购

1 parent bfe36a4a
......@@ -61,10 +61,10 @@ class XeCreateOrderHandler extends MessageHandler {
final deviceType = Platform.isIOS?"ios":"andorid";
print("[debug]. handleMessage 1 "+deviceType);
if (deviceType == 'andorid'){
await _wx_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, useCoin);
return await _wx_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, useCoin);
}else if (deviceType == 'ios'){
// 暂时不支持使用学币扣减
await _ios_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, false);
return await _ios_pay_proc_(userCode, tbxStuId, chargeCode, deviceType, phone, stuId, ext, duration, durationType, totalFee, renew, false);
}
}
......@@ -251,7 +251,8 @@ class XeCreateOrderHandler extends MessageHandler {
throw Exception('订单生成失败');
}
print("match product is "+product.price);
var isOk = _subService.buySubscription(product, userCode, tbxStuId,wxTradeNo);
var isOk = await _subService.buySubscription(product, userCode, tbxStuId,wxTradeNo);
print("[info] _subService.buySubscription res is "+isOk.toString());
if (isOk==true){
return {"orderUnique": wxTradeNo, "orderState": 1};
}else{
......
......@@ -101,16 +101,13 @@ class SubscriptionService {
for (final purchaseDetails in purchaseDetailsList) {
print('Purchase update: ${purchaseDetails.productID} - ${purchaseDetails.status}');
// 只处理订阅类型产品
if (!_isSubscription(purchaseDetails.productID)) continue;
if (!_isSubscription(purchaseDetails.productID)){
print("Purchase update !_isSubscription ");
continue;
}
// 根据交易状态处理
debugPrint("[info] _onPurchaseUpdate status is "+ purchaseDetails.status.toString());
switch (purchaseDetails.status) {
case PurchaseStatus.pending:
// 等待支付确认(例如需要家长批准),不做处理
break;
case PurchaseStatus.purchased:
// 购买成功或续期成功
......@@ -122,28 +119,22 @@ class SubscriptionService {
_verifyReceipt(purchaseDetails,orderId??'',"purchased");
// 2. 通知 App Store 交易完成
_iap.completePurchase(purchaseDetails);
break;
case PurchaseStatus.error:
// 处理错误
_handlePurchaseError(purchaseDetails.error!);
_iap.completePurchase(purchaseDetails); // 同样需要结束交易
break;
case PurchaseStatus.restored:
// 恢复购买成功
_verifyReceipt(purchaseDetails,"","restored");
_iap.completePurchase(purchaseDetails);
break;
case PurchaseStatus.canceled:
// 用户取消支付
_iap.completePurchase(purchaseDetails);
break;
default:
break;
default:
}
// ✅ 关键:只要不是 pending,都立刻完成交易,清出队列
......@@ -194,7 +185,7 @@ class SubscriptionService {
// ---------- 辅助方法 ----------
bool _isSubscription(String productId) {
return productId == monthlySubId_1 || productId == monthlySubId_1;
return productId == monthlySubId_1 || productId == monthlySubId_3|| productId == monthlySubId_6|| productId == monthlySubId_12;
}
void _handlePurchaseError(IAPError error) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!