Kaynağa Gözat

[fix]新增支付错误提示

Destiny 1 yıl önce
ebeveyn
işleme
8c5e642d26

+ 8 - 1
lib/module/store/payment_status_manager.dart

@@ -61,8 +61,13 @@ class PaymentStatusManager {
         });
         reportPaySuccess(storeItemBean.amount, orderNo, storeItemBean.name,
             paymentWay.payMethod);
-      }).catchError((error) {
+      }).catchError((error) async {
         debugPrint('支付失败: orderNo = $orderNo, error = $error');
+        await _lock.synchronized(() {
+          callbackMap[orderNo]
+              ?.onPaymentError(error);
+          callbackMap.remove(orderNo);
+        });
       });
       pollingSubscriptionMap[orderNo] = orderFuture;
     });
@@ -109,6 +114,8 @@ class PaymentStatusException implements Exception {
 abstract class PaymentStatusCallback {
   void onPaymentSuccess(
       String orderNo, PaymentWay paymentWay, StoreItem storeItemBean);
+
+  void onPaymentError(Error error);
 }
 
 final paymentStatusManager = PaymentStatusManager._();

+ 8 - 0
lib/module/store/store_controller.dart

@@ -228,4 +228,12 @@ class StoreController extends BaseController implements PaymentStatusCallback {
     userRepository.getUserInfo();
     Get.back();
   }
+
+  @override
+  void onPaymentError(Error error) {
+    // TODO: implement onPaymentError
+    LoadingDialog.hide();
+    ErrorHandler.toastError(error);
+    userRepository.getUserInfo();
+  }
 }

+ 1 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # In Windows, build-name is used as the major, minor, and patch parts
 # of the product and file versions while build-number is used as the build suffix.
-version: 1.0.0+10
+version: 1.0.0+11
 
 environment:
   sdk: ^3.6.0