【发布时间】: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