|
|
@@ -659,140 +659,4 @@ class NewDiscountController extends BaseController
|
|
|
// ToastUtil.show("Restore fail");
|
|
|
// }
|
|
|
}
|
|
|
-
|
|
|
- /// 恢复订阅
|
|
|
- Future<void> clickRestore() async {
|
|
|
- PayWayInfo? paymentWay = _selectedPayWay.value;
|
|
|
- if (paymentWay == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int payPlatform = paymentWay.payPlatform;
|
|
|
- int payMethod = paymentWay.payMethod;
|
|
|
-
|
|
|
- CustomLoadingDialog.show();
|
|
|
-
|
|
|
- Future.delayed(const Duration(seconds: 20), () {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore record not found");
|
|
|
- });
|
|
|
-
|
|
|
- final result = await ApplePay().restore();
|
|
|
- if (result["success"] == true) {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- var receipt = result['receipt'];
|
|
|
- print('查找恢复记录成功: ${result['receipt']}');
|
|
|
- checkRestoreStatus(receipt);
|
|
|
- } else {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Pay Error");
|
|
|
- print('恢复失败: ${result['error']}');
|
|
|
- }
|
|
|
-
|
|
|
- // 显示恢复订阅弹窗
|
|
|
- // RecoverSubscribeDialog.show("周会员2025年3月6日到期。", () {
|
|
|
- // AtmobLog.d(tag, "恢复订阅弹窗 => 点击确认");
|
|
|
- // });
|
|
|
- }
|
|
|
-
|
|
|
- /// 检查恢复订阅结果
|
|
|
- Future<void> checkRestoreStatus(String? receiptData) async {
|
|
|
- PayWayInfo? paymentWay = _selectedPayWay.value;
|
|
|
- if (paymentWay == null) {
|
|
|
- // ToastUtil.showToast(StringName.storeChoicePayment.tr);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (receiptData == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int payPlatform = paymentWay.payPlatform;
|
|
|
- int payMethod = paymentWay.payMethod;
|
|
|
- // var code = await storeRepository.resume(payPlatform, payMethod, receiptData);
|
|
|
- storeRepository.subscribeResume(payPlatform, payMethod, receiptData).then((data) {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore success");
|
|
|
- accountRepository.getUserInfo();
|
|
|
- Get.back();
|
|
|
- }).catchError((error) {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore fail");
|
|
|
- });
|
|
|
-
|
|
|
- // if (code == 0) {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- // ToastUtil.show("Restore success");
|
|
|
- // userRepository.getUserInfo();
|
|
|
- // Get.back();
|
|
|
- // } else {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- // ToastUtil.show("Restore fail");
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
- /// 恢复订阅
|
|
|
- Future<void> clickRestore() async {
|
|
|
- PayWayInfo? paymentWay = _selectedPayWay.value;
|
|
|
- if (paymentWay == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int payPlatform = paymentWay.payPlatform;
|
|
|
- int payMethod = paymentWay.payMethod;
|
|
|
-
|
|
|
- CustomLoadingDialog.show();
|
|
|
-
|
|
|
- Future.delayed(const Duration(seconds: 20), () {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore record not found");
|
|
|
- });
|
|
|
-
|
|
|
- final result = await ApplePay().restore();
|
|
|
- if (result["success"] == true) {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- var receipt = result['receipt'];
|
|
|
- print('查找恢复记录成功: ${result['receipt']}');
|
|
|
- checkRestoreStatus(receipt);
|
|
|
- } else {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Pay Error");
|
|
|
- print('恢复失败: ${result['error']}');
|
|
|
- }
|
|
|
-
|
|
|
- // 显示恢复订阅弹窗
|
|
|
- // RecoverSubscribeDialog.show("周会员2025年3月6日到期。", () {
|
|
|
- // AtmobLog.d(tag, "恢复订阅弹窗 => 点击确认");
|
|
|
- // });
|
|
|
- }
|
|
|
-
|
|
|
- /// 检查恢复订阅结果
|
|
|
- Future<void> checkRestoreStatus(String? receiptData) async {
|
|
|
- PayWayInfo? paymentWay = _selectedPayWay.value;
|
|
|
- if (paymentWay == null) {
|
|
|
- // ToastUtil.showToast(StringName.storeChoicePayment.tr);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (receiptData == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int payPlatform = paymentWay.payPlatform;
|
|
|
- int payMethod = paymentWay.payMethod;
|
|
|
- // var code = await storeRepository.resume(payPlatform, payMethod, receiptData);
|
|
|
- storeRepository.subscribeResume(payPlatform, payMethod, receiptData).then((data) {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore success");
|
|
|
- accountRepository.getUserInfo();
|
|
|
- Get.back();
|
|
|
- }).catchError((error) {
|
|
|
- CustomLoadingDialog.hide();
|
|
|
- ToastUtil.show("Restore fail");
|
|
|
- });
|
|
|
-
|
|
|
- // if (code == 0) {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- // ToastUtil.show("Restore success");
|
|
|
- // userRepository.getUserInfo();
|
|
|
- // Get.back();
|
|
|
- // } else {
|
|
|
- // CustomLoadingDialog.hide();
|
|
|
- // ToastUtil.show("Restore fail");
|
|
|
- // }
|
|
|
- }
|
|
|
}
|