Stripe 不会初始化付款表
Stripe wont intialize paymentsheet
我正在尝试在我的 flutter 应用程序中实施 Stripe,但我 运行 遇到了这个问题:
StripeException(error: LocalizedErrorMessage(code: FailureCode.Failed, localizedMessage: No payment sheet has been initialized yet, message: No payment sheet has been initialized yet, stripeErrorCode: null, declineCode: null, type: null))
我当前的代码是:
Future<void> makePayment() async {
final response = await http.post(
Uri.parse(
api_string,
),
headers: {"Content-Type": "application/json; charset=utf-8"},
body: json.encode({"Amount": "250"}),
);
var data = json.decode(response.body);
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: data['clientSecret'],
merchantDisplayName: 'Flutter test app',
applePay: true,
googlePay: true,
style: ThemeMode.dark,
testEnv: true,
merchantCountryCode: 'DK',
),
);
setState(() {});
await displayPaymentSheet();
}
Future<void> displayPaymentSheet() async {
try {
await Stripe.instance.presentPaymentSheet();
} catch (e) {
print(e);
}
}
我查看了官方flutter_stripe文档,但是我的API改变的例子给出了同样的错误,我的api return "clientSecret": Secret }
如评论中所述,解决方法是将 merchantId 添加到 Stripe 初始化中
我正在尝试在我的 flutter 应用程序中实施 Stripe,但我 运行 遇到了这个问题:
StripeException(error: LocalizedErrorMessage(code: FailureCode.Failed, localizedMessage: No payment sheet has been initialized yet, message: No payment sheet has been initialized yet, stripeErrorCode: null, declineCode: null, type: null))
我当前的代码是:
Future<void> makePayment() async {
final response = await http.post(
Uri.parse(
api_string,
),
headers: {"Content-Type": "application/json; charset=utf-8"},
body: json.encode({"Amount": "250"}),
);
var data = json.decode(response.body);
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: data['clientSecret'],
merchantDisplayName: 'Flutter test app',
applePay: true,
googlePay: true,
style: ThemeMode.dark,
testEnv: true,
merchantCountryCode: 'DK',
),
);
setState(() {});
await displayPaymentSheet();
}
Future<void> displayPaymentSheet() async {
try {
await Stripe.instance.presentPaymentSheet();
} catch (e) {
print(e);
}
}
我查看了官方flutter_stripe文档,但是我的API改变的例子给出了同样的错误,我的api return "clientSecret": Secret }
如评论中所述,解决方法是将 merchantId 添加到 Stripe 初始化中