这是我在这里的第一个帖子. 我正在费力地想在一个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,但仍然收到相同的错误,所以我认为我的后端与此无关