Stripe Flutter 无法在 IOS 模拟器中显示付款

Stripe Flutter can't display payment in IOS simulator

我正在使用这个库来处理 Flutter Stripe:https://pub.dev/packages/flutter_stripe

这是我的集团中成功创建付款意向并显示付款的功能sheet。

paymentSink.add(Status.Loading);
logData(key, 'Stripe Pay');
//create payment intent
var response = await paymentRepository.createPaymentIntent(200, 'USD');
paymentSink.add(Status.Successful);
var paymentIntentData = json.decode(response.body);
await stripe.initPaymentSheet(
    paymentSheetParameters: SetupPaymentSheetParameters(
  applePay: true,
  googlePay: true,
  style: ThemeMode.dark,
  testEnv: true,
  merchantDisplayName: 'Flutter Stripe Store Demo',
  customerId: paymentIntentData!['customer'],
  paymentIntentClientSecret: paymentIntentData['client_secret'],
  customerEphemeralKeySecret: paymentIntentData['ephemeralKey'],
));
//display payment sheet
await displayPaymentSheet();
if(isSuccessPaid){
  logData(key, 'isSuccessPaid: $isSuccessPaid');
  //handle result after payment successfully
}

这是显示支付sheet功能

try {
  await stripe.presentPaymentSheet().then((value) {
    isSuccessPaid = true;
  }).onError((error, stackTrace){
    GetIt.I<AppSnackBar>().show(error.toString());
    logData(key,error.toString());
  });
} catch (e) {
  GetIt.I<AppSnackBar>().show(e.toString());
  logData(key, '$e');
}

问题是 Android 模拟器像这样完美工作

但是IOS模拟器无法显示,终端显示这样的错误

我不知道这是平台错误还是模拟器问题problem.Anyone遇到这样的问题?请help.Thanks!

2022 年 4 月 14 日星期四更新 对于和我有同样问题的人,我只想分享这样的基本答案:

await stripe.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
    applePay: true,
    googlePay: true,
    testEnv: true,
    merchantCountryCode: 'US',
    merchantDisplayName: 'Prospects',
    customerId: paymentIntentData!['customer'] ?? 'Customer',
    paymentIntentClientSecret: paymentIntentData!['client_secret'],
  ));

customerId 和 paymentIntentClientSecret 不能为 null 所以仔细检查 null 安全性并且响应数据必须有 client_secret 字段