You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter Stripe设置PayPal未来支付方式时遇异常错误

Flutter Stripe 初始化支付表单异常排查(PayPal未来支付场景)

问题详情

  • 场景:通过flutter_stripe配置PayPal未来支付方式,调用initPaymentSheet初始化支付表单时触发异常。
  • 涉事代码:
await Stripe.instance.initPaymentSheet(
  paymentSheetParameters: const SetupPaymentSheetParameters(
    setupIntentClientSecret:
        "seti_1OuCs4LiqSZoNeCk9JuMfuvt_secret_PjgEOcH1iqZOvE7tU5f17kmtW9vRIsh",
    style: ThemeMode.system,
    allowsDelayedPaymentMethods: true,
    merchantDisplayName: 'MyApp',
  ),
);
  • 翻译后的报错信息:

flutter: StripeException(error: LocalizedErrorMessage(code: FailureCode.Failed, localizedMessage: 发生意外错误,请稍后重试, message: 发生意外错误,请稍后重试, stripeErrorCode: null, declineCode: null, type: null))

排查建议

  • 校验Setup Intent密钥有效性:确认setupIntentClientSecret是从Stripe后端正确生成的有效密钥,避免直接硬编码(硬编码密钥易过期或权限不足),建议通过自有后端接口动态获取。
  • 检查PayPal支付方式配置:确保你的Stripe账户已开通PayPal支付功能,且创建Setup Intent时指定了payment_method_types: ['paypal']参数。
  • 版本兼容性检查:确认flutter_stripe版本与Stripe API版本匹配,尝试升级至最新稳定版。
  • 网络与权限验证:确保设备网络连接正常;iOS端检查Info.plist是否配置网络权限,Android端确认AndroidManifest.xml中存在网络访问权限。
  • 临时替换密钥测试:使用新生成的有效Setup Intent密钥替换当前硬编码值,重新执行初始化操作。

内容的提问来源于stack exchange,提问作者Mayank Tripathi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 07:50:05