Description
Hello, I keep getting this error code that prevents payment sheet to open in both iOS and Android, this is odd since I have not made any changes to the code, I did however, upgrade to flutter 3.0.1, but am unsure how this is related to the issue
Describe the bug
No payment sheet pops up in iOS and Android, this is the error message I get in terminal:
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Exception: Cannot read properties of undefined (reading 'id')
#0 _MealPrepCheckoutScreenState._createTestPaymentSheet (package:project_raven/screens/MealPreps/MealPrepScreens/checkout_screen.dart:292:7)
#1 _MealPrepCheckoutScreenState.initPaymentSheet (package:project_raven/screens/MealPreps/MealPrepScreens/checkout_screen.dart:300:20)
I saw a similar error in with Flutter Web Stripe integration, and the answer was that the payment method is wrong. I am a bit confused because I have not changed my code and suspect it could be an issue regarding how my json/functions is set up.
I read through this resource and think it helps narrow down my issue.
https://www.angularfix.com/2021/10/typeerror-cannot-read-properties-of_5.html
`
PayButton(
paymentProcessingLoading.text,
() {
setState(() {
paymentProcessingLoading.text = "true";
});
print(paymentProcessingLoading.text);
initPaymentSheet().then((value) => confirmPayment());
},
),
Future<Map<String, dynamic>> fetchPaymentIntentClientSecret() async {
final url = Uri.parse('x/stripePaymentIntentRequest');
final response = await http.post(
url,
headers: {
'Content-Type': 'application/json',
},
body: json.encode({
'email': globalMemberEmail,
'currency': 'usd',
'items': [
{'id': 'id'}
],
'request_three_d_secure': 'any',
}),
);
return json.decode(response.body);
}
Future<Map<String, dynamic>> _createTestPaymentSheet() async {
final url = Uri.parse('x/stripePaymentIntentRequest');
final response = await http.post(
url,
headers: {
'Content-Type': 'application/json',
},
body: json.encode({'email': globalMemberEmail, 'name': globalMemberFirstName, 'memberId': globalMemberID, 'amount': mealPrepTotalby100.text}),
);
final body = json.decode(response.body);
if (body['error'] != null) {
throw Exception(body['error']);
}
return body;
}