waffy_sdk_flutter 0.1.0
waffy_sdk_flutter: ^0.1.0 copied to clipboard
Official Waffy payments SDK for Flutter. Embed the Waffy checkout in your app and get success or failure callbacks.
example/example.dart
import 'package:flutter/material.dart';
import 'package:waffy_sdk_flutter/waffy_sdk_flutter.dart';
void main() => runApp(const MaterialApp(home: CheckoutPage()));
class CheckoutPage extends StatelessWidget {
const CheckoutPage({super.key});
// Get these from your backend after creating a Waffy payment.
static const paymentUrl = 'https://example.com/checkout';
static const userToken = 'USER_TOKEN';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Waffy Checkout')),
body: WaffyPaymentWebView(
paymentUrl: paymentUrl,
userToken: userToken,
onPaymentComplete: (status, message) {
final text = status == WaffyPaymentStatus.success
? 'Payment succeeded'
: 'Payment failed: $message';
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(text)));
},
),
);
}
}