Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit a7977028
authored
2026-07-10 19:45:36 +0800
by
ethanlamzs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调试订购
1 parent
bfe36a4a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
17 deletions
lib/data/repositories/message/xe_create_order_handler.dart
lib/services/subscription_service_ios.dart
lib/data/repositories/message/xe_create_order_handler.dart
View file @
a797702
...
...
@@ -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
{
...
...
lib/services/subscription_service_ios.dart
View file @
a797702
...
...
@@ -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
;
}
// ✅ 关键:只要不是 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
)
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment