这是我在这里的第一个帖子. 我正在费力地想在一个Ffltter项目中集成一个条纹,在网上找不到任何其他类似的问题或问题. 我用的是Flutter 翼方块和条纹.

一旦我运行函数await Stripe.instance.presentPaymentSheet();并try 用信用卡42424 42424 42424伪造付款.我有上面的错误:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>?'
#0      MethodChannelStripe.presentPaymentSheet
method_channel_stripe.dart:263
<asynchronous suspension>
#1      Stripe.presentPaymentSheet
stripe.dart:517
<asynchronous suspension>

我正在后端创建付款意图,我的条纹仪表板中的这一部分似乎一切正常

以下是我的代码的简短复制品:

Pubspec.yaml

  bloc: ^8.0.0
  flutter_bloc: ^8.0.0
  flutter_stripe: ^9.3.0

STRIPE_BLOCLE.DART

class StripeBloc extends Bloc<StripeEvent, StripeState> {
  StripeBloc() : super(const StripeState()) {
    on<RequestedStripePaymentEvent>(_onRequestedStripePaymentEvent);
  }

  void _onRequestedStripePaymentEvent(RequestedStripePaymentEvent event,
      Emitter<StripeState> emit) async {
    try {
      final Map<String, dynamic>? paymentIntent = await createPaymentIntent();
      await Stripe.instance.initPaymentSheet(
          paymentSheetParameters: SetupPaymentSheetParameters(

        paymentIntentClientSecret: paymentIntent?['client_secret'],
      ));
      await Stripe.instance.presentPaymentSheet();
    } on StripeException catch (e) {
      if (e.error.code == FailureCode.Canceled) {}
      if (e.error.code == FailureCode.Failed ||
          e.error.code == FailureCode.Timeout) {
      }
    } finally {
    }
  }
}

Stripe_api.dart

Future<Map<String, dynamic>?> createPaymentIntent() async {
  try {
    var response =
        await postAPIAuthenticated('path');
    return jsonDecode(response.body);
  } catch (err) {
    throw Exception(err);
  }
}

希望大家能帮我:)谢谢

我已经try 使我的代码尽可能地最小化. 我还try 在我的前端直接调用条带API,但仍然收到相同的错误,所以我认为我的后端与此无关

推荐答案

在过go 的两天里,这个问题在fltter_stripe程序包的GitHub存储库中被多次报告:

https://github.com/flutter-stripe/flutter_stripe/issues/1344

这似乎是由于9.3.0版的问题造成的.降级至9.2.2就解决了这个问题.对于其余的问题,我们可能需要等待STRIPE在内部解决.

希望能对你有所帮助!

Flutter相关问答推荐

关闭视频通话,相机仍在运行!(Flutter WebRTC)

相同的Flutter 代码库,但Firebase登录适用于Web应用程序,但无法登录iOS应用程序

在Flutter TextField中计算子字符串位置

Flutter BLoC et workmanager:如何创建独特的仓库初始化模式?

在Flutter 中实现中小型应用程序栏标题

如何在用Ffltter成功登录后重定向下一页?

Flutter 日期时间格式

Flutter 火焰相机抖动已弃用

FutureProvider 不返回数据给 UI

#Flutter/Riverpod - 使用 AsyncNotifier 时是否可以仅调用错误?

像图像一样Flutter 自定义标签

使用堆栈的自定义按钮

Flutter可滚动定位列表支持rtl方向吗?

Flutter:为什么我的 listTile colored颜色 被容器 colored颜色 覆盖了?

flutter 中 // 和 /// 有什么区别

改变步进器的线条 colored颜色 Flutter

我无法从 Cloud firestore 访问文档字段并在 statefulwidget 类中显示它

在flutter web中重新加载页面时保留一些状态数据的有效方法是什么?

Navigator.push '!_debugLocked' 上的错误:不正确

如何将所有行项目平等地放在一行中?Flutter