API Integration
Integrating Stripe Payment Workflows in Flutter
By Pawan Kumawat • Published Nov 20, 2025 • 13 min read
1. Payment Workflow Architecture
Processing credit card payments inside a mobile application requires PCI-DSS security compliance. Mobile clients must never handle raw credit card numbers or store Stripe Secret Keys directly. Instead, payments follow a 3-step handshake:
- Client Request: Flutter app calls your secure backend API with the payment amount and currency.
- PaymentIntent Creation: Your server invokes Stripe's API using the Secret Key and returns a temporary `client_secret` string to the app.
- Native PaymentSheet: Flutter uses `flutter_stripe` to present Stripe's secure native payment UI modal, confirming the transaction directly with Stripe servers.
2. Setting Up `flutter_stripe`
Add `flutter_stripe` to your `pubspec.yaml` file:
pubspec.yaml
dependencies:
flutter_stripe: ^10.1.1
3. Implementing PaymentSheet in Flutter
payment_service.dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:http/http.dart' as http;
class StripePaymentService {
static Future<bool> makePayment({required String amount, required String currency}) async {
try {
// 1. Fetch PaymentIntent client secret from backend server
final paymentIntentData = await _createPaymentIntent(amount, currency);
final String clientSecret = paymentIntentData['client_secret'];
// 2. Initialize Payment Sheet
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: clientSecret,
merchantDisplayName: 'Pawan Kumawat Services',
style: ThemeMode.system,
),
);
// 3. Present Payment Sheet Modal
await Stripe.instance.presentPaymentSheet();
return true; // Payment completed successfully
} on StripeException catch (e) {
print("Stripe Error: ${e.error.localizedMessage}");
return false;
} catch (e) {
print("General Payment Error: $e");
return false;
}
}
static Future<Map<String, dynamic>> _createPaymentIntent(String amount, String currency) async {
final response = await http.post(
Uri.parse('https://your-backend-api.com/create-payment-intent'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({'amount': amount, 'currency': currency}),
);
return jsonDecode(response.body);
}
}
4. Conclusion
Utilizing Stripe's PaymentSheet keeps your mobile app secure, compliant, and responsive across iOS and Android.