lpe 0.0.4
lpe: ^0.0.4 copied to clipboard
Learmond Pay Element - Paysheet built in flutter. Transposable to any app framework.
LPE (Learmond Pay Element) #
A reusable Flutter package for Stripe payment sheets, providing a simple modal interface for card, bank, Apple Pay, and Google Pay payments.
Features #
- Modal bottom sheet UI
- Card, US bank, EU bank, Apple Pay, Google Pay support
- Built on stripe.
- Easy API for payment confirmation and result handling context: context,
Quick usage #
You can either present the paysheet programmatically via LearmondPaySheet.show(...) or embed the single-line widget LearmondPayButtons into your UI. The widget renders Card / Bank buttons on the first row and Apple/Google Pay on the second row and centrally handles the pay flows.
Example (recommended):
import 'package:lpe/lpe.dart';
LearmondPayButtons(
publishableKey: 'pk_test_...'
clientSecret: 'pi_test_client_secret',
merchantId: 'merchant.com.yourdomain',
amount: '10.00',
onResult: (r) { /* handle */ },
),
Where to put the widget #
Place LearmondPayButtons in your checkout screen or checkout form where your user can see common payment options—typically beneath the order-total and above the confirm button. Example:
Column(
children: [
// ... cart/summary widgets ...
LearmondPayButtons(...),
ElevatedButton(onPressed: _placeOrder, child: Text('Place Order')),
],
)
The widget wires the pay buttons to both the Stripe paysheet and the native Apple/Google pay flows and returns the result via onResult for unified handling.
Programmatic / custom buttons #
If you want to use custom-styled buttons instead of LearmondPayButtons, call the paysheet or native bridge directly. Typical steps:
- For card/bank flows, create a PaymentIntent on your server and get the
client_secret. - Call
LearmondPaySheet.show(...)with theclientSecret. - For Apple/Google Pay, call
LearmondNativePay.showNativePay(...)and send the returned token to your server for finalization.
See lpe/INSTRUCTIONS.md for complete examples and server integration guidance.
## Installation
Add to your `pubspec.yaml`:
```yaml
dependencies:
lpe:
path: ../LPE
flutter_inappwebview: ^6.0.0
import 'package:lpe/learmond_pay_element.dart';
final result = await LearmondPaySheet.show( context: context, publishableKey: 'pk_test_...', clientSecret: 'pi_...secret...', method: 'card', // or 'us_bank', 'apple_pay', 'google_pay' title: 'Pay $10.00', ); if (result.success) { // Payment succeeded }
## API
- `LearmondPaySheet.show(...)` — Shows the payment sheet and returns a `PaymentResult`.
- Supports custom titles, amounts, and button labels.
## Example
See `example/` for a full integration example.
## License
MIT
## Author
The Learmond Corporation