0

I want to intigrate stripe payment but i got this error Instance of 'StripeConfigException Also my when i click on pay button it is not showing any type of card. I want to print jsonresponse["emphermalKey"] and jsonresponse["customer"] but these show null value.I also put api key correctly . Please solve my issue i am stuck in stripe payment for couple of days Here is my stripe log which shoes null value.

{
 "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
}

my code

Center(
        child: ElevatedButton(
          onPressed: () {
            intpayment(email: "email,amount: 50.0);
            },
          child: Text("Pay20\$"),
        ),
      ),

Function

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, );
    }
  }

I think issue in this line when I comment out this the error remove but card is not displying

  await Stripe.instance.presentPaymentSheet();
2
  • Make the sure the api key you're using is correct. Commented Feb 17, 2023 at 4:33
  • Yes I am using correct api key . Commented Feb 17, 2023 at 4:58

1 Answer 1

0

If you don't have any value in jsonresponse it means you backend hasn't been able to return them, and mostly because it didn't have the correct Secret Key or having some issue sending Stripe API itself.

The fastest way to isolate the issue is looking at your backend log, or your Stripe Request Logs https://dashboard.stripe.com/test/logs and find the specific call from your backend -> Stripe.

Sign up to request clarification or add additional context in comments.

1 Comment

I am using correct Secret key .If issue is sending Stripe API itself. How to solve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.