【问题标题】:Flutter Firebase Stripe issue with json.decodejson.decode 的 Flutter Firebase Stripe 问题
【发布时间】:2022-01-22 09:30:16
【问题描述】:

我尝试在我的 Flutter Firebase 项目中实现 Stripe,但遇到了问题。

这是我的代码:

Future<void> makePayment () async {
final url = Uri.parse('***********');

final response = await http.get(url,
headers: {
  'Content-Type': 'application/json'
});

paymentIntentData = json.decode(response.body);
// Here's the issue

await Stripe.instance.initPaymentSheet(
  paymentSheetParameters: SetupPaymentSheetParameters(
    paymentIntentClientSecret: paymentIntentData!['paymentIntent'],
    applePay: true,
    googlePay: true,
    style: ThemeMode.dark,
    merchantCountryCode: 'US',
    merchantDisplayName: 'Test',
  )
);
setState(() {
  
});

displayPaymentSheet();
  }

遇到这个错误:

FormatException (FormatException: Unexpected character (at character 1)
Error: could not handle the request
^
)

我试图搜索它返回此错误的原因,但找不到。请有人可以解释我做错了什么?我不想用太多代码打扰你,如果你需要任何东西来帮助我理解我的错误在哪里,请告诉我。

【问题讨论】:

  • 请分享您的回复数据
  • 已经共享:final response = await http.get(url, headers: { 'Content-Type': 'application/json' });

标签: firebase flutter stripe-payments


【解决方案1】:

您好,您可以查看 Stripe Dashboard https://dashboard.stripe.com/logs 中的 Logs 并查看 Payment Intent 是否创建成功。

【讨论】:

  • 是的,但是“应用程序”字段为空,也许这就是问题?
猜你喜欢
  • 2020-09-17
  • 2019-06-04
  • 2019-04-30
  • 2023-04-04
  • 2021-04-27
  • 2021-11-22
  • 2020-06-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多