smart_pay 0.0.1
smart_pay: ^0.0.1 copied to clipboard
A unified Flutter payments toolkit. Configure gateways (Stripe now; more soon), render a single methods widget, and checkout via one API.
Smart Pay
Unified payments for Flutter with a single API. Configure Stripe today, more gateways soon, and present a unified checkout experience.
Contents #
- Overview
- Features
- Installation
- Platform setup
- Quick start
- API
- Examples
- Roadmap (Coming Soon)
- FAQ
- Contributing
- License
- Changelog
Overview #
smart_pay lets you register multiple payment providers (starting with Stripe) and drive them with one consistent API. Render a single widget to pick a method and call one function to checkout.
Features #
- Configure providers via
SmartPay.configure - Show enabled methods with
SmartPayMethods - Checkout using the selected method with
SmartPay.checkout - Simple provider contract
PaymentProviderPluginto add gateways - Stripe PaymentSheet built-in (client-secret via backend or in-package REST)
- Store holds config and current selection
Installation #
Add the package to your pubspec:
dependencies:
smart_pay: any
Platform setup #
Stripe requires minimal platform configuration.
iOS #
- In
ios/Runner/Info.plist, add URL scheme for Stripe:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>stripe</string>
</array>
- Minimum iOS 12+ recommended.
Android #
- Ensure Android Gradle plugin and Kotlin versions meet Stripe requirements (AGP 8+, Kotlin 1.8+ recommended).
- Target Android 21+.
Refer to Stripe plugin docs if you encounter platform issues.
Quick start #
Configure Stripe and present the methods widget.
import 'package:smart_pay/smart_pay.dart';
void main() {
SmartPay.configure(
SmartPayConfig(
providers: [
// Option A: In-package REST creation (dev/sandbox only)
StripeProvider(
publishableKey: 'pk_test_...',
secretKey: 'sk_test_...',
),
// Option B (prod): get client secret from your backend
// StripeProvider(
// publishableKey: 'pk_live_...',
// createPaymentSheet: (req) async => StripePaymentSheetConfig(
// paymentIntentClientSecret: await MyApi.createIntent(req),
// merchantDisplayName: 'My Store',
// ),
// ),
],
),
);
}
Render methods and checkout:
// UI list of methods
SmartPayMethods(
store: SmartPay.store,
onMethodSelected: (provider) => print('selected: ${provider.id}'),
);
// Later: checkout with desired flow mode
final result = await SmartPay.checkout(
const PayRequest(
amountMinorUnits: 4999,
currency: 'USD',
description: 'Order #1001',
flowMode: PaymentFlowMode.auto, // backend if available, else in-package
),
);
print(result);
API #
SmartPay.configure(SmartPayConfig)- Registers providers and optional default selection
SmartPayMethods({ store, onMethodSelected })- Stateless widget showing enabled providers as selectable chips
SmartPay.checkout(PayRequest)- Uses selected provider to complete payment and returns
PaymentResult
- Uses selected provider to complete payment and returns
PaymentProviderPlugin- Implement
id,pay()to add a gateway
- Implement
- Models
PayRequest { amountMinorUnits, currency, description?, metadata?, flowMode }PaymentResult { success, providerId, transactionId?, message?, raw? }PaymentFlowMode { auto, backend, inPackage }
Stripe provider #
StripeProvider(
publishableKey: 'pk_...',
// Choose one
secretKey: 'sk_test_...', // in-package REST (dev/sandbox)
// or
// createPaymentSheet: (req) async => StripePaymentSheetConfig(
// paymentIntentClientSecret: await MyApi.createIntent(req),
// merchantDisplayName: 'My Store',
// ),
)
Examples #
See example/ for a minimal app with method selection and checkout.
Roadmap (Coming Soon) #
Gateways #
- ❌ Razorpay (Standard Checkout)
- ❌ Paystack (Standard Checkout)
- ❌ PayPal (URL + SDK flows)
- ❌ Stripe Link
Wallets #
- ❌ Apple Pay (via Stripe PaymentSheet)
- ❌ Google Pay (via Stripe PaymentSheet)
Developer Experience #
- ❌ Server helpers/snippets (Dart/Node templates)
- ❌ Advanced UI customization and theming
- ❌ More examples and cookbook
FAQ #
- Why not include secrets in production?
- Keep server secrets on your backend; in-package REST is for local/dev only.
- Can I add my own provider?
- Yes, implement
PaymentProviderPluginand register it inSmartPay.configure.
- Yes, implement
Contributing #
PRs and issues are welcome. See the full guidelines in CONTRIBUTING.md.
License #
MIT - see LICENSE.
Changelog #
See CHANGELOG.md for release notes.