flutter 银行卡支付一体化中的显卡问题

rhfm7lfc  于 2023-02-20  发布在  Flutter
关注(0)|答案(1)|浏览(219)

我想整合条纹支付,但我得到了这个错误示例'StripeConfigException还有我的,当我点击支付按钮,它不显示任何类型的卡。我想打印jsonresponse ["emphermalKey"]和jsonresponse ["customer"],但这些显示空值。我还把API键正确。请解决我的问题,我在条纹支付卡住了几天这里是我的条纹日志鞋空值。

{
 "customer": null,
  "description": null,
  "invoice": null,
  "last_payment_error": null,
  "latest_charge": null,
"next_action": null,
  "on_behalf_of": null,
  "payment_method": null,
"payment_method_options": {
    "card": {
      "installments": null,
      "mandate_options": null,
      "network": null,
      "request_three_d_secure": "automatic"
    }
"processing": null,
  "review": null,
  "setup_future_usage": null,
  "shipping": null,
  "source": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "requires_payment_method",
  "transfer_data": null,
  "transfer_group": null
}

我的代码

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',
        customerId: jsonresponse['customer'],
        customerEphemeralKeySecret: jsonresponse['ephemeralKey'],
      ));
      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, );
    }
  }

我认为问题在这一行,当我注解出这个错误删除,但卡不显示

await Stripe.instance.presentPaymentSheet();
omvjsjqw

omvjsjqw1#

如果jsonresponse中没有任何值,则意味着后端无法返回它们,主要是因为它没有正确的密钥或发送Stripe API本身存在一些问题。
隔离问题的最快方法是查看后端日志或条带请求日志https://dashboard.stripe.com/test/logs,并从后端-〉条带中查找特定调用。

相关问题