|
|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:io';
|
|
|
|
|
|
import 'package:classify_photo/classify_photo.dart';
|
|
|
+import 'package:clean/data/repositories/user_repository.dart';
|
|
|
import 'package:clean/module/store/payment_status_manager.dart';
|
|
|
import 'package:flutter/Material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
@@ -30,20 +31,11 @@ class StoreController extends BaseController implements PaymentStatusCallback {
|
|
|
|
|
|
@override
|
|
|
Future<void> onInit() async {
|
|
|
- // TODO: implement onInit
|
|
|
- // StoreItem item1 = StoreItem(id: 1, sort: 1, name: "11111", appleGoodsId: "1111", subscribable: 1, amount: 100, originalAmount: 100, auth: "auth", subscriptionMillis: 1, content: "content", priceDesc: "priceDesc", coefficient: 1);
|
|
|
- // StoreItem item2 = StoreItem(id: 2, sort: 1, name: "11111", appleGoodsId: "1111", subscribable: 1, amount: 100, originalAmount: 100, auth: "auth", subscriptionMillis: 1, content: "content", priceDesc: "priceDesc", coefficient: 1);
|
|
|
- // StoreItem item3 = StoreItem(id: 3, sort: 1, name: "11111", appleGoodsId: "1111", subscribable: 1, amount: 100, originalAmount: 100, auth: "auth", subscriptionMillis: 1, content: "content", priceDesc: "priceDesc", coefficient: 1);
|
|
|
- //
|
|
|
- // storeItems.add(item1);
|
|
|
- // storeItems.add(item2);
|
|
|
- // storeItems.add(item3);
|
|
|
- //
|
|
|
- // currentSelectedStoreItem.value = item1;
|
|
|
|
|
|
initStoreIndexData();
|
|
|
-
|
|
|
print(await ClassifyPhoto().checkTrialEligibility());
|
|
|
+
|
|
|
+ // AgilePay.check();
|
|
|
}
|
|
|
|
|
|
void initStoreIndexData() {
|
|
|
@@ -60,6 +52,32 @@ class StoreController extends BaseController implements PaymentStatusCallback {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ Future<void> onRestoreClick() async {
|
|
|
+ PaymentWay? paymentWay = currentSelectedPaymentWay.value;
|
|
|
+ if (paymentWay == null) {
|
|
|
+ // ToastUtil.showToast(StringName.storeChoicePayment.tr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int payPlatform = paymentWay.payPlatform;
|
|
|
+ int payMethod = paymentWay.payMethod;
|
|
|
+
|
|
|
+ AgilePay.restore(success: (String? result) {
|
|
|
+ LoadingDialog.show("");
|
|
|
+ checkRestoreStatus(result);
|
|
|
+ Future.delayed(const Duration(seconds: 30), () {
|
|
|
+ LoadingDialog.hide();
|
|
|
+ });
|
|
|
+ }, payError: (int error, String? errorMessage) {
|
|
|
+ debugPrint('zk---payError: $error, $errorMessage');
|
|
|
+ // errorPayToast(error);
|
|
|
+ LoadingDialog.hide();
|
|
|
+ }, error: (int errno, String? error) {
|
|
|
+ debugPrint('zk---error: $errno, $error');
|
|
|
+ // errorPayToast(errno);
|
|
|
+ LoadingDialog.hide();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
void onBuyClick() async {
|
|
|
|
|
|
StoreItem? storeItem = currentSelectedStoreItem.value;
|
|
|
@@ -74,7 +92,7 @@ class StoreController extends BaseController implements PaymentStatusCallback {
|
|
|
}
|
|
|
int payPlatform = paymentWay.payPlatform;
|
|
|
int payMethod = paymentWay.payMethod;
|
|
|
- // LoadingDialog.show(StringName.storePayLoading.tr);
|
|
|
+ LoadingDialog.show("");
|
|
|
try {
|
|
|
OrderPayResponse response =
|
|
|
await storeRepository.orderPay(storeItem.id, payPlatform, payMethod);
|
|
|
@@ -114,6 +132,21 @@ class StoreController extends BaseController implements PaymentStatusCallback {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 检查恢复订阅结果
|
|
|
+ void checkRestoreStatus(String? receiptData) {
|
|
|
+ PaymentWay? paymentWay = currentSelectedPaymentWay.value;
|
|
|
+ if (paymentWay == null) {
|
|
|
+ // ToastUtil.showToast(StringName.storeChoicePayment.tr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (receiptData == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int payPlatform = paymentWay.payPlatform;
|
|
|
+ int payMethod = paymentWay.payMethod;
|
|
|
+ var code = storeRepository.resume(payPlatform, payMethod, receiptData);
|
|
|
+ }
|
|
|
+
|
|
|
void checkPaymentStatus(
|
|
|
String orderNo, PaymentWay paymentWay, StoreItem storeItemBean,
|
|
|
{String? receiptData}) {
|
|
|
@@ -127,6 +160,7 @@ class StoreController extends BaseController implements PaymentStatusCallback {
|
|
|
// TODO: implement onPaymentSuccess
|
|
|
LoadingDialog.hide();
|
|
|
ToastUtil.show("Pay success");
|
|
|
+ userRepository.getUserInfo();
|
|
|
Get.back();
|
|
|
}
|
|
|
}
|