【发布时间】:2023-02-18 04:12:49
【问题描述】:
我想 intigrate 条纹支付,但我得到了这个错误 ** 在调用 presentPaymentOptions() 之前,必须使用 configureWithPaymentIntent() 或 configureWithSetupIntent() 成功初始化 FlowController** 如何解决这个错误也没有显示任何卡片
Center(
child: ElevatedButton(
onPressed: () {
intpayment(email: "email,amount: 50.0);
},
child: Text("Pay20\$"),
),
),
Future<void> intpayment(
{required String email, required double amount})async{
try{
final response= await http.post(Uri.parse("https://api.stripe.com/v1/payment_intents")
,body:{
"receipt_email": email,
"amount": amount.toInt().toString(),
"currency": "usd"
},
headers: {
'Authorization': 'Bearer ' + 'key',
'Content-Type': 'application/x-www-form-urlencoded'
}
);
final jsonresponse=jsonDecode(response.body); Stripe.instance.initPaymentSheet(paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: jsonresponse['paymentIntent'],
merchantDisplayName: 'Zohaib',
));
await Stripe.instance.presentPaymentSheet();
Fluttertoast.showToast(
msg: "payment successfully",
);
}
catch(e){
if (e is StripeException) {
Fluttertoast.showToast(
msg: "Stripe error $e",
);
}
Fluttertoast.showToast(
msg: "$e",
toastLength: Toast.LENGTH_SHORT, );
}
}
【问题讨论】:
-
您是否设置了 Android 端代码?我们必须更改 MainActivity.kt 同样在 Main 函数中确保您已添加条带可发布密钥
-
如何更改 MainActivity.kt?
-
我已经更改 MainActivity.kt 但问题是一样的