I implemented stripe connect with all the backend and now i just need to open the payment sheet the flutter_stripe packaged has provided. However I get an error that requires modification of source code which I can't do. Any possible fix for this?
There is no use building the app locally and modifying the MainActivity.kt as flutterflow will change it back.
flutter_stripe embedded integration error
Custom Code
I just implemented flutter_stripe and it is not working
// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/backend/sqlite/sqlite_manager.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:flutter_stripe/flutter_stripe.dart';
Future stripePayment(
BuildContext context,
String clientSecret,
) async {
Stripe.publishableKey =
'hidden_for_reasons';
try {
// Display the payment sheet
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: clientSecret,
style: ThemeMode.dark, // Customize theme mode (dark/light)
merchantDisplayName: 'My Promovation', // Customize business name
googlePay: PaymentSheetGooglePay(
// Enable Google Pay
merchantCountryCode: 'RO',
currencyCode: 'RON',
testEnv: true, // Set to false for production
),
allowsDelayedPaymentMethods:
false,
),
);
// Present the payment sheet to the user
await Stripe.instance.presentPaymentSheet();
// If payment succeeds, navigate or show success
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Payment Successful')),
);
} catch (e) {
// Handle any errors that occur during initialization or presentation
if (e is StripeException) {
print('Error from Stripe: ${e.error.localizedMessage}');
// Show the error to the user in your app's UI
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Payment failed: ${e.error.localizedMessage}')),
);
} else {
print('Unexpected error: $e');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error $e')),
);
}
}
}
Yes
2